Skip to main content

DistanceMap

Trait DistanceMap 

Source
pub trait DistanceMap<K> {
    // Required methods
    fn get(&self, node: NodeId) -> Option<&K>;
    fn insert(&mut self, node: NodeId, dist: K);

    // Provided method
    fn contains(&self, node: NodeId) -> bool { ... }
}
Expand description

A map from nodes to distances/costs.

This trait abstracts over different distance map implementations, allowing algorithms to work with various storage strategies.

Required Methods§

Source

fn get(&self, node: NodeId) -> Option<&K>

Gets the distance to a node, if known.

Source

fn insert(&mut self, node: NodeId, dist: K)

Sets the distance to a node.

Provided Methods§

Source

fn contains(&self, node: NodeId) -> bool

Returns true if the node has a recorded distance.

Implementations on Foreign Types§

Source§

impl<K> DistanceMap<K> for HashMap<NodeId, K>

Source§

fn get(&self, node: NodeId) -> Option<&K>

Source§

fn insert(&mut self, node: NodeId, dist: K)

Implementors§