Module aoc::util::grid

source ·
Expand description

Fast 2 dimensional Grid backed by a single vec. This module is designed to work with Point.

The traits Index and IndexMut are implemented for Point to allow usage like:


  let mut grid = Grid::parse("1");
  let point = Point::new(0, 0);

  let foo = grid[point];
  assert_eq!(foo, b'1');

  grid[point] = foo + 1;
  assert_eq!(grid[point], b'2');

A convenience parse method creates a Grid directly from a 2 dimenionsal set of ASCII characters, a common occurence in Advent of Code inputs. The default_copy function creates a grid of the same size, that can be used for in BFS algorithms for tracking visited location or for tracking cost in Djikstra.

Structs§