pub struct Array256<S> { /* private fields */ }Expand description
A sparse array of 256 elements.
Indexed by Bitset256 and backed by a configurable ArrayStorage,
which is a contiguous chunk of memory holding up to 256 values.
Implementations§
Source§impl<S> Array256<S>where
S: ConstEmptyArrayStorage,
impl<S> Array256<S>where
S: ConstEmptyArrayStorage,
Source§impl<S> Array256<S>where
S: ArrayStorage,
impl<S> Array256<S>where
S: ArrayStorage,
Sourcepub fn intersects(&self, other: &Bitset256) -> bool
pub fn intersects(&self, other: &Bitset256) -> bool
Check whether this array’s occupancy intersects with the given bitset.
Sourcepub fn intersection_top(&self, other: &Bitset256) -> Option<u8>
pub fn intersection_top(&self, other: &Bitset256) -> Option<u8>
Check whether this array’s occupancy intersects with the given bitset, and if so, the highest set bit of that intersection.
Sourcepub fn get(&self, index: u8) -> Option<&S::T>
pub fn get(&self, index: u8) -> Option<&S::T>
Get a reference to the element at the specified index, if there is one.
Sourcepub fn get_mut(&mut self, index: u8) -> Option<&mut S::T>
pub fn get_mut(&mut self, index: u8) -> Option<&mut S::T>
Get a mutable reference to the element at the specified index, if there is one.
Sourcepub fn insert(&mut self, index: u8, element: S::T) -> Option<S::T>
pub fn insert(&mut self, index: u8, element: S::T) -> Option<S::T>
Insert an item at the specified index. Returns the previous occupant if there was one.
Sourcepub const fn bitset(&self) -> &Bitset256
pub const fn bitset(&self) -> &Bitset256
Get a reference to the internal Bitset256 which stores the occupied
storage indices.
Sourcepub fn iter(&self) -> impl Iterator<Item = (u8, &S::T)>
pub fn iter(&self) -> impl Iterator<Item = (u8, &S::T)>
Iterate over all occupied entries in the array.
Sourcepub fn iter_after(&self, n: u8) -> impl Iterator<Item = (u8, &S::T)>
pub fn iter_after(&self, n: u8) -> impl Iterator<Item = (u8, &S::T)>
Iterate over occupied entries in the array starting after index n.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (u8, &mut S::T)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (u8, &mut S::T)>
Iterate over mutable references to all occupied entries in the array.
Sourcepub fn custom_storage_fmt<'slf, 'f, U>(
&'slf self,
f: &'f dyn Fn(&'slf S::T) -> U,
) -> impl Debug + 'slf
pub fn custom_storage_fmt<'slf, 'f, U>( &'slf self, f: &'f dyn Fn(&'slf S::T) -> U, ) -> impl Debug + 'slf
Provide a Debug instance for this value when T is not necessarily
Debug.
Sourcepub fn clone_with(&self, f: &dyn Fn(&S::T) -> S::T) -> Self
pub fn clone_with(&self, f: &dyn Fn(&S::T) -> S::T) -> Self
Clone self with a custom function supporting clone of &T.