Package Utils
Class SortByIndexDouble
- java.lang.Object
-
- Utils.SortByIndexDouble
-
- All Implemented Interfaces:
java.util.Comparator<java.lang.Integer>
public class SortByIndexDouble extends java.lang.Object implements java.util.Comparator<java.lang.Integer>
Comparator to sort integer indices based on the corresponding value in a double array.
-
-
Constructor Summary
Constructors Constructor Description SortByIndexDouble(double[] values)
Constructor.SortByIndexDouble(double[] values, boolean reverse)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.Integer i, java.lang.Integer j)
Overrides the default compare method and instead compares the ith and jth element of the values arrayjava.lang.Integer[]
sort()
Produce a sorted list of indices for the entire array
-
-
-
Constructor Detail
-
SortByIndexDouble
public SortByIndexDouble(double[] values)
Constructor. Defaults to sorting in standard order.- Parameters:
values
- The double array used to sort the indices
-
SortByIndexDouble
public SortByIndexDouble(double[] values, boolean reverse)
Constructor. Can sort in either standard or reverse order.- Parameters:
values
- The double array used to sort the indicesreverse
- If true sorts in reverse order
-
-
Method Detail
-
compare
public int compare(java.lang.Integer i, java.lang.Integer j)
Overrides the default compare method and instead compares the ith and jth element of the values array- Specified by:
compare
in interfacejava.util.Comparator<java.lang.Integer>
- Parameters:
i
- The index of the first element to comparej
- The index of the second element to compare- Returns:
- Standard comparison integer
-
sort
public java.lang.Integer[] sort()
Produce a sorted list of indices for the entire array- Returns:
- Sorted list of indices
-
-