8 releases (4 breaking)
Uses old Rust 2015
0.5.3 | Jul 23, 2022 |
---|---|
0.5.2 | May 6, 2020 |
0.5.1 | Mar 21, 2019 |
0.5.0 | Apr 23, 2018 |
0.1.0 | Jun 3, 2015 |
#17 in Data structures
2,334,603 downloads per month
Used in 4,355 crates
(94 directly)
48KB
920 lines
WARNING: THIS PROJECT IS IN MAINTENANCE MODE, DUE TO INSUFFICIENT MAINTAINER RESOURCES
It works fine, but will generally no longer be improved.
We are currently only accepting changes which:
- keep this compiling with the latest versions of Rust or its dependencies.
- have minimal review requirements, such as documentation changes (so not totally new APIs).
A Set of bits.
Documentation is available at https://contain-rs.github.io/bit-set/bit_set.
lib.rs
:
An implementation of a set using a bit vector as an underlying representation for holding unsigned numerical elements.
It should also be noted that the amount of storage necessary for holding a
set of objects is proportional to the maximum of the objects when viewed
as a usize
.
Examples
use bit_set::BitSet;
// It's a regular set
let mut s = BitSet::new();
s.insert(0);
s.insert(3);
s.insert(7);
s.remove(7);
if !s.contains(7) {
println!("There is no 7");
}
// Can initialize from a `BitVec`
let other = BitSet::from_bytes(&[0b11010000]);
s.union_with(&other);
// Print 0, 1, 3 in some order
for x in s.iter() {
println!("{}", x);
}
// Can convert back to a `BitVec`
let bv = s.into_bit_vec();
assert!(bv[3]);
Dependencies
~79KB