zena:growable-array
import {…} from 'zena:growable-array';
Classes
GrowableArray
final class GrowableArray<T> implements MutableArray<T>, Iterable<T>
new(capacity: i32 = 8, adopting: FixedArray<T> | null = null)
adopting, when given, becomes the backing storage, full: length
starts at its length, no copy is made, and capacity is ignored.
The caller must hand the buffer over — writes through either alias
would be visible through the other. from copies; this adopts.
(A constructor parameter rather than a static so it works from
generic bodies — see the issue linked from growable below.)
length: i32 { get; }
static from<A>(seq: Array<A>): GrowableArray<A>
push(value: T): void
pop(): T
map<U>(f: (item: T, index: i32, seq: GrowableArray<T>) => U): GrowableArray<U>
contains(value: T): boolean
all(predicate: (item: T) => boolean): boolean
some(predicate: (item: T) => boolean): boolean
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
filter(predicate: (item: T) => boolean): Iterable<T>
Functions
growable
function growable<T>(items: FixedArray<T>): GrowableArray<T>
A growable array from an array literal: growable([1, 2, 3]).
The parameter supplies the mutable context, so the literal builds
directly as a FixedArray and is adopted as the backing storage —
no copy, unlike GrowableArray.from over an interface-typed source.
Until literal decorators land, this is the concise spelling for a
growable array with initial contents.