Import std.collections.bit_set
std.collections.bit_set
A set of Ints from 0 up, a bit each.
BitSet: a Set of Ints from 0 up, a bit each in an array of words, which grows to hold the largest. Adding, removing, and finding a value take the same time however many there are, and the Set algebra goes a word at a time.
std/collections/bit_set.fb
Types
BitSet
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
-
How many values it holds.
-
Adds the
value, and tells whether it's new. A negativevaluepanics. -
Adds each of the
values, which are all read first. A negative value panics. -
Removes the
value, and tells whether it was there. -
Whether it holds
value. -
Takes every value out.
-
The smallest value, or Null when there's none.
-
The largest value, or Null when there's none.
-
A new BitSet of the values in either.
-
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) -
A new BitSet of this one's values that
otherdoesn't have. -
A new BitSet of the values in one but not the
other. -
Adds each of
other's values. -
Removes each of
other's values. -
Keeps only the values
otherhas too. -
Whether each of its values is in
other. -
Whether it has each of
other's values. -
Whether the two have a value in common.
-
The values, smallest first, in a new array.
-
A new, empty BitSet.
-
A new BitSet with the same values.
-
Two BitSets are equal when they have the same values.
-
A hash of its values, which BitSets that are equal share.
-
The values, smallest first. Adding or removing one while going over them panics.
BitSetIterator
struct
Public Struct BitSetIterator Implements Iterator<Int>
The values of a BitSet, smallest first, which a For loop goes over.
std/collections/bit_set.fb, line 266
-
The next value, the least first, or Null after the largest. Panics when the BitSet changed since the loop began.
Extends
BitSet
extend
Extend BitSet Implements Printable
Shows a BitSet in a string, as its ToString writes it.
std/collections/bit_set.fb, line 294
-
Its values, the least first, as "{1, 5, 64}".
Report an issue with this page or with FutureBlitz on GitHub.