#data-structures #bitset

id-set

A bitset implementation that stores data on the stack for small sizes

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

#832 in Algorithms

Download history 13/week @ 2021-02-21 11/week @ 2021-02-28 11/week @ 2021-03-07 11/week @ 2021-03-14 57/week @ 2021-03-21 48/week @ 2021-03-28 41/week @ 2021-04-04 37/week @ 2021-04-11 43/week @ 2021-04-18 53/week @ 2021-04-25 25/week @ 2021-05-02 14/week @ 2021-05-09 25/week @ 2021-05-16 7/week @ 2021-05-23 9/week @ 2021-05-30 37/week @ 2021-06-06

140 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

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.

# use id_set::IdSet;
#
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.

# use id_set::IdSet;
#
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<_>>());

No runtime deps