Module bitset
Expand description
See bitset for the system contract and examples.
Dense dirty/visibility masks with checked indices and ascending iteration.
The caller chooses an immutable bit bound with BitSet::new. All binary
operations require exactly equal BitSet::bit_len values, even when the
backing word counts match. A mismatch returns false from in-place operations
or None from lazy operations, without changing either input. Equal empty
bounds are valid. No operation resizes a set or exposes unused trailing bits.
Construction and cloning allocate storage. Updates and iterators allocate
nothing: algebra works a word at a time and iteration visits only set bits
within each word. Lazy algebra borrows both sets instead of building a third
mask. Collecting an iterator into a Vec is a caller-owned allocation.
use ferravex_engine::bitset::BitSet;
let mut dirty = BitSet::new(65);
dirty.set(0, true);
dirty.set(64, true);
let mut visible = BitSet::new(65);
visible.set(64, true);
// Process matching indices directly, without a temporary mask or buffer.
let mut updates = 0;
for index in dirty.intersection(&visible).expect("matching bit bounds") {
assert_eq!(index, 64);
updates += 1;
}
assert_eq!(updates, 1);
assert!(dirty.difference_with(&visible));
assert!(dirty.iter().eq([0]));Structsยง
- BitSet
- A fixed-bound dense set of indices in
0..self.bit_len().