[][src]Struct sized_chunks::bitmap::Bitmap

pub struct Bitmap<Size: Bits> { /* fields omitted */ }

A compact array of bits.

The bitmap is stored as a primitive type, so the maximum value of Size is currently 128, corresponding to a type of u128. The type used to store the bitmap will be the minimum unsigned integer type required to fit the number of bits required, from u8 to u128.

Examples

let mut bitmap = Bitmap::<U10>::new();
assert_eq!(bitmap.set(5, true), false);
assert_eq!(bitmap.set(5, true), true);
assert_eq!(bitmap.get(5), true);
assert_eq!(bitmap.get(6), false);
assert_eq!(bitmap.len(), 1);
assert_eq!(bitmap.set(3, true), false);
assert_eq!(bitmap.len(), 2);
assert_eq!(bitmap.first_index(), Some(3));

Methods

impl<Size: Bits> Bitmap<Size>[src]

pub fn new() -> Self[src]

Construct an empty bitmap.

pub fn len(self) -> usize[src]

Count the number of true bits in the bitmap.

pub fn is_empty(self) -> bool[src]

Test if the bitmap contains only false bits.

pub fn get(self, index: usize) -> bool[src]

Get the value of the bit at a given index.

pub fn set(&mut self, index: usize, value: bool) -> bool[src]

Set the value of the bit at a given index.

Returns the previous value of the bit.

pub fn first_index(self) -> Option<usize>[src]

Find the index of the first true bit in the bitmap.

Trait Implementations

impl<Size: Bits> Copy for Bitmap<Size>[src]

impl<Size: Bits> Default for Bitmap<Size>[src]

impl<Size: Bits> Clone for Bitmap<Size>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<Size: Bits> PartialEq<Bitmap<Size>> for Bitmap<Size>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<Size: Bits> IntoIterator for Bitmap<Size>[src]

type Item = usize

The type of the elements being iterated over.

type IntoIter = Iter<Size>

Which kind of iterator are we turning this into?

impl<Size: Bits> Debug for Bitmap<Size>[src]

Auto Trait Implementations

impl<Size> Sync for Bitmap<Size> where
    <Size as Bits>::Store: Sync

impl<Size> Unpin for Bitmap<Size> where
    <Size as Bits>::Store: Unpin

impl<Size> Send for Bitmap<Size> where
    <Size as Bits>::Store: Send

impl<Size> UnwindSafe for Bitmap<Size> where
    <Size as Bits>::Store: UnwindSafe

impl<Size> RefUnwindSafe for Bitmap<Size> where
    <Size as Bits>::Store: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self