
E - Object typepublic class TiedTopBoundedHeap<E> extends TopBoundedHeap<E>
TopBoundedHeap, discarding elements
with the highest value. However, this variation keeps a list of tied
elements.| Modifier and Type | Field and Description |
|---|---|
private List<E> |
ties
List to keep ties in.
|
maxsizecomparator, queue, size, validSize| Constructor and Description |
|---|
TiedTopBoundedHeap(int maxsize)
Constructor for Comparable objects.
|
TiedTopBoundedHeap(int maxsize,
Comparator<? super E> comparator)
Constructor with comparator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the heap.
|
protected void |
handleOverflow(E e)
Handle an overflow in the structure.
|
Iterator<E> |
iterator() |
E |
peek()
Peek at the top element.
|
E |
poll()
Remove the top element.
|
E |
replaceTopElement(E e)
Combined operation that removes the top element, and inserts a new element
instead.
|
int |
size()
Get the heap size.
|
add, getMaxSizecheckHeap, ensureValid, heapifyDown, heapifyDownComparable, heapifyDownComparator, heapifyUp, heapifyUpComparable, heapifyUpComparator, heapModified, isEmpty, removeAt, resizepublic TiedTopBoundedHeap(int maxsize,
Comparator<? super E> comparator)
maxsize - Maximum size of heap (unless tied)comparator - Comparatorpublic TiedTopBoundedHeap(int maxsize)
maxsize - Maximum size of heap (unless tied)public int size()
Heappublic void clear()
Heappublic E replaceTopElement(E e)
HeapreplaceTopElement in class Heap<E>e - New element to insertprotected void handleOverflow(E e)
TopBoundedHeaphandleOverflow in class TopBoundedHeap<E>e - Overflowing element.