Make Grid iterable

This commit is contained in:
2024-09-05 20:10:34 -07:00
parent 9e6223f886
commit d6fc0396cb
11 changed files with 77 additions and 46 deletions

19
lib/src/Grid.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "aocpp/Grid.hpp"
namespace aocpp {
auto GridIterator::operator*() -> GridElement
{
return {{x_, y_}, grid_[Coord{x_, y_}]};
}
auto GridIterator::operator++() -> GridIterator &
{
if (++x_ == grid_.columns)
{
x_ = 0;
y_++;
}
return *this;
}
} // namespace