/// Return a set of the indices reachable from a candidate starting point
/// and for which the given predicate is valid. This can be used for example
/// to implement a flood-filling algorithm. Since the indices are collected
/// into a vector, they can later be used without keeping a reference on the
/// matrix itself, e.g., to modify the matrix.
Return a set of the indices reachable from a candidate starting point
and for which the given predicate is valid. This can be used for example
to implement a flood-filling algorithm. Since the indices are collected
into a vector, they can later be used without keeping a reference on the
matrix itself, e.g., to modify the matrix.
Return a set of the indices reachable from a candidate starting point and for which the given predicate is valid . This can be used for example to implement a flood - filling algorithm . Since the indices are collected into a vector they can later be used without keeping a reference on the matrix itself e . g . to modify the matrix .
pub fn reachable<P>(
        &self,
        start: (usize, usize),
        diagonals: bool,
        mut predicate: P,
    ) -> BTreeSet<(usize, usize)>
    where
        P: FnMut((usize, usize)) -> bool + Copy,
    {
        bfs_reach(start, |&n| {
            self.neighbours(n, diagonals).filter(move |&n| predicate(n))
        })
        .collect()
    }
pub fn reachable < P > ( & self , start : ( usize , usize ) , diagonals : bool , mut predicate : P , ) -> BTreeSet < ( usize , usize ) > where P : FnMut ( ( usize , usize ) ) -> bool + Copy , { bfs_reach ( start , | & n | { self . neighbours ( n , diagonals ) . filter ( move | & n | predicate ( n ) ) } ) . collect ( ) }
Return a set of the indices reachable from a candidate starting point
and for which the given predicate is valid.
Return a set of the indices reachable from a candidate starting point and for which the given predicate is valid .
&self
start
(usize, usize)
diagonals
bool
predicate
P