[−][src]Struct sized_chunks::bitmap::Bitmap
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> 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?
fn into_iter(self) -> Self::IntoIter[src]
impl<Size: Bits> Default for Bitmap<Size>[src]
impl<Size: Bits> Clone for Bitmap<Size>[src]
fn clone(&self) -> Self[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]
fn eq(&self, other: &Self) -> bool[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<Size: Bits> Debug for Bitmap<Size>[src]
Auto Trait Implementations
impl<Size> Unpin for Bitmap<Size> where
<Size as Bits>::Store: Unpin,
<Size as Bits>::Store: Unpin,
impl<Size> Sync for Bitmap<Size> where
<Size as Bits>::Store: Sync,
<Size as Bits>::Store: Sync,
impl<Size> Send for Bitmap<Size> where
<Size as Bits>::Store: Send,
<Size as Bits>::Store: Send,
impl<Size> UnwindSafe for Bitmap<Size> where
<Size as Bits>::Store: UnwindSafe,
<Size as Bits>::Store: UnwindSafe,
impl<Size> RefUnwindSafe for Bitmap<Size> where
<Size as Bits>::Store: RefUnwindSafe,
<Size as Bits>::Store: RefUnwindSafe,
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator, [src]
I: Iterator,
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?
fn into_iter(self) -> I[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Same<T> for T[src]
type Output = T
Should always be Self