Array
sealed class Array<T>import Array from Wax;Fixed-length, dense storage, created with new T[n] or an array initializer. All readable slots
contain values; reference elements without a default require initialization. Indexing and slices
are bounds-checked. Spans borrow storage, while copied reference elements continue to refer to
the same objects. Sorting and filling mutate the array.
Inherits from object. Follow these links for inherited members.
Members
sizefield
public native readonly int32 sizeThe number of live elements; valid element indices are [0, size). Capacity is not part of
the readable range.
thisindexer-getter
public get this(int32 index) : TReads or replaces a live element at a zero-based index. An index outside [0, size) panics.
Replacing an element does not change the collection size.
thisindexer-setter
public set this(int32 index, T value) : voidReads or replaces a live element at a zero-based index. An index outside [0, size) panics.
Replacing an element does not change the collection size.
ToSpanmethod
public fn ToSpan() : Span<T>Borrows a mutable view of the current live elements without copying. The view has a fixed length. Writes affect shared storage; it does not follow a later collection reallocation.
ToWriteOnlySpanmethod
public fn ToWriteOnlySpan() : WriteOnlySpan<T>Borrows a write-only view of the live element range without copying. Writes change the backing storage; the view itself cannot read values.
ToReadOnlySpanmethod
public fn ToReadOnlySpan() : ReadOnlySpan<T>Borrows the current live elements without copying or permitting writes through this view. Other aliases can still mutate the storage; the view does not follow a later reallocation.
Emptygetter
public static get Empty() : T[]Returns the shared zero-length array of this element type.
Slicemethod
public fn Slice(int32 start, int32 len) : Span<T>Borrows a mutable window [start, start + len). Negative arguments or a range outside the
live elements panic. An empty slice at size is valid.
Sortmethod
public fn Sort() : void where T is ComparableSorts elements ascending in place using CompareTo. Equal elements have unspecified
relative order; use SortStable when order among ties matters. No scratch array is
allocated.
SortBymethod
public fn SortBy(fn<(T,T) : int32> compare) : voidSorts in place using a comparator returning a negative value, zero, or a positive value for less, equal, or greater. The comparator must provide a consistent ordering. Equal elements may be reordered.
SortStablemethod
public fn SortStable() : void where T is ComparableSorts ascending in place with CompareTo, preserving the original order of equal elements.
Larger inputs allocate a scratch array.
SortStableBymethod
public fn SortStableBy(fn<(T,T) : int32> compare) : voidSorts in place with a consistent negative/zero/positive comparator, preserving the original order of equal elements. Larger inputs allocate a scratch array.
Containsmethod
public fn Contains(T item) : bool where T is EquatableTests whether any element matches using Equals. Returns false for an empty view.
IndexOfmethod
public fn IndexOf(T item) : int32 where T is EquatableReturns the first matching element index using Equals, or -1 when absent, including an
empty view.
LastIndexOfmethod
public fn LastIndexOf(T item) : int32 where T is EquatableReturns the last matching element index using Equals, or -1 when absent, including an
empty view.
Fillmethod
public fn Fill(T value) : voidAssigns value to every element of the backing window. An empty view does nothing.
Reference elements all receive the same reference.
FillRangemethod
public fn FillRange(T value, int32 start, int32 count) : voidFills [start, start + count) with value. Both endpoints must lie in [0, size]; invalid
endpoints panic before any write. An empty or reversed range whose endpoints are valid
performs no writes.
CopyTomethod
public fn CopyTo(Span<T> dest) : voidCopies the first min(size, dest.length) elements into dest, safely handling overlapping
views. A shorter destination truncates the copy without a panic; any remaining destination
elements are unchanged. An empty source or destination does nothing. Reference elements copy
their references, not the referenced objects.
Reversemethod
public fn Reverse() : voidReverses element order in the backing window. Empty and one-element views are unchanged. Overlapping views observe the reordered elements.
BinarySearchmethod
public fn BinarySearch(T item) : int32 where T is ComparableSearches a view already sorted ascending under CompareTo. Returns a matching element
index; when duplicates exist, the chosen match is unspecified. If absent, returns
~insertionIndex; apply ~ again to recover the insertion position. An empty view returns
-1 (~0).