Struct indexed_bitvec::IndexedBits
source · Expand description
Bits stored with extra index data for fast rank and select.
Implementations
sourceimpl<T: Deref<Target = [u8]>> IndexedBits<T>
impl<T: Deref<Target = [u8]>> IndexedBits<T>
sourcepub fn build_index(bits: Bits<T>) -> Self
pub fn build_index(bits: Bits<T>) -> Self
Build the index for a sequence of bits.
This is an expensive operation which will examine all of the data input.
pub fn bits(&self) -> Bits<&[u8]>
sourcepub fn decompose(self) -> Bits<T>
pub fn decompose(self) -> Bits<T>
Discard the index and get the original bit sequence storage back.
sourcepub fn count_ones(&self) -> u64
pub fn count_ones(&self) -> u64
Count the set bits (fast O(1)).
sourcepub fn count_zeros(&self) -> u64
pub fn count_zeros(&self) -> u64
Count the unset bits (fast O(1)).
sourcepub fn rank_ones(&self, idx: u64) -> Option<u64>
pub fn rank_ones(&self, idx: u64) -> Option<u64>
Count the set bits before a position in the bits (O(1)).
Returns None
it the index is out of bounds.
sourcepub fn rank_zeros(&self, idx: u64) -> Option<u64>
pub fn rank_zeros(&self, idx: u64) -> Option<u64>
Count the unset bits before a position in the bits (O(1)).
Returns None
it the index is out of bounds.
sourcepub fn select_ones(&self, target_rank: u64) -> Option<u64>
pub fn select_ones(&self, target_rank: u64) -> Option<u64>
Find the position of a set bit by its rank (O(log n)).
Returns None
if no suitable bit is found. It is
always the case otherwise that rank_ones(result) == Some(target_rank)
and get(result) == Some(true)
.
sourcepub fn select_zeros(&self, target_rank: u64) -> Option<u64>
pub fn select_zeros(&self, target_rank: u64) -> Option<u64>
Find the position of an unset bit by its rank (O(log n)).
Returns None
if no suitable bit is found. It is
always the case otherwise that rank_zeros(result) == Some(target_rank)
and get(result) == Some(false)
.
Trait Implementations
sourceimpl<T: Clone + Deref<Target = [u8]>> Clone for IndexedBits<T>
impl<T: Clone + Deref<Target = [u8]>> Clone for IndexedBits<T>
sourcefn clone(&self) -> IndexedBits<T>
fn clone(&self) -> IndexedBits<T>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more