Class MultiSort


  • public class MultiSort
    extends java.lang.Object
    The current implementation is a simple extension of the existing HeapSort to allow an int array to be used as the key array while sorting. Ideally, this class should replace HeapSort to provide sorting of multiple numeric arrays (not necessarily of a specific numeric type), and to allow multiple keys to be used for sorting. Also, it might be interesting to an alternative sorting algorithm, such as quick sort.
    Author:
    Rodrygo Santos
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiSort()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void ascendingHeapSort​(double[] A, int[] B, short[] C)
      Sorts the given arrays in ascending order, using heap-sort.
      static void ascendingHeapSort​(double[] A, int[] B, short[] C, int topElements)
      Sorts the top topElements of the given array in ascending order, using heap sort.
      static void ascendingHeapSort​(int[] A, double[] B, short[] C, int topElements)
      ascendingHeapSort
      static void ascendingHeapSort​(java.lang.Comparable<?>[] A, int[] B)
      Sorts the given arrays in ascending order, using heap-sort.
      static void descendingHeapSort​(double[] A, int[] B, short[] C)
      Sorts the given arrays in descending order, using heap-sort.
      static void descendingHeapSort​(double[] A, int[] B, short[] C, int topElements)
      Sorts the top topElements of the given array in descending order, using heap sort for sorting the values in ascending order and then reversing the order of a specified number of elements.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiSort

        public MultiSort()
    • Method Detail

      • ascendingHeapSort

        public static final void ascendingHeapSort​(double[] A,
                                                   int[] B,
                                                   short[] C)
        Sorts the given arrays in ascending order, using heap-sort.
        Parameters:
        A - double[] the first array to be sorted.
        B - int[] the second array to be sorted, according to the values of the first array.
        C - short[] an additional array to sort by A.
      • ascendingHeapSort

        public static final void ascendingHeapSort​(java.lang.Comparable<?>[] A,
                                                   int[] B)
        Sorts the given arrays in ascending order, using heap-sort.
        Parameters:
        A - double[] the first array to be sorted.
        B - int[] the second array to be sorted, according to the values of the first array.
      • descendingHeapSort

        public static final void descendingHeapSort​(double[] A,
                                                    int[] B,
                                                    short[] C)
        Sorts the given arrays in descending order, using heap-sort.
        Parameters:
        A - double[] the first array to be sorted.
        B - int[] the second array to be sorted, according to the values of the first array.
        C - short[] an additional array to sort by A.
      • ascendingHeapSort

        public static final void ascendingHeapSort​(double[] A,
                                                   int[] B,
                                                   short[] C,
                                                   int topElements)
        Sorts the top topElements of the given array in ascending order, using heap sort.
        Parameters:
        A - double[] the first array to be sorted.
        B - int[] the second array to be sorted, according to the values of the first array.
        C - short[] an additional array to sort by A.
        topElements - int the number of elements to be sorted.
      • ascendingHeapSort

        public static final void ascendingHeapSort​(int[] A,
                                                   double[] B,
                                                   short[] C,
                                                   int topElements)
        ascendingHeapSort
      • descendingHeapSort

        public static final void descendingHeapSort​(double[] A,
                                                    int[] B,
                                                    short[] C,
                                                    int topElements)
        Sorts the top topElements of the given array in descending order, using heap sort for sorting the values in ascending order and then reversing the order of a specified number of elements.
        Parameters:
        A - double[] the first array to be sorted.
        B - int[] the second array to be sorted, according to the values of the first array.
        C - short[] an additional array to sort by A.
        topElements - int the number of elements to be sorted.