-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: BitSet wrapper for BitVec #171
Comments
If I'm reading this correctly, the only missing API is the resizing insert? Contains is To your favor, I have already extended the impl<T, O> BitVec<T, O> where T: BitStore, O: BitOrder {
pub fn reallocating_insert(&mut self, idx: usize, value: bool) {
if self.len() <= idx {
// ensure that `idx` itself is allocated
self.resize(idx + 1, false);
}
self.set(idx, value);
}
} If you'd like to try this out in a patched fork and see if it works for you, I'd be willing to accept a PR if you want the contribution credit, or I can just put it in the upcoming 1.1 myself. |
I think that would be a good start. The other things that could be useful in this direction:
Looking at the method, I do believe it would help with my use case. |
It may also need additional functionality for things like |
I believe that BitVec provides all the necessary functionality to implement a BitSet wrapper, in a way that would be reasonably convenient.
iter_ones
BitAnd
andBitOr
implementationsThe main thing it would provide is a way to use BitVec as a set without needing to explicitly manage the length.
Does this seem like a worthwhile addition (at least behind a feature flag)?
Right now I use
bitvec
for vectors andbit-set
(https://crates.io/crates/bit-set) for the set operations, which then means I also depend (transitively) onbit-vec
. The latter two seem less maintained, so it would be nice to have a single standard crate for both vector and set-like operations.The text was updated successfully, but these errors were encountered: