Class UnconditionedExactTest.XYList
java.lang.Object
org.apache.commons.statistics.inference.UnconditionedExactTest.XYList
- Enclosing class:
UnconditionedExactTest
An expandable list of (x,y) values. This allows tracking 2D positions stored as
a single index.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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 specifiedindex
.(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.
-
Field Details
-
max
private final int maxThe maximum size of array to allocate. -
width
private final int widthWidth, or maximum x value (exclusive). -
size
private int sizeThe size of the list. -
data
private int[] dataThe 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 specifiedindex
. 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
-