Struct pi_path_finding::AStar

source ·
pub struct AStar<N: PartialOrd + Zero + Copy + Debug, E: NodeEntry<N> + Default> { /* private fields */ }
Expand description

A* 寻路的堆

N的约束,数字集合

  • 算术运算,可拷贝,可偏序比较;
  • 实际使用的时候就是数字类型,比如:i8/u8/i32/u32/f32/f64;

Implementations§

source§

impl<N: PartialOrd + Zero + Copy + Debug, E: NodeEntry<N> + Default> AStar<N, E>

source

pub fn with_capacity(map_capacity: usize, node_number: usize) -> Self

实例化A寻路算法的结构体 必须传入最大可能的全图节点容量,可选传入调用A算法时可能搜索的节点数量以提前初始化节约性能,但也可为0

source

pub fn resize(&mut self, map_capacity: usize)

重新设置地图节点数组的大小

source

pub fn find<Arg>( &mut self, start: NodeIndex, end: NodeIndex, max_number: usize, arg: &mut Arg, make_neighbors: fn(_: &mut Arg, _: NodeIndex, _: NodeIndex, _: &mut Finder<N, E>) -> NodeNeighbors<N> ) -> AStarResult

从起点向终点的A寻路算法 给定一组代表全图的通用节点nodes,以及寻路的起始节点在nodes的索引start 和目的节点在nodes索引end进行A 寻路; 如果 寻路到终点 或 寻路的结果节点数目超过max_number,则终止寻路并返回结果;

返回结果:是否成功寻路至目标点

大概流程:

    1. 创建起点的节点邻居nn。
  • 2、弹出nn中的最优邻居节点node,判断是否到达,如果没有到达,则获取该node的节点邻居nn1,如果open表不为空,从表头取最优的节点邻居nn2,比较nn2、nn1和nn,选择放入nn1或nn, 获得最优的新的nn。 重复该步骤2。

  • 3、如果open表为空,则返回NotFound。

source

pub fn result_iter<'a>(&'a self, node: NodeIndex) -> ResultIterator<'a, N, E>

返回结果的迭代器

Auto Trait Implementations§

§

impl<N, E> RefUnwindSafe for AStar<N, E>where E: RefUnwindSafe, N: RefUnwindSafe,

§

impl<N, E> Send for AStar<N, E>where E: Send, N: Send,

§

impl<N, E> Sync for AStar<N, E>where E: Sync, N: Sync,

§

impl<N, E> Unpin for AStar<N, E>where E: Unpin, N: Unpin,

§

impl<N, E> UnwindSafe for AStar<N, E>where E: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.