jdsl.core.algo.sorts
Class HeapSort
java.lang.Object
jdsl.core.algo.sorts.HeapSort
- All Implemented Interfaces:
- SortObject
- public class HeapSort
- extends 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)
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 |
HeapSort
public HeapSort()
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 sortedc
- comparator which defines in which order S is sorted