From 07567e4c8a7cad19815c93eeb046530eb613a8a3 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sun, 27 Nov 2022 11:01:31 -0800 Subject: [PATCH] queue --- 2018/15.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/2018/15.cpp b/2018/15.cpp index 601d79c..a11358e 100644 --- a/2018/15.cpp +++ b/2018/15.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include @@ -114,18 +114,18 @@ auto Game::Move(Coord my_coord, char my_team) -> std::optional Coord best_end; // initialized when best_start is non-empty int best_distance; // initialized when best_start is non-empty - std::deque> todo; + std::queue> todo; for (auto const dir : reading_order) { auto const start = my_coord + dir; if (grid_[start] == '.') { - todo.push_back({start, start, 1}); + todo.push({start, start, 1}); } } std::set seen; while (!todo.empty()) { auto const [start, cursor, steps] = todo.front(); - todo.pop_front(); + todo.pop(); if (best_start) { if (best_distance < steps) break; @@ -135,7 +135,7 @@ auto Game::Move(Coord my_coord, char my_team) -> std::optional for (auto const dir : reading_order) { auto const next = cursor + dir; if (grid_[next] == '.') { - todo.push_back({start, cursor + dir, steps+1}); + todo.push({start, cursor + dir, steps+1}); } } }