Package Utils

Class 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 array
      java.lang.Integer[] sort()
      Produce a sorted list of indices for the entire array
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • 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 indices
        reverse - 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 interface java.util.Comparator<java.lang.Integer>
        Parameters:
        i - The index of the first element to compare
        j - 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