Make Grid iterable
This commit is contained in:
19
lib/src/Grid.cpp
Normal file
19
lib/src/Grid.cpp
Normal 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
|
Reference in New Issue
Block a user