Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes the whole crate work with
u32
,u64
, andusize
underlying data for representing bits, through a trait that could be used for a user wanting to generate aBitSet
with other integer types. All unit tests are run on all versions. All operations, features and iterators are compatible, exceptAtomicBitSet
, which is still only hardcoded forusize
.Operations are for now strictly between
GenericBitSet
with the same underlying representation, but this might be generalized in the future, providing ops between any pair of sets. I've not looked into this.For backward compatibility, I've left the name
BitSet
specialized withusize
, adding a new nameGenericBitSet<T>
for other specializations.My use case
I'm using
specs
andhibitset
for a project that is compiled to WASM, which for now has a 32 bit address size, meaningusize
has 32 bits size, and I can only work with up to a million-ish entities. In the long term I will wish for more than that number, and wasm supports someu64
operations, so I would wager the performance hit is not gonna be too bad if I build aBitSet
from au64
, but I'll raise the maximum to 16 million-ish entities.Other use cases
The performance of the
BitSet
hierarchy will depend a lot on the density of the bits: when density is more than 1/64, the hierarchy almost becomes overhead. Being able to choose the layers' densities might be nice.Limitations: