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

#27 in Data structures

Download history 604748/week @ 2023-12-11 448932/week @ 2023-12-18 264125/week @ 2023-12-25 446878/week @ 2024-01-01 537888/week @ 2024-01-08 553598/week @ 2024-01-15 541515/week @ 2024-01-22 573554/week @ 2024-01-29 553921/week @ 2024-02-05 543816/week @ 2024-02-12 582430/week @ 2024-02-19 598949/week @ 2024-02-26 607932/week @ 2024-03-04 534413/week @ 2024-03-11 579444/week @ 2024-03-18 590966/week @ 2024-03-25

2,342,862 downloads per month
Used in 4,419 crates (94 directly)

MIT/Apache

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.

Build Status


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