Crates.io | rust-dense-bitset |
lib.rs | rust-dense-bitset |
version | 0.1.1 |
source | src |
created_at | 2019-01-14 19:10:23.690521 |
updated_at | 2019-01-16 17:07:41.751211 |
description | Efficient and compact bitsets for Rust. |
homepage | https://github.com/ovheurdrive/rust-dense-bitset |
repository | https://github.com/ovheurdrive/rust-dense-bitset |
max_upload_size | |
id | 108547 |
size | 75,122 |
Efficient and flexible self-contained bitset rust library.
The library is safe rust only, fully documented, and uses the most efficient algorithms whenever possible.
DenseBitSet
is a compact 64-bit bitset supporting in particular
set_bit
) and getting (get_bit
)&, ^, |, !, <<, >>
and rotationsDenseBitSetExtended
implements the same functionality, extending the bitset as necessary to accomodate as many bits as needed. Memory can be preallocated and new allocation is only performed if necessary.use rust_dense_bitset::{BitSet, DenseBitSetExtended};
let mut bs = DenseBitSetExtended::from_string(
String::from("f001eddadf411eddec0de5ca1ab1ec0feefeeb1e01dc0b01"),
16,
);
let bs2 = DenseBitSetExtended::from_string(
String::from("0J2aG5BaMRS443FEBRGS5DTMV2A"),
32
);
bs = bs.rotr(17) | (bs2 << 43);
bs.set_bit(123, true);
println!("{}", bs.subset(3, 64).to_string());
The data structure does not make use of compression and is therefore not particularly suited to sparse bitsets: in this scenario alternatives such as the hibitset library can be considered instead.
clippy
incorrectly reports issues with "suspicious operators" in the shift operators. (To avoid errors we deactivated suspicious_op_assign_impl lint)
Each individual function is tested. Run the tests with
cargo test
The Criterion
dependency is used to provide precise benchmarkings. Benchmarks can be run with
cargo bench
Generate the documentation with
cargo doc
This project is licensed under the MIT License - see the LICENSE.md file for details