Skip to content
FutureBlitz

    Install

    Import std.collections.immutable

    std.collections.immutable

    ImmutableArray<T>, ImmutableMap<K, V>, and ImmutableSet<T>: collections that never change, so any thread can read one. A change gives a new collection, which shares all of the old one's nodes but the ones on the way down to what changed, in a balanced tree, about log(Count) of them. Their values are Sendable, as the collections are.

    std/collections/immutable.fb

    Types

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

    std/collections/immutable.fb, line 30

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

    ImmutableArrayIterator struct

    Public Struct ImmutableArrayIterator<T: Sendable> Implements Iterator<T>

    An ImmutableArray's values in order: the nodes on the way down to the next one.

    std/collections/immutable.fb, line 246

    ImmutableMap struct

    @DebugEntries Public Struct ImmutableMap<K, V> Implements Iterable<(K, V)>, Defaultable, Sendable

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

    std/collections/immutable.fb, line 342

    • Public New() constructor #

      An empty one.

    • Public Static Method From(entries: Iterable<(K, V)>): ImmutableMap<K, V> static method #

      One with the entries, all read first, a later entry's value for a key taking the place of an earlier one's.

    • Public Property Count: Int property #

      How many entries it holds.

    • Public Method Get(key: K): V? method #

      The key's value, or Null when it isn't there.

    • Public Method Get(key: K, fallback: V): V method #

      The key's value, or fallback when it isn't there.

    • @PanicsAtCaller Operator [](key: K): V operator #

      The key's value. A key that isn't there panics.

    • Public Method Contains(key: K): Bool method #

      Whether key has an entry.

    • Public Method Add(key: K, value: V): ImmutableMap<K, V> method #

      A copy with the key's value, which takes the place of the one it has.

    • Public Method AddAll(entries: Iterable<(K, V)>): ImmutableMap<K, V> method #

      A copy with each of the entries added in turn, as Add adds one, all read first.

    • Public Method Remove(key: K): ImmutableMap<K, V> method #

      A copy without the key's entry, or the same one when it has none.

    • Public Method Keys(): K[] method #

      The keys, in the order the entries go in.

    • Public Method Values(): V[] method #

      The values, in their keys' order.

    • Public Method ToMap(): Map<K, V> method #

      A new Map with the same entries, in the same order.

    • Public Static Method DefaultValue(): ImmutableMap<K, V> static method #

      An empty one.

    • Public Method Iterate(): ImmutableMapIterator<K, V> method #

      Each key and its value, for 'For key, value In map', by their keys' hashes, and keys of one hash in the order they were added.

    ImmutableMapIterator struct

    Public Struct ImmutableMapIterator<K, V> Implements Iterator<(K, V)>

    An ImmutableMap's entries: the nodes on the way down to the next one, and the entry it's at.

    std/collections/immutable.fb, line 627

    ImmutableSet struct

    @DebugElements Public Struct ImmutableSet<T> Implements Iterable<T>, Defaultable, Sendable, Hashable

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

    std/collections/immutable.fb, line 702

    • Public New() constructor #

      An empty one.

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

      One with the values, all read first.

    • Public Property Count: Int property #

      How many values it holds.

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

      Whether it holds value.

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

      A copy with the value, or the same one when it has it.

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

      A copy with each of the values added, all read first.

    • Public Method Remove(value: T): ImmutableSet<T> method #

      A copy without the value, or the same one when it hasn't got it.

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

      The values, in a new array, in the order they go in.

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

      An empty one.

    • Operator ==(a: ImmutableSet<T>, b: ImmutableSet<T>): Bool operator #

      Two ImmutableSets are equal when they have the same values.

    • Public Method Hash(): UInt64 method #

      Equal ImmutableSets have equal hashes, whatever order their values go in.

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

      The values, by their hashes, and values of one hash in the order they were added.

    ImmutableSetIterator struct

    Public Struct ImmutableSetIterator<T> Implements Iterator<T>

    The values of an ImmutableSet, which For ... In goes over.

    std/collections/immutable.fb, line 771

    Extends

    ImmutableArray extend

    Extend ImmutableArray<T> Implements Equatable

    No doc comment.

    std/collections/immutable.fb, line 268

    ImmutableArray extend

    Extend ImmutableArray<T> Implements Hashable

    No doc comment.

    std/collections/immutable.fb, line 282

    ImmutableArray extend

    Extend ImmutableArray<T> Implements Printable

    No doc comment.

    std/collections/immutable.fb, line 295

    ImmutableMap extend

    Extend ImmutableMap<K, V> Implements Equatable

    No doc comment.

    std/collections/immutable.fb, line 660

    ImmutableMap extend

    Extend ImmutableMap<K, V> Implements Hashable

    No doc comment.

    std/collections/immutable.fb, line 674

    ImmutableMap extend

    Extend ImmutableMap<K, V> Implements Printable

    No doc comment.

    std/collections/immutable.fb, line 687

    ImmutableSet extend

    Extend ImmutableSet<T> Implements Printable

    No doc comment.

    std/collections/immutable.fb, line 785

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