liblisa::utils::bitmap

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

pub const EMPTY: &'static GrowingBitmap = _

An empty bitmap

pub const fn new() -> Self

Creates a new, empty, bitmap

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)

Clears the current bitmap, then fills it with data from slice.

pub fn new_all_ones(num: usize) -> Self

Creates a new bitmap with num ones.

pub fn new_all_zeros(num: usize) -> Self

Creates a new bitmap with num zeros.

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

Returns the value of the nth bit.

pub fn get_then_reset(&mut self, n: usize) -> bool

Returns the value of the nth bit, then resets it to 0.

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

ORs the bitmap with rhs.

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

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>)

Extends the bitmap with items. New values are inserted at the end of the bitmap.

pub fn fill_with_ones(&mut self)

Fills the bitmap with ones.

pub fn count_ones(&self) -> usize

Returns the number of ones in the bitmap.

pub fn count_zeros(&self) -> usize

Returns the number of zeros in the bitmap.

pub fn is_all_zeros(&self) -> bool

Returns true if the bitmap only contains zeros.

pub fn is_all_ones(&self) -> bool

Returns true if the bitmap only contains ones.

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)

Removes the first num bits, and shifts the other bits down by num bits.

pub fn remove_back(&mut self, num: usize)

Removes the last num bits from the bitmap.

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>

Returns the lowest index >= start_index for which self[index] = true

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>

Returns the index of the first bit set in all bitmaps in items.

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

Returns true if there are any bits set both in this bitmap and in other.

pub fn clear_from(&mut self, other: &impl BitmapSlice)

Clears the bits in self if they are set in other

pub fn len(&self) -> usize

Returns the length of the bitmap.

pub fn is_empty(&self) -> bool

Returns true if the bitmap is empty.

pub fn iter(&self) -> GrowingBitmapIterator<'_>

Iterates over all bits in the bitmap.

pub fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_

Iterates over all indices of the bits that are one.

pub fn data(&self) -> &[u64]

Returns the backing data of the bitmap.

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 set_range(&mut self, range: Range<usize>)

Sets all bits in range to one.

pub fn clear_range(&mut self, index: Range<usize>)

Sets all bits in range to zero.

pub fn append(&mut self, bitmap: &GrowingBitmap)

Appends bitmap to the bitmap.

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 + '_

Returns a mutable slice that references the bits in range.

pub fn set_all_zero(&mut self)

Sets all bits in the bitmap to zero.

Trait Implementations§

§

impl BitAnd for &GrowingBitmap

§

type Output = GrowingBitmap

The resulting type after applying the & operator.
§

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

Performs the & operation. Read more
§

impl BitAnd for GrowingBitmap

§

type Output = GrowingBitmap

The resulting type after applying the & operator.
§

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

Performs the & operation. Read more
§

impl<'a> BitAndAssign<&'a GrowingBitmap> for GrowingBitmap

§

fn bitand_assign(&mut self, rhs: &'a GrowingBitmap)

Performs the &= operation. Read more
§

impl BitAndAssign for GrowingBitmap

§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
§

impl BitOr for &GrowingBitmap

§

type Output = GrowingBitmap

The resulting type after applying the | operator.
§

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

Performs the | operation. Read more
§

impl BitOr for GrowingBitmap

§

type Output = GrowingBitmap

The resulting type after applying the | operator.
§

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

Performs the | operation. Read more
§

impl<'a> BitOrAssign<&'a GrowingBitmap> for GrowingBitmap

§

fn bitor_assign(&mut self, rhs: &'a GrowingBitmap)

Performs the |= operation. Read more
§

impl BitOrAssign for GrowingBitmap

§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
§

impl BitmapSlice for &GrowingBitmap

§

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

Returns the value of the bit at position index.
§

fn len(&self) -> usize

Returns the number of bits in the bitmap.
§

fn iter_data(&self) -> impl Iterator<Item = u64> + '_

Iterates over the internal backing data of the bitmap.
§

fn is_empty(&self) -> bool

Return true if the bitmap is empty.
§

fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usize
where Self: Sized,

Counts the number of bits that are one in both this bitmap and other.
§

fn overlaps_with(&self, other: &impl BitmapSlice) -> bool
where Self: Sized,

Returns true if the bitmap overlaps with other. In other words, if there is any bit which is set in both bitmaps.
§

fn is_all_zeros(&self) -> bool

Returns true if all bits in the bitmap are set to one.
§

fn is_subset_of(&self, other: &impl BitmapSlice) -> bool

Returns true if, for all bits set in the bitmap, it is also set in other.
§

fn flipped(&self) -> Flipped<'_, Self>
where Self: Sized,

Returns a slice to a bitmap where each bit is negated.
§

fn anded_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> AndWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ANDed with other.
§

fn xored_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> XorWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is XORed with other.
§

fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ORed with other.
§

fn cleared_from<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> ClearFrom<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is set to self & !other.
§

fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_

Iterates over all indices in the bitmap that are set to one.
§

fn iter(&self) -> impl Iterator<Item = bool> + '_

Iterates over all bits in the bitmap.
§

fn count_ones(&self) -> usize

Counts the number of bits that are one.
§

fn count_zeros(&self) -> usize

Counts the number of bits that are zero.
§

impl BitmapSlice for &mut GrowingBitmap

§

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

Returns the value of the bit at position index.
§

fn len(&self) -> usize

Returns the number of bits in the bitmap.
§

fn iter_data(&self) -> impl Iterator<Item = u64> + '_

Iterates over the internal backing data of the bitmap.
§

fn is_empty(&self) -> bool

Return true if the bitmap is empty.
§

fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usize
where Self: Sized,

Counts the number of bits that are one in both this bitmap and other.
§

fn overlaps_with(&self, other: &impl BitmapSlice) -> bool
where Self: Sized,

Returns true if the bitmap overlaps with other. In other words, if there is any bit which is set in both bitmaps.
§

fn is_all_zeros(&self) -> bool

Returns true if all bits in the bitmap are set to one.
§

fn is_subset_of(&self, other: &impl BitmapSlice) -> bool

Returns true if, for all bits set in the bitmap, it is also set in other.
§

fn flipped(&self) -> Flipped<'_, Self>
where Self: Sized,

Returns a slice to a bitmap where each bit is negated.
§

fn anded_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> AndWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ANDed with other.
§

fn xored_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> XorWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is XORed with other.
§

fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ORed with other.
§

fn cleared_from<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> ClearFrom<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is set to self & !other.
§

fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_

Iterates over all indices in the bitmap that are set to one.
§

fn iter(&self) -> impl Iterator<Item = bool> + '_

Iterates over all bits in the bitmap.
§

fn count_ones(&self) -> usize

Counts the number of bits that are one.
§

fn count_zeros(&self) -> usize

Counts the number of bits that are zero.
§

impl BitmapSlice for GrowingBitmap

§

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

Returns the value of the bit at position index.
§

fn len(&self) -> usize

Returns the number of bits in the bitmap.
§

fn iter_data(&self) -> impl Iterator<Item = u64> + '_

Iterates over the internal backing data of the bitmap.
§

fn is_empty(&self) -> bool

Return true if the bitmap is empty.
§

fn count_overlapping_with(&self, other: &impl BitmapSlice) -> usize
where Self: Sized,

Counts the number of bits that are one in both this bitmap and other.
§

fn overlaps_with(&self, other: &impl BitmapSlice) -> bool
where Self: Sized,

Returns true if the bitmap overlaps with other. In other words, if there is any bit which is set in both bitmaps.
§

fn is_all_zeros(&self) -> bool

Returns true if all bits in the bitmap are set to one.
§

fn is_subset_of(&self, other: &impl BitmapSlice) -> bool

Returns true if, for all bits set in the bitmap, it is also set in other.
§

fn flipped(&self) -> Flipped<'_, Self>
where Self: Sized,

Returns a slice to a bitmap where each bit is negated.
§

fn anded_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> AndWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ANDed with other.
§

fn xored_with<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> XorWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is XORed with other.
§

fn ored_with<'r, B: BitmapSlice>(&'r self, other: &'r B) -> OrWith<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is ORed with other.
§

fn cleared_from<'r, B: BitmapSlice>( &'r self, other: &'r B, ) -> ClearFrom<'r, Self, B>
where Self: Sized,

Returns a slice to a bitmap where each bit is set to self & !other.
§

fn iter_one_indices(&self) -> impl Iterator<Item = usize> + '_

Iterates over all indices in the bitmap that are set to one.
§

fn iter(&self) -> impl Iterator<Item = bool> + '_

Iterates over all bits in the bitmap.
§

fn count_ones(&self) -> usize

Counts the number of bits that are one.
§

fn count_zeros(&self) -> usize

Counts the number of bits that are zero.
§

impl BitmapSliceMut for &mut GrowingBitmap

§

fn modify(&mut self, f: impl FnMut(u64) -> u64)

Modifies the backing data according to f.
§

fn clear(&mut self)

Sets all bits in the bitmap to 0.
§

fn copy_from(&mut self, other: &impl BitmapSlice)

Overwrites all bits in the bitmap with bits from other. Read more
§

fn clear_from(&mut self, other: &impl BitmapSlice)

ANDs each bit in the bitmap with !other. Read more
§

fn or_with(&mut self, other: &impl BitmapSlice)

ORs each bit in the bitmap with other. Read more
§

impl BitmapSliceMut for GrowingBitmap

§

fn modify(&mut self, f: impl FnMut(u64) -> u64)

Modifies the backing data according to f.
§

fn clear(&mut self)

Sets all bits in the bitmap to 0.
§

fn copy_from(&mut self, other: &impl BitmapSlice)

Overwrites all bits in the bitmap with bits from other. Read more
§

fn clear_from(&mut self, other: &impl BitmapSlice)

ANDs each bit in the bitmap with !other. Read more
§

fn or_with(&mut self, other: &impl BitmapSlice)

ORs each bit in the bitmap with other. Read more
§

impl Clone for GrowingBitmap

§

fn clone(&self) -> Self

Returns a copy of the value. Read more
§

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

Performs copy-assignment from source. Read more
§

impl Debug for GrowingBitmap

§

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

Formats the value using the given formatter. Read more
§

impl Default for GrowingBitmap

§

fn default() -> GrowingBitmap

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

impl FromIterator<bool> for GrowingBitmap

§

fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self

Creates a value from an iterator. Read more
§

impl Hash for GrowingBitmap

§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<'a> Index<&'a usize> for GrowingBitmap

§

type Output = bool

The returned type after indexing.
§

fn index(&self, index: &'a usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
§

impl Index<usize> for GrowingBitmap

§

type Output = bool

The returned type after indexing.
§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
§

impl PartialEq for GrowingBitmap

§

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.
§

impl<const N: usize> TryFrom<&GrowingBitmap> for FixedBitmapU64<N>

§

type Error = ()

The type returned in the event of a conversion error.
§

fn try_from(value: &GrowingBitmap) -> Result<Self, Self::Error>

Performs the conversion.
§

impl Eq for GrowingBitmap

Auto Trait Implementations§

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 T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V