RectGrid.allCoords

Get a range that iterates through every coordinate in the grid.

struct RectGrid(T)
allCoords
(
)
if (
isArray2D!T
)

Examples

Use allCoords to apply range-oriented functions to the coords in the grid.

1 import std.algorithm;
2 
3 auto myGrid = rectGrid([
4   [ 00, 01, 02, 03, 04 ],
5   [ 10, 11, 12, 13, 14 ],
6   [ 20, 21, 22, 23, 24 ],
7 ]);
8 
9 auto coords = myGrid.allCoords
10   .filter!(x => x.col > 3)
11   .map!(x => x.row * 10 + x.col);
12 
13 assert(coords.equal([04, 14, 24]));

Meta