Expand description
Fast 2-dimensional Grid backed by a single vec, 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');Two convenience methods, parse and parse_with_border, create a Grid directly from a
2-dimensional set of ASCII characters, a common occurrence in Advent of Code inputs. The former
strips all newlines, and contains is then useful to prevent accidental wraparound between
lines. The latter not only preserves newlines in the input, but adds a row of newlines above and
below, for algorithms where newline serves as a natural barrier without needing to use
contains. The same_size_with function creates a grid of the same size that can be used
in BFS algorithms for tracking visited locations or for tracking cost in Dijkstra.