zena:fixed-array

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

Classes

FixedArray

zena
final extension class FixedArray<T> with IterableUtils<T> implements MutableArray<T>, Iterable<T>
Implements MutableArray<T>, Iterable<T>
Mixes in IterableUtils<T>
Constructors
zena
new(length: i32, value: T)
#
Properties
zena
length: i32
#
Methods
zena
static from<A>(seq: Array<A>): FixedArray<A>
#
zena
map<U>(f: (item: T, index: i32, seq: FixedArray<T>) => U): FixedArray<U>
#
zena
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
#
zena
reverse(): FixedArray<T>
#
zena
slice(start: i32, end: i32): FixedArray<T>
#

Returns a shallow copy of a portion of the array. The start index is inclusive, the end index is exclusive. Negative indices are not supported.

Operators
zena
operator [](index: i32): T
#
zena
operator []=(index: i32, value: T): void
#
zena
operator [](r: BoundedRange): FixedArray<T>
#

Returns a slice of the array using BoundedRange (a..b).

zena
operator [](r: FromRange): FixedArray<T>
#

Returns a slice from start to end of array (a..).

zena
operator [](r: ToRange): FixedArray<T>
#

Returns a slice from beginning to end index (..b).

zena
operator [](_r: FullRange): FixedArray<T>
#

Returns a copy of the entire array (..).

5 inherited members
From Iterable
zena
contains(value: T): boolean
#

Returns true if the collection contains the specified value.

zena
all(predicate: (item: T) => boolean): boolean
#

Returns true if all elements match the given predicate. Returns true if the collection is empty.

zena
some(predicate: (item: T) => boolean): boolean
#

Returns true if at least one element matches the given predicate. Returns false if the collection is empty.

zena
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
#

Finds the first element that matches the predicate. Returns an inline tuple (true, item) if found, or (false, _) if not.

zena
filter(predicate: (item: T) => boolean): Iterable<T>
#

Returns a new iterable containing only the elements that match the predicate.

Functions

fixed

zena
function fixed<T>(items: FixedArray<T>): FixedArray<T>

Its argument, unchanged: fixed([1, 2, 3]).

The parameter supplies the mutable context, so a literal argument builds directly as a FixedArray — a mutable literal in expression position, where no annotation can say so. The identity body inlines away, leaving the bare allocation.