pub struct MappingDict<V: Mappable> { /* private fields */ }
Expand description
A map comparable to a HashMap
which contains items that are Mappable
.
The map keeps track of the mapping between both the external type and Matrix type and an
object.
Implementations§
Source§impl<V> MappingDict<V>where
V: Mappable,
impl<V> MappingDict<V>where
V: Mappable,
Sourcepub fn from_vec(items: Vec<V>) -> Self
pub fn from_vec(items: Vec<V>) -> Self
Create a new MappingDict
consuming the given Vec
of items.
All items are put into the newly created map.
This is more efficient than just calling insert
yourself on an empty map, since this
method will initialize the vector and hashmap with a starting capacpity, thus resulting in
less allocations.
Sourcepub fn insert(&mut self, item: V) -> &mut V
pub fn insert(&mut self, item: V) -> &mut V
Inserts the given item
in the current MappingDict
.
Allocates if neccesary.
Returns a mutable reference to the newly inserted item.
Sourcepub fn get(
&self,
identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>,
) -> Option<&V>
pub fn get( &self, identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>, ) -> Option<&V>
Returns a reference to the item associated with the given identifier
, or None
if no
such item exists.
Sourcepub fn get_mut(
&mut self,
identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>,
) -> Option<&mut V>
pub fn get_mut( &mut self, identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>, ) -> Option<&mut V>
Returns a mutable reference to the item associated with the given identifier
, or None
if no such item exists.
Sourcepub fn has(
&self,
identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>,
) -> bool
pub fn has( &self, identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>, ) -> bool
Returns whether or not this MappingDict
contains an item associated with the given
identifier
.
Sourcepub fn remove(
&mut self,
identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>,
) -> Option<V>
pub fn remove( &mut self, identifier: MappingId<'_, V::ExternalReference, V::MatrixReference>, ) -> Option<V>
If this MappingDict
contains an item associated with the given identifier
, remove it
and return the value that was contained in the MappingDict
.
If no such item exists, this function returns None
.
Sourcepub fn iter(&self) -> Iter<'_, V>
pub fn iter(&self) -> Iter<'_, V>
Get an iterator over references of the items contained in this MappingDict
.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, V>
pub fn iter_mut(&mut self) -> IterMut<'_, V>
Get an iterator over mutable references of the items contained in this MappingDict
.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.
Trait Implementations§
Source§impl<V: Clone + Mappable> Clone for MappingDict<V>
impl<V: Clone + Mappable> Clone for MappingDict<V>
Source§fn clone(&self) -> MappingDict<V>
fn clone(&self) -> MappingDict<V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more