pub struct MaskedBitVec<'a, 'b, F: Fn(u64, u64) -> u64> { /* private fields */ }Expand description
A bit vector that is masked with another bit vector via a masking function. Offers the same functions as an unmasked vector. The mask is applied lazily.
Implementations§
Source§impl<'a, 'b, F> MaskedBitVec<'a, 'b, F>
impl<'a, 'b, F> MaskedBitVec<'a, 'b, F>
Sourcepub fn get(&self, pos: usize) -> Option<u64>
pub fn get(&self, pos: usize) -> Option<u64>
Return the bit at the given position. The bit takes the least significant bit of the returned u64 word. If the position is larger than the length of the vector, None is returned.
Sourcepub fn get_unchecked(&self, pos: usize) -> u64
pub fn get_unchecked(&self, pos: usize) -> u64
Sourcepub fn is_bit_set(&self, pos: usize) -> Option<bool>
pub fn is_bit_set(&self, pos: usize) -> Option<bool>
Return whether the bit at the given position is set. If the position is larger than the length of the vector, None is returned.
Sourcepub fn is_bit_set_unchecked(&self, pos: usize) -> bool
pub fn is_bit_set_unchecked(&self, pos: usize) -> bool
Return whether the bit at the given position is set.
§Panics
If the position is larger than the length of the vector,
the function will either return unpredictable data, or panic.
Use is_bit_set to properly handle this case with an Option.
Sourcepub fn get_bits(&self, pos: usize, len: usize) -> Option<u64>
pub fn get_bits(&self, pos: usize, len: usize) -> Option<u64>
Return multiple bits at the given position. The number of bits to return is given by len.
At most 64 bits can be returned.
If the position at the end of the query is larger than the length of the vector,
None is returned (even if the query partially overlaps with the vector).
If the length of the query is larger than 64, None is returned.
Sourcepub fn get_bits_unchecked(&self, pos: usize, len: usize) -> u64
pub fn get_bits_unchecked(&self, pos: usize, len: usize) -> u64
Return multiple bits at the given position. The number of bits to return is given by len.
At most 64 bits can be returned.
This function is always inlined, because it gains a lot from loop optimization and can utilize the processor pre-fetcher better if it is.
§Errors
If the length of the query is larger than 64, unpredictable data will be returned.
Use get_bits to avoid this.
§Panics
If the position or interval is larger than the length of the vector, the function will either return any valid results padded with unpredictable data or panic.
Sourcepub fn count_zeros(&self) -> u64
pub fn count_zeros(&self) -> u64
Return the number of zeros in the masked bit vector.
This method calls count_ones.
Sourcepub fn count_ones(&self) -> u64
pub fn count_ones(&self) -> u64
Return the number of ones in the masked bit vector.
Sourcepub fn to_bit_vec(&self) -> BitVec
pub fn to_bit_vec(&self) -> BitVec
Collect the masked BitVec into a new BitVec by applying the mask to all bits.