#set #heap #vec #heap-allocated

dense_bitset

A variably sized, heap allocated, dense bitset implemented using no unsafe code

2 releases

0.1.1 Dec 19, 2019
0.1.0 Dec 16, 2019

#2610 in Data structures

MIT license

23KB
393 lines

Dense Bitset

A dense bitset implemented in rust using only safe code.

Examples

use dense_bitset::BitSet;

let mut set = BitSet::new();

set.insert(7);
set.set(4, true);
set.flip(5);

assert_eq!(set, [7, 4, 5].iter().collect());

set.remove(7);
set.flip(4);
set.set(5, false);

assert!(set.is_empty());

let a: BitSet = [2, 5, 12, 17].iter().collect();
let b: BitSet = [2, 12].iter().collect();

assert!(!a.is_disjoint(&b));
assert!(b.is_subset(&a));
assert!(a.is_superset(&b));

lib.rs:

A dense bitset implementation using only safe code.

Examples

use dense_bitset::BitSet;

let mut set = BitSet::new();

set.insert(5);
set.insert(42);
set.insert(7);
assert!(set.get(5));

assert_eq!(set, [5, 7, 42].iter().collect());

No runtime deps