Trait mapgraph::map::Map

source ·
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§

source

type Key: Copy + Eq + Debug

The type of key used by the map.

source

type Iter<'a>: Iterator<Item = (Self::Key, &'a T)> where Self: 'a, T: 'a

The type for an immutable iterator over the nodes in the map.

source

type IterMut<'a>: Iterator<Item = (Self::Key, &'a mut T)> where Self: 'a, T: 'a

The type for a mutable iterator over the nodes in the map.

Required Methods§

source

fn len(&self) -> usize

Returns the amount of nodes in the map.

source

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.

source

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.

source

fn remove(&mut self, index: Self::Key) -> Option<T>

Removes a value from a map by its key. Returns the removed value or None in case the key was not present in the map.

source

fn clear(&mut self)

Removes all the nodes from the map.

source

fn iter(&self) -> Self::Iter<'_>

Returns an immutable iterator over the nodes in a map.

source

fn iter_mut(&mut self) -> Self::IterMut<'_>

Returns a mutable iterator over the nodes in a map.

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if the map is empty.

source

fn contains_key(&self, index: Self::Key) -> bool

Returns true if a map contains the specified key.

Implementations on Foreign Types§

source§

impl<K: Copy + Eq + Ord + Debug, T> Map<T> for BTreeMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, index: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K, T, S> Map<T> for HashMap<K, T, S>where K: Copy + Eq + Hash + Debug, S: BuildHasher + Default,

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, index: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K: Key, T> Map<T> for SlotMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, key: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K: Key, T> Map<T> for HopSlotMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, key: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K: Key, T> Map<T> for DenseSlotMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, key: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K: Key, T> Map<T> for SecondaryMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, index: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

source§

impl<K: Key, T> Map<T> for SparseSecondaryMap<K, T>

§

type Key = K

§

type Iter<'a> where Self: 'a, T: 'a = Iter<'a, K, T>

§

type IterMut<'a> where Self: 'a, T: 'a = IterMut<'a, K, T>

source§

fn len(&self) -> usize

source§

fn is_empty(&self) -> bool

source§

fn contains_key(&self, index: Self::Key) -> bool

source§

fn get(&self, index: Self::Key) -> Option<&T>

source§

fn get_mut(&mut self, index: Self::Key) -> Option<&mut T>

source§

fn remove(&mut self, index: Self::Key) -> Option<T>

source§

fn clear(&mut self)

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

Implementors§