Struct sqrid::base::Sqrid

source ·
pub struct Sqrid<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> {}
Expand description

Sqrid base “factory” type

This struct holds all the generic const parameters required by the other structs. This can be aliased and used as a pseudo-module to ease the creation of the other entites and use of algorithms like BFS.

Implementations§

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub const WIDTH: u16 = W

Width of the grid: exclusive max of the x coordinate.

source

pub const HEIGHT: u16 = H

Height of the grid: exclusive max of the y coordinate.

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub fn camefrom_into_path<MapPosDir>( map: MapPosDir, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where MapPosDir: MapPos<Option<Dir>, W, H, WORDS, SIZE>,

TODO

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub fn astar_path<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Perform an A* search; see astar

source

pub fn astar_path_grid<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Perform an A* search using a Grid internally; see astar

source

pub fn astar_path_hash<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Perform an A* search using a HashMap internally; see astar

source

pub fn astar_path_btree<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Perform an A* search using a BTreeMap internally; see astar

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub fn bf_iter<GoFn>( go: GoFn, orig: &Pos<W, H> ) -> BfIterator<GoFn, Gridbool<W, H, WORDS>, W, H, D, WORDS, SIZE>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Create new breadth-first iterator; see bf

source

pub fn bf_iter_grid<GoFn>( go: GoFn, orig: &Pos<W, H> ) -> BfIterator<GoFn, Gridbool<W, H, WORDS>, W, H, D, WORDS, SIZE>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Create new breadth-first iterator using Grid/Gridbool internally; see bf

source

pub fn bf_iter_hash<GoFn>( go: GoFn, orig: &Pos<W, H> ) -> BfIterator<GoFn, HashSet<Pos<W, H>>, W, H, D, WORDS, SIZE>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Create new breadth-first iterator using the HashMap]/HashSet] types internally; see bf

source

pub fn bf_iter_btree<GoFn>( go: GoFn, orig: &Pos<W, H> ) -> BfIterator<GoFn, BTreeSet<Pos<W, H>>, W, H, D, WORDS, SIZE>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>,

Create new breadth-first iterator using the BTreeMap/BTreeSet types internally; see bf

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub fn bfs_path<GoFn, FoundFn>( go: GoFn, orig: &Pos<W, H>, found: FoundFn ) -> Result<(Pos<W, H>, Vec<Dir>), Error>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>, FoundFn: Fn(Pos<W, H>) -> bool,

Perform a breadth-first search; see bf

source

pub fn bfs_path_grid<GoFn, FoundFn>( go: GoFn, orig: &Pos<W, H>, found: FoundFn ) -> Result<(Pos<W, H>, Vec<Dir>), Error>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>, FoundFn: Fn(Pos<W, H>) -> bool,

Perform a breadth-first search using a Grid internally; see bf

source

pub fn bfs_path_hash<GoFn, FoundFn>( go: GoFn, orig: &Pos<W, H>, found: FoundFn ) -> Result<(Pos<W, H>, Vec<Dir>), Error>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>, FoundFn: Fn(Pos<W, H>) -> bool,

Perform a breadth-first search using the HashMap/HashSet types internally; see bf

source

pub fn bfs_path_btree<GoFn, FoundFn>( go: GoFn, orig: &Pos<W, H>, found: FoundFn ) -> Result<(Pos<W, H>, Vec<Dir>), Error>
where GoFn: Fn(Pos<W, H>, Dir) -> Option<Pos<W, H>>, FoundFn: Fn(Pos<W, H>) -> bool,

Perform a breadth-first search using the HashMap/HashSet types internally; see bf

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sqrid<W, H, D, WORDS, SIZE>

source

pub fn ucs_path<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<(Pos<W, H>, Cost)>,

Perform a uniform-cost search; see ucs.

source

pub fn ucs_path_grid<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<(Pos<W, H>, Cost)>,

Perform a uniform-cost search using a Grid internally; see ucs.

source

pub fn ucs_path_hash<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<(Pos<W, H>, Cost)>,

Perform a uniform-cost search using a HashMap internally; see ucs.

source

pub fn ucs_path_btree<F>( go: F, orig: &Pos<W, H>, dest: &Pos<W, H> ) -> Result<Vec<Dir>, Error>
where F: Fn(Pos<W, H>, Dir) -> Option<(Pos<W, H>, Cost)>,

Perform a uniform-cost search using a BTreeMap internally; see ucs.

Trait Implementations§

source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Clone for Sqrid<W, H, D, WORDS, SIZE>

source§

fn clone(&self) -> Sqrid<W, H, D, WORDS, SIZE>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Debug for Sqrid<W, H, D, WORDS, SIZE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Default for Sqrid<W, H, D, WORDS, SIZE>

source§

fn default() -> Sqrid<W, H, D, WORDS, SIZE>

Returns the “default value” for a type. Read more
source§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Copy for Sqrid<W, H, D, WORDS, SIZE>

Auto Trait Implementations§

§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> RefUnwindSafe for Sqrid<W, H, D, WORDS, SIZE>

§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Send for Sqrid<W, H, D, WORDS, SIZE>

§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Sync for Sqrid<W, H, D, WORDS, SIZE>

§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> Unpin for Sqrid<W, H, D, WORDS, SIZE>

§

impl<const W: u16, const H: u16, const D: bool, const WORDS: usize, const SIZE: usize> UnwindSafe for Sqrid<W, H, D, WORDS, SIZE>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.