RectGrid.contains

True if the grid coordinate is within the grid bounds.

struct RectGrid(T)
bool
contains

Examples

// 5x3 map
auto grid = rectGrid([
  //0  1  2  3  4 col   row
  [ 0, 0, 0, 0, 0 ], // 0
  [ 0, 0, 0, 0, 0 ], // 1
  [ 0, 0, 0, 0, 0 ], // 2
]);

assert( grid.contains(RowCol(0 , 0))); // top left
assert( grid.contains(RowCol(2 , 4))); // bottom right
assert( grid.contains(RowCol(1 , 2))); // center
assert(!grid.contains(RowCol(0 , 5))); // beyond right border
assert(!grid.contains(RowCol(3 , 0))); // beyond bottom border
assert(!grid.contains(RowCol(0 ,-1))); // beyond left border
assert(!grid.contains(RowCol(-1, 0))); // beyond top border

Meta