pub trait Map<T>: Default {
type Key: Copy + Eq + Debug;
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.