RectGrid.allTiles

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

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

Examples

Use allTiles to apply range-oriented functions to the tiles 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 assert(myGrid.allTiles.filter!(x => x > 22).equal([23, 24]));
10 
11 // use ref with allTiles to apply modifications
12 foreach(ref tile ; myGrid.allTiles.filter!(x => x < 10)) {
13   tile += 10;
14 }
15 
16 assert(myGrid.tileAt(RowCol(0,0)) == 10);

Meta