https://github.com/udoprog/uniset
A hierarchical growable bitset which supports in-place atomic operations
https://github.com/udoprog/uniset
bitset rust
Last synced: 4 months ago
JSON representation
A hierarchical growable bitset which supports in-place atomic operations
- Host: GitHub
- URL: https://github.com/udoprog/uniset
- Owner: udoprog
- License: apache-2.0
- Created: 2020-02-18T12:07:48.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-28T00:59:14.000Z (7 months ago)
- Last Synced: 2025-03-12T09:08:10.865Z (4 months ago)
- Topics: bitset, rust
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 7
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# uniset
[
](https://github.com/udoprog/uniset)
[](https://crates.io/crates/uniset)
[](https://docs.rs/uniset)
[](https://github.com/udoprog/uniset/actions?query=branch%3Amain)
A hierarchical, growable bit set with support for in-place atomic
operations.The idea is based on [hibitset], but dynamically growing instead of having a
fixed capacity. By being careful with the underlying data layout, we also
support structural sharing between the [local] and [atomic] bitsets.
## Features
* `vec-safety` - Avoid relying on the assumption that `&mut Vec` can be
safely coerced to `&mut Vec` if `T` and `U` have an identical memory
layouts (enabled by default, [issue #1]).
## Examples
```rust
use uniset::BitSet;let mut set = BitSet::new();
assert!(set.is_empty());
assert_eq!(0, set.capacity());set.set(127);
set.set(128);
assert!(!set.is_empty());assert!(set.test(128));
assert_eq!(vec![127, 128], set.iter().collect::>());
assert!(!set.is_empty());assert_eq!(vec![127, 128], set.drain().collect::>());
assert!(set.is_empty());
```[issue #1]: https://github.com/udoprog/unicycle/issues/1
[hibitset]: https://docs.rs/hibitset
[local]: https://docs.rs/uniset/latest/uniset/struct.BitSet.html
[atomic]: https://docs.rs/uniset/latest/uniset/struct.AtomicBitSet.html