Package pal.util

Class HeapSort


  • public class HeapSort
    extends java.lang.Object
    sorts numbers and comparable objects by treating contents of array as a binary tree. KNOWN BUGS: There is a horrible amount of code duplication here!
    Version:
    $Id: HeapSort.java,v 1.11 2003/03/23 00:34:23 matt Exp $
    Author:
    Alexei Drummond, Korbinian Strimmer
    • Constructor Summary

      Constructors 
      Constructor Description
      HeapSort()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double[] getSorted​(double[] array)  
      static void main​(java.lang.String[] args)
      test harness for heapsort algorithm
      static void sort​(double[] array)
      Sorts an array of doubles into increasing order.
      static void sort​(double[] array, int[] indices)
      Sorts an array of indices into an array of doubles into increasing order.
      static void sort​(java.lang.Object[] array, Comparator c)
      Sorts an array of objects into increasing order given a comparator.
      static void sort​(java.util.Vector array)
      Sorts a vector of comparable objects into increasing order.
      static void sort​(java.util.Vector array, int[] indices)
      Sorts an array of indices to vector of comparable objects into increasing order.
      static void sort​(Comparable[] array)
      Sorts an array of comparable objects into increasing order.
      static void sortAbs​(double[] array)
      Sorts an array of doubles into increasing order, ingoring sign.
      • Methods inherited from class java.lang.Object

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

      • HeapSort

        public HeapSort()
    • Method Detail

      • sort

        public static void sort​(java.util.Vector array,
                                int[] indices)
        Sorts an array of indices to vector of comparable objects into increasing order.
      • sort

        public static void sort​(java.util.Vector array)
        Sorts a vector of comparable objects into increasing order.
      • sort

        public static void sort​(Comparable[] array)
        Sorts an array of comparable objects into increasing order.
      • sort

        public static void sort​(java.lang.Object[] array,
                                Comparator c)
        Sorts an array of objects into increasing order given a comparator.
      • getSorted

        public static final double[] getSorted​(double[] array)
        Returns:
        a sorted version of input array, orignal is unchanged
      • sort

        public static void sort​(double[] array)
        Sorts an array of doubles into increasing order.
      • sortAbs

        public static void sortAbs​(double[] array)
        Sorts an array of doubles into increasing order, ingoring sign.
      • sort

        public static void sort​(double[] array,
                                int[] indices)
        Sorts an array of indices into an array of doubles into increasing order.
      • main

        public static void main​(java.lang.String[] args)
        test harness for heapsort algorithm