envzn
0.8 · beta · not released

Library / Collections / Sequences / NativeArray

CLASS

NativeArray

NativeArray — what T[] and T[N+] are.

Constructors 2

INIT()

CREATE(): room for four elements.

INIT(int64 n)

CREATE(n): room for n elements, with length 0.

Methods 15

METHOD length() RETURNS int64
reads

The live elements.

METHOD capacity() RETURNS int64
reads

The allocated slots.

MODIFY METHOD reserve(int64 n) RETURNS void
modifies

Room for at least n elements, keeping the 79% growth trigger: the incremental hint a caller appending in a loop gives.

MODIFY METHOD reserveExact(int64 n) RETURNS boolean
modifies

Room for exactly the n elements the caller names: no growth heuristic. FALSE, with the array unchanged, when the block cannot be allocated.

MODIFY METHOD clear() RETURNS void
modifies

Drop every element; length becomes 0 and the block is kept.

METHOD __op_index__(int64 i) RETURNS MUTABLE REFERENCE T
reads

a[i] — a checked read: the cell, borrowed.

MODIFY METHOD __op_set_index__(int64 i, T value) RETURNS void
modifies

a[i] = v — the high-water write (I.J.i): grows to i + 1 if needed, then the value moves in. A gap it opens reads as EMPTY / zero, or a value class's default (E1159).

MODIFY METHOD append(T value) RETURNS void
modifies

The value moves in at the end: the write []= makes at index .length, where there is no old value to take out.

MODIFY METHOD appendRange(REFERENCE NativeArray[T] other) RETURNS void
modifies

Append a copy of every element of other, which may be this array.

MODIFY METHOD remove(int64 i) RETURNS T
modifies

Move element i out, sliding the tail down one slot.

MODIFY METHOD swap(int64 i, int64 j) RETURNS void
modifies

Exchange elements i and j.

METHOD copyTo(MUTABLE REFERENCE NativeArray[T] dst, int64 n) RETURNS void
reads

dst becomes a copy of this array's first n elements; its old ones are dropped.

MODIFY METHOD convertFrom(REFERENCE U[] src, int64 n) RETURNS void
modifies
METHOD equals(REFERENCE NativeArray[T] other) RETURNS boolean
reads

The same length and every element equal.

METHOD clone() RETURNS NativeArray[T]
reads

A deep copy: each element's own copy.