Class SquareGrid


public class SquareGrid extends Object
Data structure which describes a set of SquareNode as a grid. Must be a complete grid with no missing elements. CW or CCW orientation is not specified.
  • Field Details

    • nodes

      public List<SquareNode> nodes
    • columns

      public int columns
    • rows

      public int rows
  • Constructor Details

    • SquareGrid

      public SquareGrid()
  • Method Details

    • reset

      public void reset()
    • get

      public SquareNode get(int row, int col)
      Looks up the node based on its coordinate. negative values wrap
    • set

      public void set(int row, int col, SquareNode node)
    • indexOf

      public int indexOf(int row, int col)
    • getCornerByIndex

      public SquareNode getCornerByIndex(int index)
      Returns the corner specified by its index.
      index - 0 to 3, inclusive
    • getCornerIndex

      public int getCornerIndex(SquareNode node)
      Returns the index of the corner. 0 = (0,0), 1 = (0,w-1), 2 = (h-1,w-1), 3 = (h-1,0)