Skip to content
FutureBlitz

    Install

    Import std.collections.set

    std.collections.set

    Set<T>: values without repeats, in the order they were added, which a Map holds as its keys.

    std/collections/set.fb

    Types

    Set class

    @DebugElements Public Class Set<T: Hashable> Implements Iterable<T>, Cloneable, Defaultable, Hashable

    A hash set: values, each held once, in the order they were added.

    Examples

    Local seen = Set<String>()
    Expect(seen.Add("cave"))
    Expect(!seen.Add("cave"))
    Expect(seen.Contains("cave") && seen.Count == 1)

    std/collections/set.fb, line 17

    • Public New() constructor #

      A new, empty Set.

    • Public Property Count: Int property #

      How many values it holds.

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

      Adds the value, and tells whether it's new.

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

      Removes the value, and tells whether it was there. The others keep their order.

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

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

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

      Adds each of the values that isn't there yet, in their order.

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

      Removes each of the values that's there.

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

      Removes each value that isn't among the values.

    • Public Method Union(values: Iterable<T>): Set<T> method #

      A new Set of this one's values, then the other values that aren't among them.

    • Public Method Intersect(values: Iterable<T>): Set<T> method #

      A new Set of this one's values that are among the values too.

    • Public Method Difference(values: Iterable<T>): Set<T> method #

      A new Set of this one's values that aren't among the values.

    • Public Method SymmetricDifference(values: Iterable<T>): Set<T> method #

      A new Set of the values that are in this one or among the values, but not both: this one's first, then the others.

    • Public Method IsSubsetOf(values: Iterable<T>): Bool method #

      Whether each of this one's values is among the values.

    • Public Method IsSupersetOf(values: Iterable<T>): Bool method #

      Whether each of the values is in this one.

    • Public Method Overlaps(values: Iterable<T>): Bool method #

      Whether any of the values is in this one.

    • Public Method SetEquals(values: Iterable<T>): Bool method #

      Whether the values, without their repeats, are this one's, in any order.

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

      The values, in order, in a new array.

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

      A new, empty Set.

    • Public Method Clone(): Set<T> method #

      A new Set with the same values, in the same order.

    • @PanicsAtCaller Public Method Filter(keep: Func(T): Bool): Set<T> method #

      A new Set of the values that keep says to keep.

    • @PanicsAtCaller Public Method Find(test: Func(T): Bool): T? method #

      The first value that test says is the one, or Null.

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

      Two Sets are equal when they have the same values, in any order.

    • Public Method Hash(): UInt64 method #

      A Set's hash, the same for equal Sets: its values', added up, so their order doesn't count.

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

      The values, in the order they were added. Adding or removing one while going over them panics.

    SetIterator struct

    Public Struct SetIterator<T: Hashable> Implements Iterator<T>

    The values of a Set, in order, which For ... In goes over.

    std/collections/set.fb, line 186

    Extends

    Set extend

    Extend Set<T> Implements Printable

    No doc comment.

    std/collections/set.fb, line 198

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