Manuscript Documentation
v2026.12.0

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

Manuscript
type BitSet {
    words List[Int] = []
}

BitSet.words#

Bitmap words, 64 members each, grown on demand. Internal state: use the operations, not this field.

Manuscript
words List[Int] = []

BitSet.add#

Adds an index. A negative index, or one above 1073741823, is EINVAL and changes nothing.

Manuscript
var fn add(index Int) Result[Void, Error]

BitSet.clear#

Removes every member and releases the bitmap.

Manuscript
var fn clear() Void

BitSet.contains#

Reports whether the index is a member; out-of-range indexes are not members.

Manuscript
fn contains(index Int) Bool

BitSet.difference#

Returns a new set of the members of this set that are not in other.

Manuscript
fn difference(other BitSet) BitSet

BitSet.intersection#

Returns a new set of the members of both sets.

Manuscript
fn intersection(other BitSet) BitSet

BitSet.is_disjoint_from#

Reports whether the sets share no member.

Manuscript
fn is_disjoint_from(other BitSet) Bool

BitSet.is_empty#

Reports whether the set has no members.

Manuscript
fn is_empty() Bool

BitSet.is_subset_of#

Reports whether every member of this set is in other.

Manuscript
fn is_subset_of(other BitSet) Bool

BitSet.is_superset_of#

Reports whether every member of other is in this set.

Manuscript
fn is_superset_of(other BitSet) Bool

BitSet.length#

Returns the number of members.

Manuscript
fn length() Int

BitSet.next#

Returns the smallest member that is at least from, or null when there is no such member.

Manuscript
fn next(from Int = 0) Int?

BitSet.remove#

Removes an index; absent and out-of-range indexes change nothing.

Manuscript
var fn remove(index Int) Void

BitSet.symmetric_difference#

Returns a new set of the members of exactly one of the sets.

Manuscript
fn symmetric_difference(other BitSet) BitSet

BitSet.union#

Returns a new set of the members of either set.

Manuscript
fn union(other BitSet) BitSet

BitSet.values#

Returns a new list of the members in ascending order.

Manuscript
fn values() List[Int]