nz.ac.waikato.jdsl.core.algo.sorts
Class HeapSort

java.lang.Object
  extended by nz.ac.waikato.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:
JDSL 2.1.1
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
Parameters:
s - sequence to be sorted
c - comparator which defines in which order S is sorted


Copyright © 2009 ModelJUnit Project. All Rights Reserved.