Package pal.util
Class HeapSort
java.lang.Object
pal.util.HeapSort
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic final double[]
getSorted
(double[] array) static void
test harness for heapsort algorithmstatic 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
Sorts a vector of comparable objects into increasing order.static void
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.
-
Constructor Details
-
HeapSort
public HeapSort()
-
-
Method Details
-
sort
Sorts an array of indices to vector of comparable objects into increasing order. -
sort
Sorts a vector of comparable objects into increasing order. -
sort
Sorts an array of comparable objects into increasing order. -
sort
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
test harness for heapsort algorithm
-