7 releases (4 breaking)

Uses old Rust 2015

0.5.2 May 6, 2020
0.5.1 Mar 21, 2019
0.5.0 Apr 23, 2018
0.4.0 Mar 11, 2016
0.1.0 Jun 3, 2015

#2 in #bitset

Download history 28187/week @ 2020-12-25 46921/week @ 2021-01-01 55963/week @ 2021-01-08 52306/week @ 2021-01-15 53371/week @ 2021-01-22 61025/week @ 2021-01-29 59995/week @ 2021-02-05 57441/week @ 2021-02-12 67770/week @ 2021-02-19 63779/week @ 2021-02-26 67636/week @ 2021-03-05 68230/week @ 2021-03-12 73648/week @ 2021-03-19 81642/week @ 2021-03-26 69020/week @ 2021-04-02 63581/week @ 2021-04-09

225,851 downloads per month
Used in 1,061 crates (65 directly)

MIT/Apache

43KB
763 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.

Build Status crates.io


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

~80KB