bitmaps

Struct Bitmap

Source
pub struct Bitmap<Size: Bits> { /* private fields */ }
Expand description

A compact array of bits.

The type used to store the bitmap will be the minimum unsigned integer type required to fit the number of bits, from u8 to u128. If the size is 1, bool is used. If the size exceeds 128, an array of u128 will be used, sized as appropriately. The maximum supported size is currently 1024, represented by an array [u128; 8].

Implementations§

Source§

impl Bitmap<U128>

Source

pub unsafe fn load_m128i(&self) -> __m128i

Available with target feature sse2 only.
Source§

impl Bitmap<U256>

Source

pub unsafe fn load_m128i(&self) -> [__m128i; 2]

Available with target feature sse2 only.
Source

pub unsafe fn load_m256i(&self) -> __m256i

Available with target feature avx only.
Source§

impl Bitmap<U512>

Source

pub unsafe fn load_m128i(&self) -> [__m128i; 4]

Available with target feature sse2 only.
Source

pub unsafe fn load_m256i(&self) -> [__m256i; 2]

Available with target feature avx only.
Source§

impl Bitmap<U768>

Source

pub unsafe fn load_m128i(&self) -> [__m128i; 6]

Available with target feature sse2 only.
Source

pub unsafe fn load_m256i(&self) -> [__m256i; 3]

Available with target feature avx only.
Source§

impl Bitmap<U1024>

Source

pub unsafe fn load_m128i(&self) -> [__m128i; 8]

Available with target feature sse2 only.
Source

pub unsafe fn load_m256i(&self) -> [__m256i; 4]

Available with target feature avx only.
Source§

impl<Size: Bits> Bitmap<Size>

Source

pub fn new() -> Self

Construct a bitmap with every bit set to false.

Source

pub fn mask(bits: usize) -> Self

Construct a bitmap where every bit with index less than bits is true, and every other bit is false.

Source

pub fn from_value(data: Size::Store) -> Self

Construct a bitmap from a value of the same type as its backing store.

Source

pub fn into_value(self) -> Size::Store

Convert this bitmap into a value of the type of its backing store.

Source

pub fn len(self) -> usize

Count the number of true bits in the bitmap.

Source

pub fn is_empty(self) -> bool

Test if the bitmap contains only false bits.

Source

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

Get the value of the bit at a given index.

Source

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

Set the value of the bit at a given index.

Returns the previous value of the bit.

Source

pub fn first_index(self) -> Option<usize>

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

Source

pub fn invert(&mut self)

Invert all the bits in the bitmap.

Trait Implementations§

Source§

impl<Size: Bits> BitAnd for Bitmap<Size>

Source§

type Output = Bitmap<Size>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<Size: Bits> BitAndAssign for Bitmap<Size>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<Size: Bits> BitOr for Bitmap<Size>

Source§

type Output = Bitmap<Size>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<Size: Bits> BitOrAssign for Bitmap<Size>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<Size: Bits> BitXor for Bitmap<Size>

Source§

type Output = Bitmap<Size>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<Size: Bits> BitXorAssign for Bitmap<Size>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<Size: Bits> Clone for Bitmap<Size>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Size: Bits> Debug for Bitmap<Size>

Source§

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

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

impl<Size: Bits> Default for Bitmap<Size>

Source§

fn default() -> Self

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

impl From<[u128; 2]> for Bitmap<U256>

Source§

fn from(data: [u128; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 3]> for Bitmap<U384>

Source§

fn from(data: [u128; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 4]> for Bitmap<U512>

Source§

fn from(data: [u128; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 5]> for Bitmap<U640>

Source§

fn from(data: [u128; 5]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 6]> for Bitmap<U768>

Source§

fn from(data: [u128; 6]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 7]> for Bitmap<U896>

Source§

fn from(data: [u128; 7]) -> Self

Converts to this type from the input type.
Source§

impl From<[u128; 8]> for Bitmap<U1024>

Source§

fn from(data: [u128; 8]) -> Self

Converts to this type from the input type.
Source§

impl From<__m128i> for Bitmap<U128>

Source§

fn from(data: __m128i) -> Self

Converts to this type from the input type.
Source§

impl From<__m256i> for Bitmap<U256>

Source§

fn from(data: __m256i) -> Self

Converts to this type from the input type.
Source§

impl Into<[u128; 2]> for Bitmap<U256>

Source§

fn into(self) -> [u128; 2]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 3]> for Bitmap<U384>

Source§

fn into(self) -> [u128; 3]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 4]> for Bitmap<U512>

Source§

fn into(self) -> [u128; 4]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 5]> for Bitmap<U640>

Source§

fn into(self) -> [u128; 5]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 6]> for Bitmap<U768>

Source§

fn into(self) -> [u128; 6]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 7]> for Bitmap<U896>

Source§

fn into(self) -> [u128; 7]

Converts this type into the (usually inferred) input type.
Source§

impl Into<[u128; 8]> for Bitmap<U1024>

Source§

fn into(self) -> [u128; 8]

Converts this type into the (usually inferred) input type.
Source§

impl Into<__m128i> for Bitmap<U128>

Source§

fn into(self) -> __m128i

Converts this type into the (usually inferred) input type.
Source§

impl Into<__m256i> for Bitmap<U256>

Source§

fn into(self) -> __m256i

Converts this type into the (usually inferred) input type.
Source§

impl<'a, Size: Bits> IntoIterator for &'a Bitmap<Size>

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Size>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<Size: Bits> Not for Bitmap<Size>

Source§

type Output = Bitmap<Size>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<Size: Bits> PartialEq for Bitmap<Size>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Size: Bits> Copy for Bitmap<Size>

Auto Trait Implementations§

§

impl<Size> Freeze for Bitmap<Size>
where <Size as Bits>::Store: Freeze,

§

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

§

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

§

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> UnwindSafe for Bitmap<Size>
where <Size as Bits>::Store: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.