Class SortUtils


  • public class SortUtils
    extends Object
    Utilities for sorting, primarily used for SparseRows.
    • Constructor Summary

      Constructors 
      Constructor Description
      SortUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compare​(double[] d1, double[] d2)  
      static boolean isSorted​(int start, int end, double[] values)  
      static boolean isSorted​(int start, int end, int[] indexes)  
      static boolean isSorted​(MatrixBlock in)  
      static void sortByIndex​(int start, int end, int[] indexes, double[] values)
      In-place sort of two arrays, only indexes is used for comparison and values of same position are sorted accordingly.
      static void sortByIndex​(int start, int end, int[] indexes, int[] indexes2, double[] values)
      In-place sort of three arrays, only first indexes is used for comparison and second indexes as well as values of same position are sorted accordingly.
      static void sortByValue​(int start, int end, double[] values, int[] indexes)  
      static void sortByValueStable​(int start, int end, double[] values, int[] indexes)
      In-place sort of two arrays, only indexes is used for comparison and values of same position are sorted accordingly.
    • Constructor Detail

      • SortUtils

        public SortUtils()
    • Method Detail

      • isSorted

        public static boolean isSorted​(int start,
                                       int end,
                                       int[] indexes)
      • isSorted

        public static boolean isSorted​(int start,
                                       int end,
                                       double[] values)
      • isSorted

        public static boolean isSorted​(MatrixBlock in)
      • compare

        public static int compare​(double[] d1,
                                  double[] d2)
      • sortByIndex

        public static void sortByIndex​(int start,
                                       int end,
                                       int[] indexes,
                                       double[] values)
        In-place sort of two arrays, only indexes is used for comparison and values of same position are sorted accordingly.
        Parameters:
        start - starting index
        end - ending index
        indexes - array of indexes to sort by
        values - double array of values to sort
      • sortByIndex

        public static void sortByIndex​(int start,
                                       int end,
                                       int[] indexes,
                                       int[] indexes2,
                                       double[] values)
        In-place sort of three arrays, only first indexes is used for comparison and second indexes as well as values of same position are sorted accordingly.
        Parameters:
        start - starting index
        end - ending index
        indexes - ?
        indexes2 - ?
        values - ?
      • sortByValue

        public static void sortByValue​(int start,
                                       int end,
                                       double[] values,
                                       int[] indexes)
      • sortByValueStable

        public static void sortByValueStable​(int start,
                                             int end,
                                             double[] values,
                                             int[] indexes)
        In-place sort of two arrays, only indexes is used for comparison and values of same position are sorted accordingly.
        Parameters:
        start - start index
        end - end index
        values - double array of values to sort
        indexes - int array of indexes to sort by