[−][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
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]
P: Clone,
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]
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]
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]
impl<P: Eq> Ord for Path<P>
[src]
fn cmp(&self, other: &Path<P>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[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]
fn partial_cmp(&self, other: &Path<P>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[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,
P: RefUnwindSafe,
impl<P> Send for Path<P> where
P: Send + Sync,
P: Send + Sync,
impl<P> Sync for Path<P> where
P: Send + Sync,
P: Send + Sync,
impl<P> Unpin for Path<P>
impl<P> UnwindSafe for Path<P> where
P: RefUnwindSafe,
P: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,