Skip to content
FutureBlitz

    Install

    Import std.collections.immutable

    ImmutableArray

    std.collections.immutable

    struct

    @DebugElements Public Struct ImmutableArray<T: Sendable> Implements Iterable<T>, Defaultable, Sendable

    An array that never changes: each change gives a new one, which shares what it can with the old, so threads can share it.

    Examples

    Local first = ImmutableArray<Int>().AddAll([1, 2, 3])
    Local second = first.Set(0, 10).Add(4)
    Expect(first.ToArray() == [1, 2, 3])
    Expect(second.ToArray() == [10, 2, 3, 4])

    std/collections/immutable.fb, line 41

    • Public New() constructor #

      An empty one.

    • Public Static Method From(values: Iterable<T>): ImmutableArray<T> static method #

      One with the values, in order, all read first.

    • Public Property Count: Int property #

      How many values it holds.

    • @PanicsAtCaller Operator [](index: Int): T operator #

      The value at index, which panics outside it.

    • @PanicsAtCaller Public Method Set(index: Int, value: T): ImmutableArray<T> method #

      A copy with value at index in place of what's there.

    • Public Method Add(value: T): ImmutableArray<T> method #

      A copy with value added at the end.

    • Public Method AddAll(values: Iterable<T>): ImmutableArray<T> method #

      A copy with each of the values added at the end, in order, all read first.

    • @PanicsAtCaller Public Method Insert(index: Int, value: T): ImmutableArray<T> method #

      A copy with value at index, moving what's there and after it along, where index is from 0 to Count.

    • @PanicsAtCaller Public Method RemoveAt(index: Int): ImmutableArray<T> method #

      A copy without the value at index.

    • Public Method Contains(value: T): Bool method #

      Whether it holds value.

    • Public Method ToArray(): T[] method #

      The values, in order, in a new array.

    • Public Static Method DefaultValue(): ImmutableArray<T> static method #

      An empty one.

    • Public Method Iterate(): ImmutableArrayIterator<T> method #

      The values, in order.

    Report an issue with this page or with FutureBlitz on GitHub.