net.sf.jsort.sort
Class HeapSort
java.lang.Object
net.sf.jsort.sort.AbstractSort
net.sf.jsort.sort.HeapSort
- All Implemented Interfaces:
- CompareSort, SortAlgorithm
public final class HeapSort
- extends AbstractSort
This is a implemention of the Heap Sort algorithm.
This algorithm use the
structure of a tree inside the array, it manipulate any element using the
concept of methods parent(), left() and right(). The main method of this
algorithm is maxHeapify(), it keeps the parent (position i) and its children
under the rule parent(i) >= i. This rule is used by PriorityQueue to keep
with a very simple implementation the hole queue ordered.
- Author:
- Domingos Creado
- See Also:
- http://en.wikipedia.org/wiki/Heapsort
Method Summary |
void |
buildMaxHeap(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
build the heap |
void |
heapsort(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
|
void |
sort(java.lang.Object[] list,
java.util.Comparator comparator,
int start,
int end)
Sort a specific range of the list, using the specified comparator. |
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(java.lang.Object[] list,
java.util.Comparator comparator,
int start,
int end)
- Description copied from interface:
CompareSort
- Sort a specific range of the list, using the specified comparator.
- Specified by:
sort
in interface CompareSort
- Specified by:
sort
in class AbstractSort
- Parameters:
list
- to be sort
heapsort
public void heapsort(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
buildMaxHeap
public void buildMaxHeap(java.lang.Object[] a,
java.util.Comparator comparator,
int start,
int end)
- build the heap
- Parameters:
a
- comparator
-
Copyright © 2005-2008 Domingos Creado. All Rights Reserved.