Class UnconditionedExactTest.XYList

  • Enclosing class:
    UnconditionedExactTest

    private static class UnconditionedExactTest.XYList
    extends java.lang.Object
    An expandable list of (x,y) values. This allows tracking 2D positions stored as a single index.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int[] data
      The list data.
      private int max
      The maximum size of array to allocate.
      private int size
      The size of the list.
      private int width
      Width, or maximum x value (exclusive).
    • Constructor Summary

      Constructors 
      Constructor Description
      XYList​(int maxx, int maxy)
      Create an instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void add​(int x, int y)
      Adds the value to the list.
      (package private) int get​(int index)
      Gets the 2D index at the specified index.
      (package private) int getMaxX()
      Gets the maximum X value (inclusive).
      (package private) int getMaxY()
      Gets the maximum Y value (inclusive).
      (package private) int getWidth()
      Gets the width.
      (package private) boolean isEmpty()
      Checks if the list size is zero.
      (package private) boolean isFull()
      Checks if the list is the maximum capacity.
      (package private) int size()
      Gets the number of elements in the list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • max

        private final int max
        The maximum size of array to allocate.
      • width

        private final int width
        Width, or maximum x value (exclusive).
      • size

        private int size
        The size of the list.
      • data

        private int[] data
        The list data.
    • Constructor Detail

      • XYList

        XYList​(int maxx,
               int maxy)
        Create an instance. It is assumed that (maxx+1)*(maxy+1) does not exceed the capacity of an array.
        Parameters:
        maxx - Maximum x-value (inclusive).
        maxy - Maximum y-value (inclusive).
    • Method Detail

      • getWidth

        int getWidth()
        Gets the width. (x, y) values are stored using y * width + x.
        Returns:
        the width
      • getMaxX

        int getMaxX()
        Gets the maximum X value (inclusive).
        Returns:
        the max X
      • getMaxY

        int getMaxY()
        Gets the maximum Y value (inclusive).
        Returns:
        the max Y
      • add

        void add​(int x,
                 int y)
        Adds the value to the list.
        Parameters:
        x - X value.
        y - Y value.
      • get

        int get​(int index)
        Gets the 2D index at the specified index. The index is y * width + x:
         x = index % width
         y = index / width
         
        Parameters:
        index - Element index.
        Returns:
        the 2D index
      • size

        int size()
        Gets the number of elements in the list.
        Returns:
        the size
      • isEmpty

        boolean isEmpty()
        Checks if the list size is zero.
        Returns:
        true if empty
      • isFull

        boolean isFull()
        Checks if the list is the maximum capacity.
        Returns:
        true if full