Skip to main content

Module bitvec

Module bitvec 

Source
Expand description

Stores booleans as individual bits - 8x smaller than Vec<bool>.

Use this when you’re tracking lots of boolean flags (like “visited” markers in graph traversals, or null bitmaps). Backed by Vec<u64> so bitwise operations like AND/OR/XOR stay cache-friendly.

§Example

let bools = vec![true, false, true, true, false, false, true, false];
let bitvec = BitVector::from_bools(&bools);
// Stored as: 0b01001101 (1 byte instead of 8)

assert_eq!(bitvec.get(0), Some(true));
assert_eq!(bitvec.get(1), Some(false));
assert_eq!(bitvec.count_ones(), 4);

Structs§

BitVector
Stores booleans as individual bits - 8x smaller than Vec<bool>.