[][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

Methods

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 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 Rcs.

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]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Returns max if self is greater than max, and min if self is less than min. Otherwise this will return self. Panics if min > max. Read more

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: Debug> Debug for Path<P>[src]

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

Auto Trait Implementations

impl<P> !Send for Path<P>

impl<P> !Sync for Path<P>

Blanket Implementations

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

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

impl<T> From for T[src]

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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