pub struct BitVector { /* private fields */ }Expand description
A compact bit vector for storing boolean values.
Each boolean is stored as a single bit, providing 8x compression
compared to Vec<bool>.
Implementations§
Source§impl BitVector
impl BitVector
Sourcepub fn with_capacity(bits: usize) -> Self
pub fn with_capacity(bits: usize) -> Self
Creates a bit vector with the specified capacity (in bits).
Sourcepub fn from_bools(bools: &[bool]) -> Self
pub fn from_bools(bools: &[bool]) -> Self
Creates a bit vector from a slice of booleans.
Sourcepub fn filled(len: usize, value: bool) -> Self
pub fn filled(len: usize, value: bool) -> Self
Creates a bit vector with all bits set to the same value.
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of bits set to true.
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Returns the number of bits set to false.
Sourcepub fn ones_iter(&self) -> impl Iterator<Item = usize> + '_
pub fn ones_iter(&self) -> impl Iterator<Item = usize> + '_
Returns an iterator over indices where bits are true.
Sourcepub fn zeros_iter(&self) -> impl Iterator<Item = usize> + '_
pub fn zeros_iter(&self) -> impl Iterator<Item = usize> + '_
Returns an iterator over indices where bits are false.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Returns the compression ratio (original bytes / compressed bytes).
Sourcepub fn and(&self, other: &Self) -> Self
pub fn and(&self, other: &Self) -> Self
Performs bitwise AND with another bit vector.
The result has the length of the shorter vector.
Sourcepub fn or(&self, other: &Self) -> Self
pub fn or(&self, other: &Self) -> Self
Performs bitwise OR with another bit vector.
The result has the length of the shorter vector.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserializes from bytes.
Trait Implementations§
Source§impl FromIterator<bool> for BitVector
impl FromIterator<bool> for BitVector
impl Eq for BitVector
impl StructuralPartialEq for BitVector
Auto Trait Implementations§
impl Freeze for BitVector
impl RefUnwindSafe for BitVector
impl Send for BitVector
impl Sync for BitVector
impl Unpin for BitVector
impl UnwindSafe for BitVector
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§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.