Skip to content
FutureBlitz

    Install

    Import std.collections.bit_set

    BitSet

    std.collections.bit_set

    class

    @DebugElements Public Class BitSet Implements Iterable<Int>, Cloneable, Defaultable, Hashable

    A set of Ints that aren't negative, a bit each, for many small numbers in little space.

    Examples

    Local set = BitSet()
    set.Add(3)
    set.Add(64)
    Expect(!set.Add(3))
    Expect(set.Count == 2)
    Expect(set.Contains(64) && !set.Contains(4))
    Expect(set.ToArray() == [3, 64])

    std/collections/bit_set.fb, line 23

    • Public Property Count: Int property #

      How many values it holds.

    • @PanicsAtCaller Public Method Add(value: Int): Bool method #

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

    • @PanicsAtCaller Public Method AddAll(values: Iterable<Int>) method #

      Adds each of the values, which are all read first. A negative value panics.

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

      Removes the value, and tells whether it was there.

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

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

    • Public Method First(): Int? method #

      The smallest value, or Null when there's none.

    • Public Method Last(): Int? method #

      The largest value, or Null when there's none.

    • Public Method Union(other: BitSet): BitSet method #

      A new BitSet of the values in either.

    • Public Method Intersect(other: BitSet): BitSet method #

      A new BitSet of the values in both.

      Examples

      Local a = BitSet()
      a.AddAll([1, 2, 3])
      Local b = BitSet()
      b.AddAll([2, 3, 4])
      Expect(a.Intersect(b).ToArray() == [2, 3])
      Expect(a.Union(b).Count == 4)
    • Public Method Difference(other: BitSet): BitSet method #

      A new BitSet of this one's values that other doesn't have.

    • Public Method SymmetricDifference(other: BitSet): BitSet method #

      A new BitSet of the values in one but not the other.

    • Public Method AddAll(other: BitSet) method #

      Adds each of other's values.

    • Public Method RemoveAll(other: BitSet) method #

      Removes each of other's values.

    • Public Method KeepOnly(other: BitSet) method #

      Keeps only the values other has too.

    • Public Method IsSubsetOf(other: BitSet): Bool method #

      Whether each of its values is in other.

    • Public Method IsSupersetOf(other: BitSet): Bool method #

      Whether it has each of other's values.

    • Public Method Overlaps(other: BitSet): Bool method #

      Whether the two have a value in common.

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

      The values, smallest first, in a new array.

    • Public Static Method DefaultValue(): BitSet static method #

      A new, empty BitSet.

    • Public Method Clone(): BitSet method #

      A new BitSet with the same values.

    • Operator ==(a: BitSet, b: BitSet): Bool operator #

      Two BitSets are equal when they have the same values.

    • Public Method Hash(): UInt64 method #

      A hash of its values, which BitSets that are equal share.

    • Public Method Iterate(): BitSetIterator method #

      The values, smallest first. Adding or removing one while going over them panics.

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