public final class Indexing extends Object
| Modifier and Type | Method and Description |
|---|---|
static int[] |
bitsToIndices(BitSet bits)
Return an index array corresponding to the 'set' bits of the supplied
BitSet. |
static int[] |
indices(int size)
Create an
int[] of values ascending from 0 to
1-size. |
static int[] |
indices(int from,
int to)
Create an
int[] of values spanning from to to,
inclusive. |
static BitSet |
indicesToBits(List<Integer> indices,
int capacity)
Return a
BitSet with capacity and with all bits at
indices 'set'. |
static int |
maxIndex(double... data)
Find the index of the maximum value in
data. |
static int[] |
maxIndex(double[][] data)
Find the indices of the maximum value in
data. |
static int[] |
maxIndex(double[][][] data)
Find the indices of the maximum value in
data. |
static int |
minIndex(double... data)
Find the index of the minimum value in
data. |
static int[] |
minIndex(double[][] data)
Find the indices of the minimum value in
data. |
static int[] |
minIndex(double[][][] data)
Find the indices of the minimum value in
data. |
static List<Integer> |
sortedIndices(List<Double> data,
boolean ascending)
Create an index
List of pointers to sorted data. |
public static int[] indices(int size)
int[] of values ascending from 0 to
1-size.size - of output arrayIllegalArgumentException - if size is not in the range
[1..10⁷]public static int[] indices(int from,
int to)
int[] of values spanning from to to,
inclusive. Sequence will be descending if from is greater than
to.from - start value, inclusiveto - end value, inclusiveIllegalArgumentException - if from < 0 or to < 0, or
the computed size of the index array is < 1public static List<Integer> sortedIndices(List<Double> data, boolean ascending)
List of pointers to sorted data. Say you
have a number of List<Double>s and want to iterate them according
to the sort order of one of them. Supply this method with the desired
data and use the returned indices in a custom iterator, leaving all
original data in place.
Notes:
data.NaN is considered to be equal to itself and greater than all
other double values (including Double.POSITIVE_INFINITY) per the behavior
of Double.compareTo(Double).data - for which to compute sort indicesascending - sort order if true, descending if falseListIllegalArgumentException - if data is emptypublic static int[] bitsToIndices(BitSet bits)
BitSet.bits - to operate onpublic static BitSet indicesToBits(List<Integer> indices, int capacity)
BitSet with capacity and with all bits at
indices 'set'.indices - to operate oncapacity - of returned BitSetpublic static int minIndex(double... data)
data. For equivalent minima,
method returns the index of the first minimum encountered. If the supplied
array is empty, method returns -1.data - to evaluate-1 if the array is emptypublic static int[] minIndex(double[][] data)
data. For equivalent
maxima, method returns the indices of the first minimum encountered. If the
1st dimension of the supplied array is empty or all arrays in the 2nd
dimension are empty, method returns [-1, -1].data - to evaluate[-1, -1] for empty
arrayspublic static int[] minIndex(double[][][] data)
data. For equivalent
minima, method returns the indices of the first minimum encountered. If the
1st dimension of the supplied array is empty or all arrays in the 2nd or
3rd dimensions are empty, method returns [-1, -1, -1].data - to evaluate[-1, -1, -1] for empty
arrayspublic static int maxIndex(double... data)
data. For equivalent maxima,
method returns the index of the first maximum encountered. If the supplied
array is empty, method returns -1.data - to evaluatepublic static int[] maxIndex(double[][] data)
data. For equivalent
maxima, method returns the indices of the first maximum encountered. If the
1st dimension of the supplied array is empty or all arrays in the 2nd
dimension are empty, method returns [-1, -1].data - to evaluate[-1, -1] for empty
arrayspublic static int[] maxIndex(double[][][] data)
data. For equivalent
maxima, method returns the indices of the first maximum encountered. If the
1st dimension of the supplied array is empty or all arrays in the 2nd or
3rd dimensions are empty, method returns [-1, -1, -1].data - to evaluate[-1, -1, -1] for empty
arrays