Class NaturalRanking.IntList
java.lang.Object
org.apache.commons.statistics.ranking.NaturalRanking.IntList
- Enclosing class:
NaturalRanking
An expandable list of int values. This allows tracking array positions
without using boxed values in a
List<Integer>
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
add
(int value) Adds the value to the list.(package private) void
clear()
Clear the list.(package private) int
get
(int index) Gets the element at the specifiedindex
.(package private) void
shuffle
(IntUnaryOperator randomIntFunction) Shuffle the list.(package private) int
size()
Gets the number of elements in the list.private static void
swap
(int[] array, int i, int j) Swaps the two specified elements in the specified array.
-
Field Details
-
max
private final int maxThe maximum size of array to allocate. -
size
private int sizeThe size of the list. -
data
private int[] dataThe list data. Initialised with space to store a tie of 2 values.
-
-
Constructor Details
-
IntList
IntList(int max) - Parameters:
max
- Maximum size of array to allocate. Can use the length of the parent array for which this is used to track indices.
-
-
Method Details
-
add
void add(int value) Adds the value to the list.- Parameters:
value
- the value
-
get
int get(int index) Gets the element at the specifiedindex
.- Parameters:
index
- Element index- Returns:
- the element
-
size
int size()Gets the number of elements in the list.- Returns:
- the size
-
clear
void clear()Clear the list. -
shuffle
Shuffle the list.- Parameters:
randomIntFunction
- Function maps positivex
randomly to[0, x)
.
-
swap
private static void swap(int[] array, int i, int j) Swaps the two specified elements in the specified array.- Parameters:
array
- Data arrayi
- First indexj
- Second index
-