A fast, immutable BitSet.
A Bitset is a specialized type of set that tracks the Int
values it contains: for each integer value, a BitSet uses
a single bit to track whether the value is present (1) or absent (0). Bitsets are often sparse, since "missing" bits
can be assumed to be zero.
Unlike scala's default immutable this BitSet does not do a full copy on each added value.
Internally the implementation is a tree. Each leaf uses an Array[Long] value to hold up to 2048 bits, and each branch uses an Array[BitSet] to hold up to 32 subtrees (null subtrees are treated as empty).
Bitset treats the values it stores as 32-bit unsigned values, which is relevant to the internal addressing methods as
well as the order used by iterator
.
The benchmarks suggest this bitset is MUCH faster than Scala's built-in bitset for cases where you may need many modifications and merges, (for example in a BloomFilter).
Attributes
- Companion:
- object
- Source:
- BitSet.scala
- Graph
- Supertypes
- Self type