Skip to content

Commit

Permalink
mw_common/algo: FloodSelect conversion to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
inodentry committed Jan 2, 2024
1 parent 1ee05b4 commit 923d2ac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/mw_common/src/algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ use crate::grid::{Coord, Pos};
pub enum FloodSelect {
/// Tile does not qualify
No,
/// Do no more iterations
Abort,
/// Add tile to end of queue
Yes,
/// Add tile to start of queue (next tile to check)
YesPrio,
/// Do no more iterations
Abort,
}

/// Type of the queue data structure (re)used for `flood`
pub type FloodQ = std::collections::VecDeque<Pos>;

impl From<FloodSelect> for bool {
fn from(value: FloodSelect) -> Self {
match value {
FloodSelect::No | FloodSelect::Abort => false,
FloodSelect::Yes | FloodSelect::YesPrio => true,
}
}
}

/// Floodfill algorithm
///
/// Initialize `q` with starting tiles to expand from.
Expand Down

0 comments on commit 923d2ac

Please sign in to comment.