Struct la_arena::ArenaMap

source ·
pub struct ArenaMap<IDX, V> { /* private fields */ }
Expand description

A map from arena indexes to some other type. Space requirement is O(highest index).

Implementations§

source§

impl<T, V> ArenaMap<Idx<T>, V>

source

pub const fn new() -> Self

Creates a new empty map.

source

pub fn with_capacity(capacity: usize) -> Self

Create a new empty map with specific capacity.

source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the map.

source

pub fn clear(&mut self)

Clears the map, removing all elements.

source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the map as much as possible.

source

pub fn contains_idx(&self, idx: Idx<T>) -> bool

Returns whether the map contains a value for the specified index.

source

pub fn remove(&mut self, idx: Idx<T>) -> Option<V>

Removes an index from the map, returning the value at the index if the index was previously in the map.

source

pub fn insert(&mut self, idx: Idx<T>, t: V) -> Option<V>

Inserts a value associated with a given arena index into the map.

If the map did not have this index present, None is returned. Otherwise, the value is updated, and the old value is returned.

source

pub fn get(&self, idx: Idx<T>) -> Option<&V>

Returns a reference to the value associated with the provided index if it is present.

source

pub fn get_mut(&mut self, idx: Idx<T>) -> Option<&mut V>

Returns a mutable reference to the value associated with the provided index if it is present.

source

pub fn values(&self) -> impl Iterator<Item = &V> + DoubleEndedIterator

Returns an iterator over the values in the map.

source

pub fn values_mut( &mut self ) -> impl Iterator<Item = &mut V> + DoubleEndedIterator

Returns an iterator over mutable references to the values in the map.

source

pub fn iter(&self) -> impl Iterator<Item = (Idx<T>, &V)> + DoubleEndedIterator

Returns an iterator over the arena indexes and values in the map.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (Idx<T>, &mut V)>

Returns an iterator over the arena indexes and values in the map.

source

pub fn entry(&mut self, idx: Idx<T>) -> Entry<'_, Idx<T>, V>

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

Trait Implementations§

source§

impl<IDX: Clone, V: Clone> Clone for ArenaMap<IDX, V>

source§

fn clone(&self) -> ArenaMap<IDX, V>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<IDX: Debug, V: Debug> Debug for ArenaMap<IDX, V>

source§

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

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

impl<T, V> Default for ArenaMap<Idx<V>, T>

source§

fn default() -> Self

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

impl<T, V> Extend<(Idx<V>, T)> for ArenaMap<Idx<V>, T>

source§

fn extend<I: IntoIterator<Item = (Idx<V>, T)>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T, V> FromIterator<(Idx<V>, T)> for ArenaMap<Idx<V>, T>

source§

fn from_iter<I: IntoIterator<Item = (Idx<V>, T)>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<IDX: Hash, V: Hash> Hash for ArenaMap<IDX, V>

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<T, V> Index<Idx<V>> for ArenaMap<Idx<V>, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, idx: Idx<V>) -> &T

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

impl<T, V> IndexMut<Idx<V>> for ArenaMap<Idx<V>, T>

source§

fn index_mut(&mut self, idx: Idx<V>) -> &mut T

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

impl<T, V> IntoIterator for ArenaMap<Idx<T>, V>

§

type Item = (Idx<T>, V)

The type of the elements being iterated over.
§

type IntoIter = ArenaMapIter<Idx<T>, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<IDX: Ord, V: Ord> Ord for ArenaMap<IDX, V>

source§

fn cmp(&self, other: &ArenaMap<IDX, V>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<IDX: PartialEq, V: PartialEq> PartialEq<ArenaMap<IDX, V>> for ArenaMap<IDX, V>

source§

fn eq(&self, other: &ArenaMap<IDX, V>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<IDX: PartialOrd, V: PartialOrd> PartialOrd<ArenaMap<IDX, V>> for ArenaMap<IDX, V>

source§

fn partial_cmp(&self, other: &ArenaMap<IDX, V>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<IDX: Eq, V: Eq> Eq for ArenaMap<IDX, V>

source§

impl<IDX, V> StructuralEq for ArenaMap<IDX, V>

source§

impl<IDX, V> StructuralPartialEq for ArenaMap<IDX, V>

Auto Trait Implementations§

§

impl<IDX, V> RefUnwindSafe for ArenaMap<IDX, V>where IDX: RefUnwindSafe, V: RefUnwindSafe,

§

impl<IDX, V> Send for ArenaMap<IDX, V>where IDX: Send, V: Send,

§

impl<IDX, V> Sync for ArenaMap<IDX, V>where IDX: Sync, V: Sync,

§

impl<IDX, V> Unpin for ArenaMap<IDX, V>where IDX: Unpin, V: Unpin,

§

impl<IDX, V> UnwindSafe for ArenaMap<IDX, V>where IDX: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.