#bitset #stores #data #elements #store #stack-size

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

#1521 in Data structures

Download history 15194/week @ 2023-11-21 27027/week @ 2023-11-28 41008/week @ 2023-12-05 28352/week @ 2023-12-12 18242/week @ 2023-12-19 5783/week @ 2023-12-26 24506/week @ 2024-01-02 26613/week @ 2024-01-09 33368/week @ 2024-01-16 29867/week @ 2024-01-23 26600/week @ 2024-01-30 32565/week @ 2024-02-06 26719/week @ 2024-02-13 38487/week @ 2024-02-20 40213/week @ 2024-02-27 32467/week @ 2024-03-05

145,197 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