Skip to main content

RawBitmapGeneric

Struct RawBitmapGeneric 

Source
pub struct RawBitmapGeneric<S: Storage> { /* private fields */ }
Expand description

A simple bitmap backed by generic storage.

Implementations§

Source§

impl<S: Storage> RawBitmapGeneric<S>

Source

pub const fn new(bits: S) -> Self

Create a new raw bitmap with the given storage.

Source

pub fn size(&self) -> usize

Returns the size of this bitmap.

Source

pub fn storage(&self) -> &S

Access the underlying storage read-only.

Source

pub fn storage_mut(&mut self) -> &mut S

Access the underlying storage mutably.

Source

pub fn shrink(&mut self, size: usize) -> Result<(), Status>

Shrinks the accessible portion of the bitmap, without re-allocating the underlying storage.

This is useful for programs which require underlying bitmap storage to be aligned to a certain size (initialized via Reset), but want to restrict access to a smaller portion of the bitmap (via Shrink).

Source

pub fn scan(&self, bitoff: usize, bitmax: usize, is_set: bool) -> Option<usize>

Returns true if all bits in the range [bitoff, bitmax) match is_set.

If they do not match, returns false and the index of the first bit that doesn’t match. An empty region (i.e. bitoff >= bitmax) will return true.

Source

pub fn reverse_scan( &self, bitoff: usize, bitmax: usize, is_set: bool, ) -> Option<usize>

Returns true if all bits in the range [bitoff, bitmax) match is_set, scanning in reverse.

If they do not match, returns false and the index of the last bit that doesn’t match. An empty region (i.e. bitoff >= bitmax) will return true.

Source

pub fn reverse_find( &self, is_set: bool, bitoff: usize, bitmax: usize, run_len: usize, ) -> Result<usize, Status>

Finds the last run of run_len is_set bits, in [bitoff, bitmax).

Returns the start of the run, or Status::NO_RESOURCES if not found.

Source

pub fn grow(&mut self, size: usize) -> Result<(), Status>

Increases the bitmap size.

Source

pub fn reset(&mut self, size: usize) -> Result<(), Status>

Resets the bitmap; clearing and resizing it.

Allocates memory, and can fail.

Trait Implementations§

Source§

impl<S: Storage> Bitmap<usize> for RawBitmapGeneric<S>

Source§

fn find( &self, is_set: bool, bitoff: usize, bitmax: usize, run_len: usize, ) -> Result<usize, Status>

Finds a run of run_len is_set bits, between bitoff and bitmax. Read more
Source§

fn get(&self, bitoff: usize, bitmax: usize) -> GetResult<usize>

Returns true if all the bits in [bitoff, bitmax) are set. Read more
Source§

fn set(&mut self, bitoff: usize, bitmax: usize) -> Result<(), Status>

Sets all bits in the range [bitoff, bitmax). Read more
Source§

fn clear(&mut self, bitoff: usize, bitmax: usize) -> Result<(), Status>

Clears all bits in the range [bitoff, bitmax). Read more
Source§

fn clear_all(&mut self)

Clear all bits in the bitmap.
Source§

fn get_one(&self, bitoff: T) -> bool

Returns true if the bit at bitoff is set.
Source§

fn set_one(&mut self, bitoff: T) -> Result<(), Status>

Sets the bit at bitoff.
Source§

fn clear_one(&mut self, bitoff: T) -> Result<(), Status>

Clears the bit at bitoff.
Source§

impl<S: Debug + Storage> Debug for RawBitmapGeneric<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Default + Storage> Default for RawBitmapGeneric<S>

Source§

fn default() -> RawBitmapGeneric<S>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for RawBitmapGeneric<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for RawBitmapGeneric<S>
where S: RefUnwindSafe,

§

impl<S> Send for RawBitmapGeneric<S>
where S: Send,

§

impl<S> Sync for RawBitmapGeneric<S>
where S: Sync,

§

impl<S> Unpin for RawBitmapGeneric<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for RawBitmapGeneric<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for RawBitmapGeneric<S>
where S: UnwindSafe,

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> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.