Struct GrowingBitmap
pub struct GrowingBitmap { /* private fields */ }
Expand description
A bitmap that is automatically resized whenever an element higher than the maximum capacity of the bitmap is set.
Newly added bits are initialized to 0
(unset).
Implementations§
§impl GrowingBitmap
impl GrowingBitmap
pub const EMPTY: &'static GrowingBitmap = _
pub const EMPTY: &'static GrowingBitmap = _
An empty bitmap
pub const fn new() -> Self
pub const fn new() -> Self
Creates a new, empty, bitmap
pub fn from_slice(slice: &impl BitmapSlice) -> Self
pub fn from_slice(slice: &impl BitmapSlice) -> Self
Creates a bitmap and fills it with the data from slice
.
pub fn clone_from_slice(&mut self, slice: &impl BitmapSlice)
pub fn clone_from_slice(&mut self, slice: &impl BitmapSlice)
Clears the current bitmap, then fills it with data from slice
.
pub fn new_all_ones(num: usize) -> Self
pub fn new_all_ones(num: usize) -> Self
Creates a new bitmap with num
ones.
pub fn new_all_zeros(num: usize) -> Self
pub fn new_all_zeros(num: usize) -> Self
Creates a new bitmap with num
zeros.
pub fn get_then_reset(&mut self, n: usize) -> bool
pub fn get_then_reset(&mut self, n: usize) -> bool
Returns the value of the n
th bit, then resets it to 0
.
pub fn and_with(&mut self, rhs: &impl BitmapSlice) -> bool
pub fn and_with(&mut self, rhs: &impl BitmapSlice) -> bool
ANDs the bitmap with rhs
.
pub fn or_with(&mut self, rhs: &impl BitmapSlice) -> bool
pub fn or_with(&mut self, rhs: &impl BitmapSlice) -> bool
ORs the bitmap with rhs
.
pub fn set(&mut self, n: usize) -> bool
pub fn set(&mut self, n: usize) -> bool
Sets self[n]
to true.
Returns true if self[n]
changed; False if self[n]
was already true.
pub fn reset(&mut self, n: usize) -> bool
pub fn reset(&mut self, n: usize) -> bool
Sets self[n]
to false.
Returns true if self[n]
changed; False if self[n]
was already false.
pub fn extend(&mut self, items: impl IntoIterator<Item = bool>)
pub fn extend(&mut self, items: impl IntoIterator<Item = bool>)
Extends the bitmap with items
.
New values are inserted at the end of the bitmap.
pub fn fill_with_ones(&mut self)
pub fn fill_with_ones(&mut self)
Fills the bitmap with ones.
pub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of ones in the bitmap.
pub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Returns the number of zeros in the bitmap.
pub fn is_all_zeros(&self) -> bool
pub fn is_all_zeros(&self) -> bool
Returns true if the bitmap only contains zeros.
pub fn is_all_ones(&self) -> bool
pub fn is_all_ones(&self) -> bool
Returns true if the bitmap only contains ones.
pub fn remove(&mut self, n: usize) -> bool
pub fn remove(&mut self, n: usize) -> bool
Removes bit n
and shifts all bits above n
down by one bit.
pub fn remove_front(&mut self, num: usize)
pub fn remove_front(&mut self, num: usize)
Removes the first num
bits, and shifts the other bits down
by num
bits.
pub fn remove_back(&mut self, num: usize)
pub fn remove_back(&mut self, num: usize)
Removes the last num
bits from the bitmap.
pub fn first_bit_set(&self) -> Option<usize>
pub fn first_bit_set(&self) -> Option<usize>
Returns the index of the first one bit in the bitmap.
pub fn first_bit_set_from(&self, start_index: usize) -> Option<usize>
pub fn first_bit_set_from(&self, start_index: usize) -> Option<usize>
Returns the lowest index >= start_index for which self[index] = true
pub fn first_bit_unset_from(&self, start_index: usize) -> Option<usize>
pub fn first_bit_unset_from(&self, start_index: usize) -> Option<usize>
Returns the lowest index >= start_index for which self[index] = false
pub fn first_bit_set_after_many(
items: &[&GrowingBitmap],
start_index: usize,
end_index: usize,
) -> Option<usize>
pub fn first_bit_set_after_many( items: &[&GrowingBitmap], start_index: usize, end_index: usize, ) -> Option<usize>
Returns the index of the first bit set in all bitmaps in items
.
pub fn is_superset_of(&self, other: &GrowingBitmap) -> bool
pub fn is_superset_of(&self, other: &GrowingBitmap) -> bool
Returns true if for all bits: other[n] implies self[n].
pub fn overlaps_with(&self, other: &impl BitmapSlice) -> bool
pub fn overlaps_with(&self, other: &impl BitmapSlice) -> bool
Returns true if there are any bits set both in this bitmap and in other
.
pub fn clear_from(&mut self, other: &impl BitmapSlice)
pub fn clear_from(&mut self, other: &impl BitmapSlice)
Clears the bits in self if they are set in other
pub fn iter(&self) -> GrowingBitmapIterator<'_>
pub fn iter(&self) -> GrowingBitmapIterator<'_>
Iterates over all bits in the bitmap.
pub fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
pub fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
Iterates over all indices of the bits that are one.
pub fn resize(&mut self, len: usize)
pub fn resize(&mut self, len: usize)
Resizes the bitmap to contain exactly len
bits.
If the bitmap grows, zero bits are inserted at the end.
pub fn clear_range(&mut self, index: Range<usize>)
pub fn clear_range(&mut self, index: Range<usize>)
Sets all bits in range
to zero.
pub fn append(&mut self, bitmap: &GrowingBitmap)
pub fn append(&mut self, bitmap: &GrowingBitmap)
Appends bitmap
to the bitmap.
pub fn slice(&self, range: Range<usize>) -> impl BitmapSlice + '_
pub fn slice(&self, range: Range<usize>) -> impl BitmapSlice + '_
Returns a slice that references the bits in range
.
pub fn slice_mut(&mut self, range: Range<usize>) -> impl BitmapSliceMut + '_
pub fn slice_mut(&mut self, range: Range<usize>) -> impl BitmapSliceMut + '_
Returns a mutable slice that references the bits in range
.
pub fn set_all_zero(&mut self)
pub fn set_all_zero(&mut self)
Sets all bits in the bitmap to zero.
Trait Implementations§
§impl BitAnd for &GrowingBitmap
impl BitAnd for &GrowingBitmap
§impl BitAnd for GrowingBitmap
impl BitAnd for GrowingBitmap
§impl<'a> BitAndAssign<&'a GrowingBitmap> for GrowingBitmap
impl<'a> BitAndAssign<&'a GrowingBitmap> for GrowingBitmap
§fn bitand_assign(&mut self, rhs: &'a GrowingBitmap)
fn bitand_assign(&mut self, rhs: &'a GrowingBitmap)
&=
operation. Read more§impl BitAndAssign for GrowingBitmap
impl BitAndAssign for GrowingBitmap
§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read more§impl BitOr for &GrowingBitmap
impl BitOr for &GrowingBitmap
§impl BitOr for GrowingBitmap
impl BitOr for GrowingBitmap
§impl<'a> BitOrAssign<&'a GrowingBitmap> for GrowingBitmap
impl<'a> BitOrAssign<&'a GrowingBitmap> for GrowingBitmap
§fn bitor_assign(&mut self, rhs: &'a GrowingBitmap)
fn bitor_assign(&mut self, rhs: &'a GrowingBitmap)
|=
operation. Read more§impl BitOrAssign for GrowingBitmap
impl BitOrAssign for GrowingBitmap
§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read more§impl BitmapSlice for &GrowingBitmap
impl BitmapSlice for &GrowingBitmap
§fn iter_data(&self) -> impl Iterator<Item = u64> + '_
fn iter_data(&self) -> impl Iterator<Item = u64> + '_
§fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
other
.§fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
other
.
In other words, if there is any bit which is set in both bitmaps.§fn is_all_zeros(&self) -> bool
fn is_all_zeros(&self) -> bool
§fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
other
.§fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
§fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
other
.§fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
other
.§fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
other
.§fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
self & !other
.§fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
§fn count_ones(&self) -> usize
fn count_ones(&self) -> usize
§fn count_zeros(&self) -> usize
fn count_zeros(&self) -> usize
§impl BitmapSlice for &mut GrowingBitmap
impl BitmapSlice for &mut GrowingBitmap
§fn iter_data(&self) -> impl Iterator<Item = u64> + '_
fn iter_data(&self) -> impl Iterator<Item = u64> + '_
§fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
other
.§fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
other
.
In other words, if there is any bit which is set in both bitmaps.§fn is_all_zeros(&self) -> bool
fn is_all_zeros(&self) -> bool
§fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
other
.§fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
§fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
other
.§fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
other
.§fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
other
.§fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
self & !other
.§fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
§fn count_ones(&self) -> usize
fn count_ones(&self) -> usize
§fn count_zeros(&self) -> usize
fn count_zeros(&self) -> usize
§impl BitmapSlice for GrowingBitmap
impl BitmapSlice for GrowingBitmap
§fn iter_data(&self) -> impl Iterator<Item = u64> + '_
fn iter_data(&self) -> impl Iterator<Item = u64> + '_
§fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usizewhere
Self: Sized,
other
.§fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
fn overlaps_with(&self, other: &impl BitmapSlice) -> boolwhere
Self: Sized,
other
.
In other words, if there is any bit which is set in both bitmaps.§fn is_all_zeros(&self) -> bool
fn is_all_zeros(&self) -> bool
§fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
fn is_subset_of(&self, other: &impl BitmapSlice) -> bool
other
.§fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
fn flipped(&self) -> Flipped<'_, Self>where
Self: Sized,
§fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
fn anded_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> AndWith<'r, Self, B>where
Self: Sized,
other
.§fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
fn xored_with<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> XorWith<'r, Self, B>where
Self: Sized,
other
.§fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>where
Self: Sized,
other
.§fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
fn cleared_from<'r, B: BitmapSlice>(
&'r self,
other: &'r B,
) -> ClearFrom<'r, Self, B>where
Self: Sized,
self & !other
.§fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_
§fn count_ones(&self) -> usize
fn count_ones(&self) -> usize
§fn count_zeros(&self) -> usize
fn count_zeros(&self) -> usize
§impl BitmapSliceMut for &mut GrowingBitmap
impl BitmapSliceMut for &mut GrowingBitmap
§fn copy_from(&mut self, other: &impl BitmapSlice)
fn copy_from(&mut self, other: &impl BitmapSlice)
other
. Read more§fn clear_from(&mut self, other: &impl BitmapSlice)
fn clear_from(&mut self, other: &impl BitmapSlice)
!other
. Read more§fn or_with(&mut self, other: &impl BitmapSlice)
fn or_with(&mut self, other: &impl BitmapSlice)
other
. Read more§impl BitmapSliceMut for GrowingBitmap
impl BitmapSliceMut for GrowingBitmap
§fn copy_from(&mut self, other: &impl BitmapSlice)
fn copy_from(&mut self, other: &impl BitmapSlice)
other
. Read more§fn clear_from(&mut self, other: &impl BitmapSlice)
fn clear_from(&mut self, other: &impl BitmapSlice)
!other
. Read more§fn or_with(&mut self, other: &impl BitmapSlice)
fn or_with(&mut self, other: &impl BitmapSlice)
other
. Read more§impl Clone for GrowingBitmap
impl Clone for GrowingBitmap
§impl Debug for GrowingBitmap
impl Debug for GrowingBitmap
§impl Default for GrowingBitmap
impl Default for GrowingBitmap
§fn default() -> GrowingBitmap
fn default() -> GrowingBitmap
§impl FromIterator<bool> for GrowingBitmap
impl FromIterator<bool> for GrowingBitmap
§fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self
§impl Hash for GrowingBitmap
impl Hash for GrowingBitmap
§impl<'a> Index<&'a usize> for GrowingBitmap
impl<'a> Index<&'a usize> for GrowingBitmap
§impl Index<usize> for GrowingBitmap
impl Index<usize> for GrowingBitmap
§impl PartialEq for GrowingBitmap
impl PartialEq for GrowingBitmap
§impl<const N: usize> TryFrom<&GrowingBitmap> for FixedBitmapU64<N>
impl<const N: usize> TryFrom<&GrowingBitmap> for FixedBitmapU64<N>
impl Eq for GrowingBitmap
Auto Trait Implementations§
impl Freeze for GrowingBitmap
impl RefUnwindSafe for GrowingBitmap
impl Send for GrowingBitmap
impl Sync for GrowingBitmap
impl Unpin for GrowingBitmap
impl UnwindSafe for GrowingBitmap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more