2 releases

Uses old Rust 2015

0.4.1 Apr 12, 2017
0.4.0 Jul 20, 2016

#9 in #bit-array


Used in 4 crates (via keeshond)

MIT/Apache

50KB
873 lines

A Set of bits backed by bit-array

Documentation is available at https://ambaxter.github.io/bitarray_set/bitarray_set/.


lib.rs:

An implementation of a set using a bit array 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

extern crate typenum;
use typenum::{Unsigned, U8};
use bitarray_set::BitArraySet;

// It's a regular set
let mut s = BitArraySet::<u32, U8>::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 `BitArray`
let other = BitArraySet::<u32, U8>::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 `BitArray`
let bv = s.into_bit_array();
assert!(bv[3]);

Dependencies

~435KB