17 releases
Uses old Rust 2015
0.2.2 | Oct 3, 2017 |
---|---|
0.2.1 | Jul 4, 2017 |
0.1.13 | Jul 3, 2017 |
0.1.10 | Jun 28, 2017 |
#1839 in Data structures
288,907 downloads per month
Used in 5 crates
(3 directly)
49KB
1.5K
SLoC
A bitset implementation that stores data on the stack for small sizes.
Docs: https://docs.rs/id-set/.
lib.rs
:
IdSet
is a bitset implementation that stores data on the stack for small sizes (elements
less than 196) and keeps track of the element count.
Examples
The API is generally similar to that of the bit-set crate.
#
let mut set = IdSet::new();
set.insert(42);
assert!(set.contains(42));
set.remove(42);
assert_eq!(set.len(), 0);
Additionally the IdIter
struct provides iteration over the bits of any iterator over Block
values, allowing iteration over unions, intersections, and differences of arbitrarily many sets.
#
let a: IdSet = (0..15).collect();
let b: IdSet = (10..20).collect();
let c: IdSet = (0..5).collect();
assert_eq!(a.intersection(b.union(&c)).collect::<Vec<_>>(),
a.intersection(&b).union(a.intersection(&c)).collect::<Vec<_>>());