Struct pathfinder::Network

source ·
pub struct Network<T: Draw + Hash + Copy> {
    pub hash_map: [Option<T>; 666],
}

Fields§

§hash_map: [Option<T>; 666]

Implementations§

Calculates the path from node A to node B.

Examples
use pathfinder::{Coordinate, Network, Node};
let b = Node::new("B", Coordinate::new(20, 20));
let mut a = Node::new("A", Coordinate::new(0, 0));
a.link(&b);
let path = Network::new(vec![a, b]).path("A", "B");
assert_eq!(path, vec!(b, a));
use pathfinder::{Coordinate, Network, Node};
let nodes = Node::from_list(&[(0, 0), (10, 10), (20, 20), (30, 30)]);
let mut nodes = Node::linked_list(nodes);
let path = Network::new(nodes).path("D", "A");
assert_eq!(path.len(), 4);
for i in 0..path.len() {
    assert_eq!(path[i].geo.x, i as i16 * 10);
}

Returns if the given hash exists in the network.

Examples
use pathfinder::{Coordinate, Network, Node};
let nodes = Node::from_list(&[(0, 0), (10, 10), (20, 20), (30, 30), (40, 40)]);
let network = Network::new(nodes.clone());
assert!(network.get("A").is_some());
assert!(network.get("E").is_some());
assert!(network.get("F").is_none());

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Sets value as a parameter of self.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.