RectGrid.opApply

Foreach over every tile in the grid. Supports ref.

  1. int opApply(int delegate(ref TileType) fn)
    struct RectGrid(T)
    int
    opApply
    (
    int delegate() fn
    )
    if (
    isArray2D!T
    )
  2. int opApply(int delegate(RowCol, ref TileType) fn)

Examples

foreach with coords

1 auto myGrid = rectGrid([
2   [ 00, 01, 02, 03, 04 ],
3   [ 10, 11, 12, 13, 14 ],
4   [ 20, 21, 22, 23, 24 ],
5 ]);
6 
7 int[] actual;
8 foreach(tile ; myGrid) { actual ~= tile; }
9 
10 assert(actual == [
11     00, 01, 02, 03, 04,
12     10, 11, 12, 13, 14,
13     20, 21, 22, 23, 24]);

Meta