@std/collections/bitset.ms#
Import each required symbol with import Name from "@std/collections/bitset.ms".
BitSet Type#
A set of small non-negative integers stored one bit each: 8 bytes per 64 candidates, with O(1) add, remove and contains.
Indexes must be 0 through 1073741823 (a 128 MiB bitmap); other indexes are rejected by add with EINVAL, so the set never grows without bound by accident.
clone() makes an independent copy.
Use it for visited marks, flags and dense id sets; use Set for sparse or non-integer members.
type BitSet {
words List[Int] = []
}BitSet.words#
Bitmap words, 64 members each, grown on demand. Internal state: use the operations, not this field.
words List[Int] = []BitSet.add#
Adds an index. A negative index, or one above 1073741823, is EINVAL and changes
nothing.
var fn add(index Int) Result[Void, Error]BitSet.clear#
Removes every member and releases the bitmap.
var fn clear() VoidBitSet.contains#
Reports whether the index is a member; out-of-range indexes are not members.
fn contains(index Int) BoolBitSet.difference#
Returns a new set of the members of this set that are not in other.
fn difference(other BitSet) BitSetBitSet.intersection#
Returns a new set of the members of both sets.
fn intersection(other BitSet) BitSetBitSet.is_disjoint_from#
Reports whether the sets share no member.
fn is_disjoint_from(other BitSet) BoolBitSet.is_empty#
Reports whether the set has no members.
fn is_empty() BoolBitSet.is_subset_of#
Reports whether every member of this set is in other.
fn is_subset_of(other BitSet) BoolBitSet.is_superset_of#
Reports whether every member of other is in this set.
fn is_superset_of(other BitSet) BoolBitSet.length#
Returns the number of members.
fn length() IntBitSet.next#
Returns the smallest member that is at least from, or null when there is no
such member.
fn next(from Int = 0) Int?BitSet.remove#
Removes an index; absent and out-of-range indexes change nothing.
var fn remove(index Int) VoidBitSet.symmetric_difference#
Returns a new set of the members of exactly one of the sets.
fn symmetric_difference(other BitSet) BitSetBitSet.union#
Returns a new set of the members of either set.
fn union(other BitSet) BitSetBitSet.values#
Returns a new list of the members in ascending order.
fn values() List[Int]