pub struct Bitmap<const N: usize>where
BitsImpl<N>: Bits,{ /* private fields */ }Expand description
A fixed capacity inline bitmap of N bits.
Used as the occupancy map inside SparseChunk.
Supports N in 1..=1024; other sizes fail to compile.
Implementations§
Source§impl<const N: usize> Bitmap<N>where
BitsImpl<N>: Bits,
impl<const N: usize> Bitmap<N>where
BitsImpl<N>: Bits,
Sourcepub fn from_value(data: <BitsImpl<N> as Bits>::Store) -> Self
pub fn from_value(data: <BitsImpl<N> as Bits>::Store) -> Self
Construct a bitmap from a value of the same type as its backing store.
Bits at or above index N are cleared, keeping the bitmap coherent:
len(), is_empty() and is_full() only ever count bits below N.
Sourcepub fn set(&mut self, index: usize, value: bool) -> bool
pub fn set(&mut self, index: usize, value: bool) -> bool
Set the value of the bit at a given index, returning the previous value.
index must be < N (debug-asserted, as with the bitmaps crate);
writing a padding bit in a release build would create an incoherent
state, so len() would count a bit no scan or iterator can see.
Sourcepub fn first_index(self) -> Option<usize>
pub fn first_index(self) -> Option<usize>
Find the index of the first set bit.
Sourcepub fn next_index(self, index: usize) -> Option<usize>
pub fn next_index(self, index: usize) -> Option<usize>
Find the index of the first set bit strictly after index.
Sourcepub fn last_index(self) -> Option<usize>
pub fn last_index(self) -> Option<usize>
Find the index of the last set bit.
Sourcepub fn prev_index(self, index: usize) -> Option<usize>
pub fn prev_index(self, index: usize) -> Option<usize>
Find the index of the last set bit strictly before index.
Sourcepub fn first_false_index(self) -> Option<usize>
pub fn first_false_index(self) -> Option<usize>
Find the index of the first clear bit.
Sourcepub fn next_false_index(self, index: usize) -> Option<usize>
pub fn next_false_index(self, index: usize) -> Option<usize>
Find the index of the first clear bit strictly after index.