indexed property

Iterable<(int, int, T)> indexed

Each cell in the grid with its x and y coordinates.

The order of the cells are based on the grid's internal memory layout, but each x and y coordinate is also provided for each cell, which makes this getter more useful than cells in many cases.

See also:

  • rows; for an iterable of rows.
  • columns; for an iterable of columns.

Implementation

Iterable<(int x, int y, T cell)> get indexed {
  return Iterable.generate(
    height,
    (y) => Iterable.generate(
      width,
      (x) => (x, y, get(x, y)),
    ),
  ).expand((row) => row);
}