struct
Span
A non owning view of contiguous data.
Parameters
- T (
CollectionElement
): The type of the elements in the span. - is_mutable (
Bool
): Whether the span is mutable. - lifetime (
lifetime<#lit.struct.extract<:_stdlib::_builtin::_bool::_Bool is_mutable, "value">>
): The lifetime of the Span.
Implemented traits
AnyType
,
Copyable
,
Movable
,
Sized
Methods
__init__
__init__(inout self: Self, *, unsafe_ptr: UnsafePointer[T, 0], len: Int)
Unsafe construction from a pointer and length.
Args:
- unsafe_ptr (
UnsafePointer[T, 0]
): The underlying pointer of the span. - len (
Int
): The length of the view.
__init__(inout self: Self, list: Reference[List[T], is_mutable, lifetime, 0])
Construct a Span from a List.
Args:
- list (
Reference[List[T], is_mutable, lifetime, 0]
): The list to which the span refers.
__init__[size: Int](inout self: Self, array: Reference[InlineArray[T, size], is_mutable, lifetime, 0])
Construct a Span from an InlineArray.
Parameters:
- size (
Int
): The size of the InlineArray.
Args:
- array (
Reference[InlineArray[T, size], is_mutable, lifetime, 0]
): The array to which the span refers.
__getitem__
__getitem__(self: Self, idx: Int) -> ref [lifetime] T
Get a reference to an element in the span.
Args:
- idx (
Int
): The index of the value to return.
Returns:
An element reference.
__getitem__(self: Self, slc: Slice) -> Self
Get a new span from a slice of the current span.
Args:
- slc (
Slice
): The slice specifying the range of the new subslice.
Returns:
A new span that points to the same data as the current span.
unsafe_ptr
unsafe_ptr(self: Self) -> UnsafePointer[T, 0]
Gets a pointer to the first element of this slice.
Returns:
A pointer pointing at the first element of this slice.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?