About to test out ranges of points
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user