#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

#1839 in Data structures

Download history 32844/week @ 2024-03-14 34873/week @ 2024-03-21 45038/week @ 2024-03-28 45301/week @ 2024-04-04 53510/week @ 2024-04-11 50977/week @ 2024-04-18 49538/week @ 2024-04-25 53993/week @ 2024-05-02 53635/week @ 2024-05-09 56997/week @ 2024-05-16 63806/week @ 2024-05-23 74289/week @ 2024-05-30 73120/week @ 2024-06-06 67965/week @ 2024-06-13 58641/week @ 2024-06-20 69542/week @ 2024-06-27

288,907 downloads per month
Used in 5 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.

#
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<_>>());

No runtime deps