RectGrid.contains

True if the grid coordinate is within the grid bounds.

struct RectGrid(T)
bool
contains
if (
isArray2D!T
)

Examples

1 // 5x3 map
2 auto grid = rectGrid([
3   //0  1  2  3  4 col   row
4   [ 0, 0, 0, 0, 0 ], // 0
5   [ 0, 0, 0, 0, 0 ], // 1
6   [ 0, 0, 0, 0, 0 ], // 2
7 ]);
8 
9 assert( grid.contains(RowCol(0 , 0))); // top left
10 assert( grid.contains(RowCol(2 , 4))); // bottom right
11 assert( grid.contains(RowCol(1 , 2))); // center
12 assert(!grid.contains(RowCol(0 , 5))); // beyond right border
13 assert(!grid.contains(RowCol(3 , 0))); // beyond bottom border
14 assert(!grid.contains(RowCol(0 ,-1))); // beyond left border
15 assert(!grid.contains(RowCol(-1, 0))); // beyond top border

Meta