MaskedBitVec

Struct MaskedBitVec 

Source
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>
where F: Fn(u64, u64) -> u64,

Source

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.

Source

pub fn get_unchecked(&self, pos: usize) -> u64

Return the bit at the given position. The bit takes the least significant bit of the returned u64 word.

§Panics

If the position is larger than the length of the vector, the function will either return unpredictable data, or panic. Use get to properly handle this case with an Option.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn count_zeros(&self) -> u64

Return the number of zeros in the masked bit vector. This method calls count_ones.

Source

pub fn count_ones(&self) -> u64

Return the number of ones in the masked bit vector.

Source

pub fn to_bit_vec(&self) -> BitVec

Collect the masked BitVec into a new BitVec by applying the mask to all bits.

Trait Implementations§

Source§

impl<'a, 'b, F: Clone + Fn(u64, u64) -> u64> Clone for MaskedBitVec<'a, 'b, F>

Source§

fn clone(&self) -> MaskedBitVec<'a, 'b, F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, 'b, F: Debug + Fn(u64, u64) -> u64> Debug for MaskedBitVec<'a, 'b, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, 'b, F> Freeze for MaskedBitVec<'a, 'b, F>
where F: Freeze,

§

impl<'a, 'b, F> RefUnwindSafe for MaskedBitVec<'a, 'b, F>
where F: RefUnwindSafe,

§

impl<'a, 'b, F> Send for MaskedBitVec<'a, 'b, F>
where F: Send,

§

impl<'a, 'b, F> Sync for MaskedBitVec<'a, 'b, F>
where F: Sync,

§

impl<'a, 'b, F> Unpin for MaskedBitVec<'a, 'b, F>
where F: Unpin,

§

impl<'a, 'b, F> UnwindSafe for MaskedBitVec<'a, 'b, F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.