Mojo struct
ContiguousSlice
struct ContiguousSlice
Represents a slice expression without a stride.
This type is used to support different behavior for strided vs unstrided slicing.
Fields
- start (
Optional[Int]): The starting index of the slice. - end (
Optional[Int]): The end index of the slice.
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable
comptime members
__copyinit__is_trivial
comptime __copyinit__is_trivial = False
__del__is_trivial
comptime __del__is_trivial = False
__moveinit__is_trivial
comptime __moveinit__is_trivial = False
Methods
__init__
__init__(out self, start: Optional[Int], end: Optional[Int], stride: NoneType)
Construct slice given the start and end values.
Args:
indices
indices(self, length: Int) -> Tuple[Int, Int]
Returns a tuple of 2 integers representing the start, and end of the slice if applied to a container of the given length.
Args:
- length (
Int): The length of the target container.
Returns:
Tuple: A tuple containing two integers for start and and.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!