evenfurther / pathfinding

Pathfinding library for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Matrix: direction aware varient of neighbours method

cbrown1234 opened this issue · comments

Would it make sense to add to a direction aware version of Matrix::neighbours to this crate?

Along the lines of:

pub fn neighbours_enumerated_by_direction(
    &self,
    (r,c): (usize, usize),
    diagonals: bool,
) -> impl Iterator<Item = ((isize, isize), (usize, usize))>

Potentially it could be better if the directions were an enum.

My context for this is that I'm working on some flow field pathfinding algorithms in which it's required to keep track of the direction of minimum values of neighbours.

I'm not convinced this is general enough to make it a method. You can easily use the matrix::directions module to make such a function. However, if you find that you cannot do this efficiently unless this is a specialized method, I could reconsider this position.