public class HeapSelect<T extends java.lang.Comparable<? super T>>
extends java.lang.Object
| Constructor and Description |
|---|
HeapSelect(java.lang.Class clazz,
int k)
Constructor.
|
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.
|
int |
size()
Returns the number of objects that have been added into heap.
|
void |
sort()
Sort the smallest values.
|
T[] |
toArray()
Returns the array back the heap.
|
T[] |
toArray(T[] a)
Returns the array back the heap.
|
public HeapSelect(java.lang.Class clazz,
int k)
clazz - the data type of elements.k - the size of heap.public HeapSelect(T[] heap)
heap - the array to store smallest values to track.public int size()
public T[] toArray()
public void add(T datum)
public void heapify()
public T peek()
public T get(int i)
public void sort()