
E - Element type. Should be Comparable or a Comparator
needs to be given.public class TopBoundedHeap<E> extends Heap<E>
k Elements only.Heap.UnorderedIter| Modifier and Type | Field and Description |
|---|---|
protected int |
maxsize
Maximum size.
|
comparator, queue, size| Constructor and Description |
|---|
TopBoundedHeap(int maxsize)
Constructor with maximum size only.
|
TopBoundedHeap(int maxsize,
Comparator<? super E> comparator)
Constructor with maximum size and
Comparator. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(E e)
Add an element to the heap.
|
int |
getMaxSize()
Get the maximum size.
|
protected void |
handleOverflow(E e)
Handle an overflow in the structure.
|
checkHeap, clear, heapifyDown, heapifyDownComparable, heapifyDownComparator, heapifyUp, heapifyUpComparable, heapifyUpComparator, heapModified, isEmpty, peek, poll, removeAt, replaceTopElement, resize, size, unorderedIterpublic TopBoundedHeap(int maxsize)
maxsize - Maximum sizepublic TopBoundedHeap(int maxsize,
Comparator<? super E> comparator)
Comparator.maxsize - Maximum sizecomparator - Comparatorprotected void handleOverflow(E e)
e - Overflowing element.public int getMaxSize()