pub struct Maze { /* private fields */ }
Expand description
Data structure representing a maze on a grid.
stores each possible paths as a HashMap
mapping each positions to the accessible adjascent ones.
Implementations
sourceimpl Maze
impl Maze
sourcepub fn new(
width: isize,
height: isize,
start: Pos,
end: Pos,
paths_: Vec<(Pos, Vec<Pos>)>
) -> Self
pub fn new(
width: isize,
height: isize,
start: Pos,
end: Pos,
paths_: Vec<(Pos, Vec<Pos>)>
) -> Self
Constructor.
sourcepub fn is_start(&self, position: Pos) -> bool
pub fn is_start(&self, position: Pos) -> bool
Check if the provided position is the start of the Maze
.
sourcepub fn is_end(&self, position: Pos) -> bool
pub fn is_end(&self, position: Pos) -> bool
Check if the provided position is the end of the Maze
.
sourcepub fn paths_from(&self, position: Pos) -> &[Pos]
pub fn paths_from(&self, position: Pos) -> &[Pos]
Returns an array of all positions directly accessible from a position in the Maze
.
sourcepub fn is_inside(&self, position: Pos) -> bool
pub fn is_inside(&self, position: Pos) -> bool
Check if a position is included within the Maze
.
sourcepub fn adjascent(&self, position: Pos) -> Vec<Pos>
pub fn adjascent(&self, position: Pos) -> Vec<Pos>
Returns adjascent positions of position
that are included in the Maze
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Maze
impl Send for Maze
impl Sync for Maze
impl Unpin for Maze
impl UnwindSafe for Maze
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more