Array#
Provides mutable array types that store their elements on the heap rather than in registers or the stack.
- type
Array -
An opaque type of supertype
Struct.- inline
__==( ... ) - fn
__@( self index ) -
Implements support for the
@operator. Returns a view reference to the element atindexof arrayself. - inline
__as( cls T ) -
Implements support for the
asoperator. Arrays can be cast toGenerator, or directly passed tofor. - fn
__copy( self ) -
Implements support for the
copyoperation. - inline
__countof( self ) -
Implements support for the
countofoperator. Returns the current number of elements stored inselfas a value ofusizetype. - fn
__drop( self ) -
Implements support for freeing the array's memory when it goes out of scope.
- inline
__imply( cls T ) -
Implements support for pointer casts, to pass the array to C functions for example.
- inline
__typecall( cls element-type capacity ) -
Construct a mutable array type of
element-typewith a variable or fixed maximum capacity.If
capacityis defined, then it specifies the maximum number of array elements permitted. If it is undefined, then an initial capacity of 16 elements is assumed, which is doubled whenever it is exceeded, allowing for an indefinite number of elements. - fn
append( self value ) -
Append
valueas an element to the arrayselfand return a reference to the new element. When thearrayis ofGrowingArraytype, this operation will transparently resize the array's storage. - fn
clear( self ) -
Clear the array and reset its element count to zero. This will drop all elements that have been previously contained by the array.
- inline
emplace-append( self args... ) -
Construct a new element with arguments
args...directly in a newly assigned slot of arrayself. When thearrayis ofGrowingArraytype, this operation will transparently resize the array's storage. - inline
emplace-append-many( self size args... ) -
Construct a new element with arguments
args...directly in a newly assigned slot of arrayself. When thearrayis ofGrowingArraytype, this operation will transparently resize the array's storage. - type
insert -
Insert
valueatindexinto the arrayselfand return a reference to the new element. When thearrayis ofGrowingArraytype, this operation will transparently resize the array's storage. This operation offsets the index of each following element by 1. If index is omitted,insertoperates likeappend. - fn
last( self ) - fn
pop( self ) -
Remove element with highest index from array
selfand return it. - inline
predicated-sort( self predicate ... ) -
Sort elements of array
selffrom smallest to largest, either using the<operator supplied by the element type, or by using the predicate supplied by the callablepredicate, which takes two arguments and is expected to return true if the first argument is smaller than the second one. - fn
remove( self index ) -
Remove element at index from array
selfand return it. This operation offsets the index of each following element by -1. - fn
resize( self count args... ) -
Resize the array to the specified count. Items are appended or removed to meet the desired count.
- inline
sort( self key ... ) -
Sort elements of array
selffrom smallest to largest, either using the<operator supplied by the element type, or by using the key supplied by the callablekey, which is expected to return a comparable value for each element value supplied. - fn
swap( self a b ) -
Safely swap the contents of two indices.
- inline
- type
FixedArray -
An opaque type of supertype
Array.- fn
__repr( self ) -
Implements support for the
reproperation. - inline
__typecall( cls opts... ) - inline
capacity( self ) -
Returns the maximum capacity of array
self, which is fixed. - fn
reserve( self count ) -
Internally used by the type. Ensures that array
selfcan hold at leastcountelements. A fixed array will raise an assertion when its capacity has been exceeded.
- fn
- type
GrowingArray -
An opaque type of supertype
Array.- fn
__repr( self ) -
Implements support for the
reproperation. - inline
__typecall( cls opts... ) - inline
capacity( self ) -
Returns the current maximum capacity of array
self. - fn
reserve( self count ) -
Internally used by the type. Ensures that array
selfcan hold at leastcountelements. A growing array will always attempt to comply.
- fn