Skip to main content

IndexedBitmap

Struct IndexedBitmap 

Source
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

Source

pub fn new() -> IndexedBitmap

Source

pub fn bitset(&mut self, n: usize, set: bool) -> bool

Source

pub fn bitget(&self, n: usize) -> bool

Source

pub fn lowest_zero(&self) -> usize

Source

pub fn highest_one(&self) -> Option<usize>

Source

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.

Source

pub fn this_one_or_next_one(&self, n: usize) -> Option<usize>

Source

pub fn lowest_one(&self) -> Option<usize>

Source

pub fn next_one(&self, n: usize) -> Option<usize>

Source

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.

Source

pub fn shrink_to_fit(&mut self)

Shrink to the minimum size of holding the set pages.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.