pub struct RankSelectBitVec { /* private fields */ }Expand description
A bitvector with O(1) rank and O(log n) select support.
Uses u64 blocks with a superblock index every 512 bits. Rank queries
use u64::count_ones() for popcount. Select uses binary search over
superblocks.
Implementations§
Source§impl RankSelectBitVec
impl RankSelectBitVec
Sourcepub fn rank1(&self, i: usize) -> usize
pub fn rank1(&self, i: usize) -> usize
Count the number of 1-bits in positions [0, i).
Returns 0 if i == 0. Panics if i > len.
Sourcepub fn select1(&self, k: usize) -> Option<usize>
pub fn select1(&self, k: usize) -> Option<usize>
Find the position of the k-th 1-bit (1-indexed).
Returns None if there are fewer than k set bits.
Sourcepub fn select0(&self, k: usize) -> Option<usize>
pub fn select0(&self, k: usize) -> Option<usize>
Find the position of the k-th 0-bit (1-indexed).
Returns None if there are fewer than k zero bits.
Sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Total number of 1-bits.
Sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Total number of 0-bits.
Trait Implementations§
Source§impl Clone for RankSelectBitVec
impl Clone for RankSelectBitVec
Source§fn clone(&self) -> RankSelectBitVec
fn clone(&self) -> RankSelectBitVec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RankSelectBitVec
impl RefUnwindSafe for RankSelectBitVec
impl Send for RankSelectBitVec
impl Sync for RankSelectBitVec
impl Unpin for RankSelectBitVec
impl UnsafeUnpin for RankSelectBitVec
impl UnwindSafe for RankSelectBitVec
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
Mutably borrows from an owned value. Read more