enum Chunk {
Zeros(u16),
Ones(u16),
Mixed(u16, u16, Rc<[u64; 32]>),
}
Variants§
Zeros(u16)
A chunk that is all zeros; we don’t represent the zeros explicitly.
Ones(u16)
A chunk that is all ones; we don’t represent the ones explicitly.
Mixed(u16, u16, Rc<[u64; 32]>)
A chunk that has a mix of zeros and ones, which are represented explicitly and densely. It never has all zeros or all ones.
If this is the final chunk there may be excess, unused words. This turns out to be both simpler and have better performance than allocating the minimum number of words, largely because we avoid having to store the length, which would make this type larger. These excess words are always be zero, as are any excess bits in the final in-use word.
The second field is the count of 1s set in the chunk, and must satisfy
0 < count < chunk_domain_size
.
The words are within an Rc
because it’s surprisingly common to
duplicate an entire chunk, e.g. in ChunkedBitSet::clone_from()
, or
when a Mixed
chunk is union’d into a Zeros
chunk. When we do need
to modify a chunk we use Rc::make_mut
.
Implementations§
Trait Implementations§
impl Eq for Chunk
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl !Send for Chunk
impl !Sync for Chunk
impl Unpin for Chunk
impl UnwindSafe for Chunk
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes
Size for each variant:
Zeros
: 2 bytesOnes
: 2 bytesMixed
: 14 bytes