zena:growable-array

zena
import {…} from 'zena:growable-array';

Classes

GrowableArray

zena
final class GrowableArray<T> implements MutableArray<T>, Iterable<T>
Implements MutableArray<T>, Iterable<T>
Constructors
zena
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.)

Properties
zena
length: i32 { get; }
#
Methods
zena
static from<A>(seq: Array<A>): GrowableArray<A>
#
zena
push(value: T): void
#
zena
pop(): T
#
zena
map<U>(f: (item: T, index: i32, seq: GrowableArray<T>) => U): GrowableArray<U>
#
zena
contains(value: T): boolean
#
zena
all(predicate: (item: T) => boolean): boolean
#
zena
some(predicate: (item: T) => boolean): boolean
#
zena
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
#
zena
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
#
zena
filter(predicate: (item: T) => boolean): Iterable<T>
#
Operators
zena
operator [](index: i32): T
#
zena
operator []=(index: i32, value: T): void
#

Functions

growable

zena
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.