dense_map::collection

Struct DenseMapCollection

Source
pub struct DenseMapCollection<K: DenseMapCollectionKey, T> { /* private fields */ }
Expand description

A generic collection indexed by a DenseMapCollectionKey.

DenseMapCollection provides the same performance guarantees as DenseMap, but provides a two-level keying scheme that matches the pattern used in [crate::DeviceDense].

Implementations§

Source§

impl<K: DenseMapCollectionKey, T> DenseMapCollection<K, T>

Source

pub fn new() -> Self

Creates a new empty DenseMapCollection.

Source

pub fn is_empty(&self) -> bool

Returns true if the DenseMapCollection holds no items.

Source

pub fn get(&self, key: &K) -> Option<&T>

Returns a reference to the item indexed by key, or None if the key doesn’t exist.

Source

pub fn get_mut(&mut self, key: &K) -> Option<&mut T>

Returns a mutable reference to the item indexed by key, or None if the key doesn’t exist.

Source

pub fn remove(&mut self, key: &K) -> Option<T>

Removes item indexed by key from the container.

Returns the removed item if it exists, or None otherwise.

Source

pub fn insert(&mut self, key: &K, item: T) -> Option<T>

Inserts item at key.

If the DenseMapCollection already contained an item indexed by key, insert returns it, or None otherwise.

Source

pub fn iter(&self) -> impl ExactSizeIterator<Item = &T>

Creates an iterator over the containing items.

Source

pub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = &mut T>

Creates a mutable iterator over the containing items.

Source

pub fn iter_maps(&self) -> impl Iterator<Item = &DenseMap<T>>

Creates an iterator over the maps in variant order.

Source

pub fn entry(&mut self, key: K) -> Entry<'_, K, T>

Gets the given key’s corresponding entry in the map for in-place manipulation.

Source

pub fn push_entry( &mut self, make_key: fn(_: usize) -> K, value: T, ) -> OccupiedEntry<'_, K, T>

Inserts a new entry, constructing a key with the provided function.

§Panics

The make_key function must always construct keys of the same variant, otherwise this method will panic.

Trait Implementations§

Source§

impl<K: DenseMapCollectionKey, T> Default for DenseMapCollection<K, T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, T> Freeze for DenseMapCollection<K, T>

§

impl<K, T> RefUnwindSafe for DenseMapCollection<K, T>

§

impl<K, T> Send for DenseMapCollection<K, T>
where K: Send, T: Send,

§

impl<K, T> Sync for DenseMapCollection<K, T>
where K: Sync, T: Sync,

§

impl<K, T> Unpin for DenseMapCollection<K, T>
where K: Unpin, T: Unpin,

§

impl<K, T> UnwindSafe for DenseMapCollection<K, T>
where K: UnwindSafe, T: 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> 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, 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.