RectGrid.opApply - multiple declarations
- Function RectGrid.opApply
- Function RectGrid.opApply
Function RectGrid.opApply
Foreach over every tile in the grid. Supports ref
.
Prototype
int opApply( int delegate(ref RectGrid.TileType) fn );
Example
foreach with coords
auto myGrid = rectGrid([ [ 00, 01, 02, 03, 04 ], [ 10, 11, 12, 13, 14 ], [ 20, 21, 22, 23, 24 ], ]); int[] actual; foreach(tile ; myGrid) { actual ~= tile; } assert(actual == [ 00, 01, 02, 03, 04, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24]);
Function RectGrid.opApply
Foreach over every (coord,tile) pair in the grid. Supports ref
.
Prototype
int opApply( int delegate(RowCol, ref RectGrid.TileType) fn );
Example
foreach with coords
auto myGrid = rectGrid([ [ 00, 01, 02, 03, 04 ], [ 10, 11, 12, 13, 14 ], [ 20, 21, 22, 23, 24 ], ]); foreach(coord, tile ; myGrid) { assert(tile == coord.row * 10 + coord.col); }
Authors
Copyright
Copyright © 2015, Ryan Roden-Corrent