pub trait Map<T>: Default {
type Key: Copy + Eq + Debug + 'static;
type Iter<'a>: Iterator<Item = (Self::Key, &'a T)>
where Self: 'a,
T: 'a;
type IterMut<'a>: Iterator<Item = (Self::Key, &'a mut T)>
where Self: 'a,
T: 'a;
// Required methods
fn len(&self) -> usize;
fn get(&self, index: Self::Key) -> Option<&T>;
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>;
fn remove(&mut self, index: Self::Key) -> Option<T>;
fn clear(&mut self);
fn iter(&self) -> Self::Iter<'_>;
fn iter_mut(&mut self) -> Self::IterMut<'_>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn contains_key(&self, index: Self::Key) -> bool { ... }
}Expand description
A trait for a generic map that can be used as a node or an edge map in a
Graph.
Required Associated Types§
Required Methods§
Sourcefn get(&self, index: Self::Key) -> Option<&T>
fn get(&self, index: Self::Key) -> Option<&T>
Returns an immutable reference to a value by its key or None in case the key is
not present in the map.
Sourcefn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
Returns a mutable reference to a value by its key or None in case the key is not
present in the map.
Provided Methods§
Sourcefn contains_key(&self, index: Self::Key) -> bool
fn contains_key(&self, index: Self::Key) -> bool
Returns true if a map contains the specified key.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<K, T, S> Map<T> for HashMap<K, T, S>
Available on crate features std or indexmap only.
impl<K, T, S> Map<T> for HashMap<K, T, S>
Available on crate features
std or indexmap only.type Key = K
type Iter<'a> = Map<Iter<'a, K, T>, fn((&'a K, &'a T)) -> (K, &'a T)> where Self: 'a, T: 'a
type IterMut<'a> = Map<IterMut<'a, K, T>, fn((&'a K, &'a mut T)) -> (K, &'a mut T)> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, index: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K, T, S> Map<T> for IndexMap<K, T, S>
Available on crate features std or indexmap only.
impl<K, T, S> Map<T> for IndexMap<K, T, S>
Available on crate features
std or indexmap only.type Key = K
type Iter<'a> = Map<Iter<'a, K, T>, fn((&'a K, &'a T)) -> (K, &'a T)> where Self: 'a, T: 'a
type IterMut<'a> = Map<IterMut<'a, K, T>, fn((&'a K, &'a mut T)) -> (K, &'a mut T)> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, index: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Copy + Eq + Ord + Debug + 'static, T> Map<T> for BTreeMap<K, T>
Available on crate feature alloc only.
impl<K: Copy + Eq + Ord + Debug + 'static, T> Map<T> for BTreeMap<K, T>
Available on crate feature
alloc only.type Key = K
type Iter<'a> = Map<Iter<'a, K, T>, fn((&'a K, &'a T)) -> (K, &'a T)> where Self: 'a, T: 'a
type IterMut<'a> = Map<IterMut<'a, K, T>, fn((&'a K, &'a mut T)) -> (K, &'a mut T)> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, index: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Key + 'static, T> Map<T> for SlotMap<K, T>
Available on crate feature slotmap only.
impl<K: Key + 'static, T> Map<T> for SlotMap<K, T>
Available on crate feature
slotmap only.type Key = K
type Iter<'a> = Iter<'a, K, T> where Self: 'a, T: 'a
type IterMut<'a> = IterMut<'a, K, T> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, key: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Key + 'static, T> Map<T> for DenseSlotMap<K, T>
Available on crate feature slotmap only.
impl<K: Key + 'static, T> Map<T> for DenseSlotMap<K, T>
Available on crate feature
slotmap only.type Key = K
type Iter<'a> = Iter<'a, K, T> where Self: 'a, T: 'a
type IterMut<'a> = IterMut<'a, K, T> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, key: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Key + 'static, T> Map<T> for HopSlotMap<K, T>
Available on crate feature slotmap only.
impl<K: Key + 'static, T> Map<T> for HopSlotMap<K, T>
Available on crate feature
slotmap only.type Key = K
type Iter<'a> = Iter<'a, K, T> where Self: 'a, T: 'a
type IterMut<'a> = IterMut<'a, K, T> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, key: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Key + 'static, T> Map<T> for SecondaryMap<K, T>
Available on crate feature slotmap only.
impl<K: Key + 'static, T> Map<T> for SecondaryMap<K, T>
Available on crate feature
slotmap only.type Key = K
type Iter<'a> = Iter<'a, K, T> where Self: 'a, T: 'a
type IterMut<'a> = IterMut<'a, K, T> where Self: 'a, T: 'a
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn contains_key(&self, index: Self::Key) -> bool
fn get(&self, index: Self::Key) -> Option<&T>
fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>
fn remove(&mut self, index: Self::Key) -> Option<T>
fn clear(&mut self)
fn iter(&self) -> Self::Iter<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
Source§impl<K: Key + 'static, T> Map<T> for SparseSecondaryMap<K, T>
Available on crate feature slotmap only.
impl<K: Key + 'static, T> Map<T> for SparseSecondaryMap<K, T>
Available on crate feature
slotmap only.