Skip to content
FutureBlitz

    Install

    Import std.collections.immutable

    ImmutableSet

    std.collections.immutable

    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.

    Examples

    Local a = ImmutableSet<Int>().AddAll([1, 2])
    Local b = a.Add(3)
    Expect(a.Count == 2 && b.Count == 3)
    Expect(b.Contains(3) && !a.Contains(3))

    std/collections/immutable.fb, line 750

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

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