pub struct BitsRef<'a>(/* private fields */);
Expand description
Bits stored as a sequence of bytes (most significant bit first).
Implementations§
Source§impl<'a> BitsRef<'a>
impl<'a> BitsRef<'a>
pub fn from_bytes(bytes: &'a [u8], len: u64) -> Option<Self>
Sourcepub fn all_bytes(self) -> &'a [u8]
pub fn all_bytes(self) -> &'a [u8]
All of the bytes stored in the byte sequence: not just the ones actually used.
Sourcepub fn bytes(self) -> &'a [u8]
pub fn bytes(self) -> &'a [u8]
The used bytes of the byte sequence: bear in mind some of the bits in the last byte may be unused.
Sourcepub fn get(self, idx_bits: u64) -> Option<bool>
pub fn get(self, idx_bits: u64) -> Option<bool>
Get the byte at a specific index.
Returns None
for out-of-bounds.
Sourcepub fn count_ones(self) -> u64
pub fn count_ones(self) -> u64
Count the set bits (O(n)).
Sourcepub fn count_zeros(self) -> u64
pub fn count_zeros(self) -> u64
Count the unset bits (O(n)).
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(n)).
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(n)).
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(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(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§
Source§impl<'a> Ord for BitsRef<'a>
impl<'a> Ord for BitsRef<'a>
Source§impl<'a> PartialOrd for BitsRef<'a>
impl<'a> PartialOrd for BitsRef<'a>
impl<'a> Copy for BitsRef<'a>
impl<'a> Eq for BitsRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for BitsRef<'a>
impl<'a> RefUnwindSafe for BitsRef<'a>
impl<'a> Send for BitsRef<'a>
impl<'a> Sync for BitsRef<'a>
impl<'a> Unpin for BitsRef<'a>
impl<'a> UnwindSafe for BitsRef<'a>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)