Class UnconditionedExactTest.XYList

java.lang.Object
org.apache.commons.statistics.inference.UnconditionedExactTest.XYList
Enclosing class:
UnconditionedExactTest

private static class UnconditionedExactTest.XYList extends 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[]
    The list data.
    private final int
    The maximum size of array to allocate.
    private int
    The size of the list.
    private final int
    Width, or maximum x value (exclusive).
  • Constructor Summary

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

    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
    Gets the maximum X value (inclusive).
    (package private) int
    Gets the maximum Y value (inclusive).
    (package private) int
    Gets the width.
    (package private) boolean
    Checks if the list size is zero.
    (package private) boolean
    Checks if the list is the maximum capacity.
    (package private) int
    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 Details

    • 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 Details

    • 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 Details

    • 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