About to test out ranges of points

This commit is contained in:
2021-12-12 10:42:53 -05:00
parent cd37945791
commit f360be0c8d
2 changed files with 13 additions and 2 deletions

View File

@@ -7,7 +7,7 @@
#include <vector>
#include <range/v3/view.hpp>
template<typename T>
class Grid2D {
private:
@@ -28,6 +28,17 @@ public:
T get(int x, int y) {
return grid[y][x];
}
auto get_range() {
auto res = grid | ranges::views::enumerate | ranges::views::transform([](auto it) {
int index_y = std::get<0>(it);
std::vector<T> element = std::get<1>(it);
return element | ranges::views::enumerate | ranges::views::transform([&](auto pair) {
int index_x = std::get<0>(pair);
return Point{index_x, index_y};
});
});
return ranges::views::join(res);
}
};