pub struct IndexedBitmap { /* private fields */ }Expand description
The indexed bitmap.
The core of this data structure is a bitmap, but we build index to accelerate search operations for zeroes and ones.
Implementations§
Source§impl IndexedBitmap
impl IndexedBitmap
pub fn new() -> IndexedBitmap
pub fn bitset(&mut self, n: usize, set: bool) -> bool
pub fn bitget(&self, n: usize) -> bool
pub fn lowest_zero(&self) -> usize
pub fn highest_one(&self) -> Option<usize>
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Size measured in bits to accomodate the bitmap.
It is set to self.highest_one() + 1 if there’s any set bit, or 0 if there’s no set bit.
pub fn this_one_or_next_one(&self, n: usize) -> Option<usize>
pub fn lowest_one(&self) -> Option<usize>
pub fn next_one(&self, n: usize) -> Option<usize>
Sourcepub fn shrink_to(&mut self, n: usize)
pub fn shrink_to(&mut self, n: usize)
Shrink to the specified size of holding the set pages.
When operating, it’s possible that some zero pages in bitmap and index are present. They are usually created when previous operations touches these pages. In that case, we will view these pages as would be touched in near future, so we won’t proactively shrink them. In fact, doing so it reduces unnecessary memory allocations.
However, it’s not always reasonable that the touched pages remains there indefinitely. So we offer this function so that the caller can recycle the excess zero pages.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink to the minimum size of holding the set pages.