[][src]Struct hierarchical_pathfinding::generics::Path

pub struct Path<P> { /* fields omitted */ }

A generic implementation of a Path

Stores a sequence of Nodes and the total Cost of traversing these Nodes. Note that the individual costs of the steps within the Path cannot be retrieved through this struct.

This struct does not own the actual Path, it merely keeps an [Rc] to it. This makes cloning and reversing very efficient, but makes them immutable and limits some ways to access the contents

Implementations

impl<P> Path<P>[src]

pub fn new(path: Vec<P>, cost: Cost) -> Path<P>[src]

creates a new Path with the given sequence of Nodes and total Cost

Examples

Basic usage:

let path = Path::new(vec!['a', 'b', 'c'], 42);

assert_eq!(path, vec!['a', 'b', 'c']);
assert_eq!(path.cost(), 42);

pub fn from_slice(path: &[P], cost: Cost) -> Path<P> where
    P: Clone
[src]

creates a new Path with the given sequence of Nodes and total Cost

Examples

Basic usage:

let path = Path::from_slice(&['a', 'b', 'c'], 42);

assert_eq!(path, vec!['a', 'b', 'c']);
assert_eq!(path.cost(), 42);

pub fn cost(&self) -> Cost[src]

Returns the Cost of the Path

pub fn len(&self) -> usize[src]

Returns the length of the Path

pub fn is_empty(&self) -> bool[src]

Returns if the Path is empty

pub fn reversed(&self, start_cost: Cost, end_cost: Cost) -> Path<P> where
    P: Clone
[src]

Returns a reversed version of the Path.

start_cost is what need to be subtracted, and end_cost is what needs to be added to the cost in the case of asymmetric paths. Can be set to 0 for symmetric paths.

This operation is low cost since Paths are based on [Rc]s.

Examples

Basic usage:

let path = Path::new(vec!['a', 'b', 'c'], 42);
let reversed = path.reversed(5, 2);

assert_eq!(reversed, vec!['c', 'b', 'a']);
assert_eq!(reversed.cost(), 39);

pub fn iter(&self) -> Iter<'_, P>[src]

Returns an Iterator over the Path

pub fn as_vec(&self) -> Vec<P> where
    P: Clone
[src]

Extracts a Vec from the Path, cloning the data

Trait Implementations

impl<P: Clone> Clone for Path<P>[src]

impl<P: Debug> Debug for Path<P>[src]

impl<P: Display> Display for Path<P>[src]

impl<P: Eq> Eq for Path<P>[src]

impl<P> Index<usize> for Path<P>[src]

type Output = P

The returned type after indexing.

impl<P: Eq> Ord for Path<P>[src]

impl<'a, P: PartialEq> PartialEq<&'a [P]> for Path<P>[src]

impl<P: PartialEq> PartialEq<Path<P>> for Path<P>[src]

impl<P: PartialEq> PartialEq<Vec<P>> for Path<P>[src]

impl<P: PartialEq> PartialOrd<Path<P>> for Path<P>[src]

impl<P> StructuralEq for Path<P>[src]

impl<P> StructuralPartialEq for Path<P>[src]

Auto Trait Implementations

impl<P> RefUnwindSafe for Path<P> where
    P: RefUnwindSafe

impl<P> Send for Path<P> where
    P: Send + Sync

impl<P> Sync for Path<P> where
    P: Send + Sync

impl<P> Unpin for Path<P>

impl<P> UnwindSafe for Path<P> where
    P: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.