[−][src]Struct hierarchical_pathfinding::generics::Path
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]
P: Clone,
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]
P: Clone,
Extracts a Vec from the Path, cloning the data
Trait Implementations
impl<P: Clone> Clone for Path<P>
[src]
fn clone(&self) -> 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]
fn eq(&self, rhs: &Vec<P>) -> bool
[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]
fn partial_cmp(&self, other: &Path<P>) -> Option<Ordering>
[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 cmp(&self, other: &Path<P>) -> Ordering
[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]
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]
impl<P: Debug> Debug for Path<P>
[src]
impl<P: Display> Display for Path<P>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,