Skip to main content

Array256

Struct Array256 

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

Source

pub const EMPTY: Self

The empty array.

Source§

impl<S> Array256<S>
where S: ArrayStorage,

Source

pub fn test(&self, index: u8) -> bool

Check if the specified index is occupied.

Source

pub fn intersects(&self, other: &Bitset256) -> bool

Check whether this array’s occupancy intersects with the given bitset.

Source

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.

Source

pub const fn is_empty(&self) -> bool

Return whether this array has no elements.

Source

pub fn len(&self) -> usize
where S: AsRef<[S::T]>,

Get the number of items in this array.

Source

pub fn get(&self, index: u8) -> Option<&S::T>
where S: AsRef<[S::T]>,

Get a reference to the element at the specified index, if there is one.

Source

pub fn get_mut(&mut self, index: u8) -> Option<&mut S::T>
where S: AsMut<[S::T]>,

Get a mutable reference to the element at the specified index, if there is one.

Source

pub fn insert(&mut self, index: u8, element: S::T) -> Option<S::T>
where S: AsMut<[S::T]>,

Insert an item at the specified index. Returns the previous occupant if there was one.

Source

pub fn remove(&mut self, index: u8) -> Option<S::T>
where S: AsRef<[S::T]>,

Remove an item by index.

Source

pub fn clear(&mut self)

Clear the array.

Source

pub const fn bitset(&self) -> &Bitset256

Get a reference to the internal Bitset256 which stores the occupied storage indices.

Source

pub fn iter(&self) -> impl Iterator<Item = (u8, &S::T)>
where S: AsRef<[S::T]>,

Iterate over all occupied entries in the array.

Source

pub fn iter_after(&self, n: u8) -> impl Iterator<Item = (u8, &S::T)>
where S: AsRef<[S::T]>,

Iterate over occupied entries in the array starting after index n.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (u8, &mut S::T)>
where S: AsMut<[S::T]>,

Iterate over mutable references to all occupied entries in the array.

Source

pub fn custom_storage_fmt<'slf, 'f, U>( &'slf self, f: &'f dyn Fn(&'slf S::T) -> U, ) -> impl Debug + 'slf
where U: Debug + 'slf, S: AsRef<[S::T]>, 'f: 'slf,

Provide a Debug instance for this value when T is not necessarily Debug.

Source

pub fn clone_with(&self, f: &dyn Fn(&S::T) -> S::T) -> Self
where S: FromIterator<S::T> + AsRef<[S::T]>,

Clone self with a custom function supporting clone of &T.

Trait Implementations§

Source§

impl<S: Clone> Clone for Array256<S>

Source§

fn clone(&self) -> Array256<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for Array256<S>
where S: ArrayStorage + AsRef<[S::T]>, S::T: Debug,

Source§

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

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

impl<S> Default for Array256<S>
where S: Default,

Source§

fn default() -> Self

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

impl<S> FromIterator<(u8, <S as ArrayStorage>::T)> for Array256<S>
where S: ConstEmptyArrayStorage + AsMut<[S::T]>,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (u8, S::T)>,

Creates a value from an iterator. Read more
Source§

impl<S: Hash> Hash for Array256<S>

Source§

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

impl<S> Index<u8> for Array256<S>
where S: ArrayStorage + AsRef<[S::T]>,

Source§

type Output = <S as ArrayStorage>::T

The returned type after indexing.
Source§

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

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

impl<S> IndexMut<u8> for Array256<S>
where S: ArrayStorage + AsRef<[S::T]> + AsMut<[S::T]>,

Source§

fn index_mut(&mut self, index: u8) -> &mut Self::Output

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

impl<S: PartialEq> PartialEq for Array256<S>

Source§

fn eq(&self, other: &Array256<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<S: Eq> Eq for Array256<S>

Source§

impl<S> StructuralPartialEq for Array256<S>

Auto Trait Implementations§

§

impl<S> Freeze for Array256<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Array256<S>
where S: RefUnwindSafe,

§

impl<S> Send for Array256<S>
where S: Send,

§

impl<S> Sync for Array256<S>
where S: Sync,

§

impl<S> Unpin for Array256<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Array256<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Array256<S>
where S: 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, dest: *mut u8)

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