DataStructures
Class Sort

java.lang.Object
  extended by DataStructures.Sort

public class Sort
extends java.lang.Object

A class providing static array sorting routines

Author:
Peter Williams
See Also:
Comparable

Method Summary
static
<E extends java.lang.Comparable<? super E>>
void
heapSort(E[] a, int n)
          Sorts an array a[0..n-1] in ascending order using heapsort.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

heapSort

public static final <E extends java.lang.Comparable<? super E>> void heapSort(E[] a,
                                                                              int n)
Sorts an array a[0..n-1] in ascending order using heapsort. The array is replaced on output by its sorted rearrangement. Array elements must implement the Comparable interface in their defining class or in some superclass.

Type Parameters:
E - the type of elements held in the array
Parameters:
a - the array to sort
n - the number of elements sorted, elements a[n] onwards are ignored
Throws:
java.lang.ArrayIndexOutOfBoundsException - if n is greater than the array length.