public class HeapSort<T extends java.lang.Comparable<? super T>> extends TestTimes implements SortInterface<T>
| Modifier and Type | Field and Description |
|---|---|
(package private) T[] |
heap |
(package private) int |
heapSize |
| Constructor and Description |
|---|
HeapSort() |
| Modifier and Type | Method and Description |
|---|---|
private void |
heapify()
This method is used to transform the array being sorted into a heap.
|
private void |
heapSort()
This is the method that performs the HeapSort.
|
private void |
siftDown(int node)
This method will compare the node specified by it's index in the heap to both the left
and right child.
|
void |
sort(T[] arrayToSort)
This is the method that users will call to sort the specified array of
Objects of type
T using HeapSort. |
public void sort(T[] arrayToSort)
This is the method that users will call to sort the specified array of
Objects of type T using HeapSort.
This method will call the heapSort method to perform the sort.
The Comparable interface must either be implemented by T
or a superclass of T.
When this method is done, the specified array is sorted.
sort in interface SortInterface<T extends java.lang.Comparable<? super T>>arrayToSort - The array of Objects of type T to be sorted.private void heapSort()
private void heapify()
private void siftDown(int node)
node - The index of the node being compared to it's children.