public interface IntegerHeap
Modifier and Type | Interface and Description |
---|---|
static interface |
IntegerHeap.UnsortedIter
Unsorted iterator - in heap order.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int key)
Add a key-value pair to the heap
|
void |
add(int key,
int max)
Add a key-value pair to the heap, except if the new element is larger than
the top, and we are at design size (overflow)
|
void |
clear()
Delete all elements from the heap.
|
boolean |
isEmpty()
Is the heap empty?
|
int |
peek()
Get the current top key
|
int |
poll()
Remove the first element
|
int |
replaceTopElement(int e)
Combined operation that removes the top element, and inserts a new element
instead.
|
int |
size()
Query the size
|
IntegerHeap.UnsortedIter |
unsortedIter()
Get an unsorted iterator to inspect the heap.
|
void add(int key)
key
- Keyvoid add(int key, int max)
key
- Keymax
- Maximum size of heapint replaceTopElement(int e)
e
- New element to insertint peek()
int poll()
void clear()
int size()
boolean isEmpty()
true
when the size is 0.IntegerHeap.UnsortedIter unsortedIter()