public class HeapSelect<T extends java.lang.Comparable<? super T>>
extends java.lang.Object
| Constructor and Description |
|---|
HeapSelect(T[] heap)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(T datum)
Assimilate a new value from the stream.
|
T |
get(int i)
Returns the i-th smallest value seen so far.
|
void |
heapify()
In case of avoiding creating new objects frequently, one may check and
update the peek object directly and call this method to sort the internal
array in heap order.
|
T |
peek()
Returns the k-th smallest value seen so far.
|
void |
sort()
Sort the smallest values.
|
public HeapSelect(T[] heap)
heap - the array to store smallest values to track.public void add(T datum)
public void heapify()
public T peek()
public T get(int i)
public void sort()