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
sourceimpl Bitmap<128>
impl Bitmap<128>
pub unsafe fn load_m128i(&self) -> __m128i
sse2
only.sourceimpl Bitmap<256>
impl Bitmap<256>
pub unsafe fn load_m128i(&self) -> [__m128i; 2]
sse2
only.pub unsafe fn load_m256i(&self) -> __m256i
avx
only.sourceimpl Bitmap<512>
impl Bitmap<512>
pub unsafe fn load_m128i(&self) -> [__m128i; 4]
sse2
only.pub unsafe fn load_m256i(&self) -> [__m256i; 2]
avx
only.sourceimpl Bitmap<768>
impl Bitmap<768>
pub unsafe fn load_m128i(&self) -> [__m128i; 6]
sse2
only.pub unsafe fn load_m256i(&self) -> [__m256i; 3]
avx
only.sourceimpl Bitmap<1024>
impl Bitmap<1024>
pub unsafe fn load_m128i(&self) -> [__m128i; 8]
sse2
only.pub unsafe fn load_m256i(&self) -> [__m256i; 4]
avx
only.sourceimpl<const SIZE: usize> Bitmap<{ SIZE }>where
BitsImpl<SIZE>: Bits,
impl<const SIZE: usize> Bitmap<{ SIZE }>where
BitsImpl<SIZE>: Bits,
sourcepub fn mask(bits: usize) -> Self
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
.
sourcepub fn from_value(data: <BitsImpl<SIZE> as Bits>::Store) -> Self
pub fn from_value(data: <BitsImpl<SIZE> as Bits>::Store) -> Self
Construct a bitmap from a value of the same type as its backing store.
sourcepub fn into_value(self) -> <BitsImpl<SIZE> as Bits>::Store
pub fn into_value(self) -> <BitsImpl<SIZE> as Bits>::Store
Convert this bitmap into a value of the type of its backing store.
sourcepub fn as_value(&self) -> &<BitsImpl<SIZE> as Bits>::Store
pub fn as_value(&self) -> &<BitsImpl<SIZE> as Bits>::Store
Get a reference to this bitmap’s backing store.
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
sourcepub fn set(&mut self, index: usize, value: bool) -> bool
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.
sourcepub fn first_index(self) -> Option<usize>
pub fn first_index(self) -> Option<usize>
Find the index of the first true
bit in the bitmap.
sourcepub fn last_index(self) -> Option<usize>
pub fn last_index(self) -> Option<usize>
Find the index of the last true
bit in the bitmap.
sourcepub fn next_index(self, index: usize) -> Option<usize>
pub fn next_index(self, index: usize) -> Option<usize>
Find the index of the first true
bit in the bitmap after index
.
sourcepub fn prev_index(self, index: usize) -> Option<usize>
pub fn prev_index(self, index: usize) -> Option<usize>
Find the index of the last true
bit in the bitmap before index
.
sourcepub fn first_false_index(self) -> Option<usize>
pub fn first_false_index(self) -> Option<usize>
Find the index of the first false
bit in the bitmap.
sourcepub fn last_false_index(self) -> Option<usize>
pub fn last_false_index(self) -> Option<usize>
Find the index of the last false
bit in the bitmap.
sourcepub fn next_false_index(self, index: usize) -> Option<usize>
pub fn next_false_index(self, index: usize) -> Option<usize>
Find the index of the first false
bit in the bitmap after index
.
sourcepub fn prev_false_index(self, index: usize) -> Option<usize>
pub fn prev_false_index(self, index: usize) -> Option<usize>
Find the index of the first false
bit in the bitmap before index
.
Trait Implementations
sourceimpl<const SIZE: usize> BitAnd<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitAnd<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourceimpl<const SIZE: usize> BitAndAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitAndAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourcefn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresourceimpl<const SIZE: usize> BitOr<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitOr<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourceimpl<const SIZE: usize> BitOrAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitOrAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourcefn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresourceimpl<const SIZE: usize> BitXor<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitXor<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourceimpl<const SIZE: usize> BitXorAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> BitXorAssign<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourcefn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresourceimpl<const SIZE: usize> Hash for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: Hash,
impl<const SIZE: usize> Hash for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: Hash,
sourceimpl<'a, const SIZE: usize> IntoIterator for &'a Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<'a, const SIZE: usize> IntoIterator for &'a Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourceimpl<const SIZE: usize> Ord for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: Ord,
impl<const SIZE: usize> Ord for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: Ord,
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl<const SIZE: usize> PartialEq<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
impl<const SIZE: usize> PartialEq<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
sourceimpl<const SIZE: usize> PartialOrd<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: PartialOrd,
impl<const SIZE: usize> PartialOrd<Bitmap<SIZE>> for Bitmap<{ SIZE }>where
BitsImpl<{ SIZE }>: Bits,
<BitsImpl<{ SIZE }> as Bits>::Store: PartialOrd,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more