Trait DistanceMap

Source
pub trait DistanceMap<K, V> {
    // Required methods
    fn build(num_elements: usize) -> Self;
    fn get_item(&self, pos: K) -> Option<&V>;
    fn put_item(&mut self, pos: K, val: V);
}
Expand description

A mapping for storing the distances of nodes for shortest path algorithms.

Required Methods§

Source

fn build(num_elements: usize) -> Self

Create mapping with support for items between 0 and num_elements - 1.

Source

fn get_item(&self, pos: K) -> Option<&V>

Get the distance to the item at pos. If the distance does not exist, the function returns None.

Source

fn put_item(&mut self, pos: K, val: V)

Insert item at position pos with distance V.

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: Eq + Hash, V: Clone> DistanceMap<K, V> for HashMap<K, V>

Source§

fn build(_num_elements: usize) -> Self

Source§

fn get_item(&self, pos: K) -> Option<&V>

Source§

fn put_item(&mut self, pos: K, val: V)

Source§

impl<K: IndexType, V: Clone> DistanceMap<K, V> for Vec<Option<V>>

Source§

fn build(num_elements: usize) -> Self

Source§

fn get_item(&self, pos: K) -> Option<&V>

Source§

fn put_item(&mut self, pos: K, val: V)

Implementors§

Source§

impl<K: Eq + Hash, V: Clone> DistanceMap<K, V> for DictMap<K, V>