jdsl.core.algo.sorts
Class HeapSort

java.lang.Object
  |
  +--jdsl.core.algo.sorts.HeapSort
All Implemented Interfaces:
SortObject

public class HeapSort
extends java.lang.Object
implements SortObject

Performs a heap-sort in O(n log n) time, provided only that the replaceElement(.) method of the Sequence works in O(1) time (and thus the style of implementation of the Sequence is not relevant). All of the Positions of the sequence are preserved, but their elements are moved around.

Version:
$Id: HeapSort.java,v 1.7 2000/01/12 03:21:21 mdh Exp $
Author:
Benoit Hudson (bh), Luca Vismara (lv)

Constructor Summary
HeapSort()
           
 
Method Summary
 void sort(Sequence s, Comparator c)
          Method that actually sorts the sequence, with the first element after the sort being the one that the comparator reported was smallest.
 
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 void sort(Sequence s,
                 Comparator c)
Description copied from interface: SortObject
Method that actually sorts the sequence, with the first element after the sort being the one that the comparator reported was smallest.
Specified by:
sort in interface SortObject
Following copied from interface: jdsl.core.algo.sorts.SortObject
Parameters:
s - sequence to be sorted
c - comparator which defines in which order S is sorted