Package pal.util

Class HeapSort

java.lang.Object
pal.util.HeapSort

public class HeapSort extends 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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final double[]
    getSorted(double[] array)
     
    static void
    main(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(Object[] array, Comparator c)
    Sorts an array of objects into increasing order given a comparator.
    static void
    sort(Vector array)
    Sorts a vector of comparable objects into increasing order.
    static void
    sort(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 Details

    • HeapSort

      public HeapSort()
  • Method Details

    • sort

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

      public static void sort(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(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(String[] args)
      test harness for heapsort algorithm