Mojo struct
VariadicListMem
struct VariadicListMem[elt_is_mutable: Bool, //, element_type: AnyType, origin: Origin[elt_is_mutable.value]]
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 mut 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
,
UnknownDestructibility
Methods
__init__
@implicit
__init__(out self, mut value: Variadic[mut ref [origin] element_type])
Constructs a VariadicList from a variadic argument type.
Args:
- value (
Variadic[mut ref [origin] element_type]
): The variadic argument to construct the list with.
@implicit
__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, *[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, self]
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!