Mojo struct
VariadicListMem
A utility class to access variadic function arguments of memory-only types that may have ownership. It exposes references to the elements in a way that can be enumerated. Each element may be accessed with elt[]
.
Parameters
- elt_is_mutable (
Bool
): True if the elements of the list are mutable for an inout or owned argument. - element_type (
AnyType
): The type of the elements in the list. - origin (
Origin[elt_is_mutable.value]
): The reference origin of the underlying elements.
Aliases
reference_type = Pointer[element_type, origin]
:
Fields
- value (
Variadic[ref [origin] element_type]
): The underlying storage, a variadic list of references to elements of the given type.
Implemented traits
AnyType
,
Sized
Methods
__init__
__init__(out self, inout value: Variadic[inout ref [origin] element_type])
Constructs a VariadicList from a variadic argument type.
Args:
- value (
Variadic[inout ref [origin] element_type]
): The variadic argument to construct the list with.
__init__(out self, owned value: Variadic[owned ref [origin] element_type])
Constructs a VariadicList from a variadic argument type.
Args:
- value (
Variadic[owned ref [origin] element_type]
): The variadic argument to construct the list with.
__moveinit__
__moveinit__(out self, owned existing: Self)
Moves constructor.
Args:
- existing (
Self
): The existing VariadicListMem.
__del__
__del__(owned self)
Destructor that releases elements if owned.
__getitem__
__getitem__(self, idx: Int) -> ref [{origin, (mutcast imm *[0,0])}] element_type
Gets a single element on the variadic list.
Args:
- idx (
Int
): The index of the element to access on the list.
Returns:
A low-level pointer to the element on the list corresponding to the given index.
__len__
__len__(self) -> Int
Gets the size of the list.
Returns:
The number of elements on the variadic list.
__iter__
__iter__(self) -> _VariadicListMemIter[element_type, origin, *[0,0]]
Iterate over the list.
Returns:
An iterator to the start of the list.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!