O
- object typepublic class UpdatableHeap<O> extends Heap<O>
Modifier and Type | Field and Description |
---|---|
protected static int |
IN_TIES
Constant for "in ties list", for tied heaps.
|
protected gnu.trove.map.TObjectIntMap<Object> |
index
Holds the indices in the heap of each element.
|
protected static int |
NO_VALUE
Constant for "not in heap"
|
private static long |
serialVersionUID
Serial version
|
Constructor and Description |
---|
UpdatableHeap()
Simple constructor with default size.
|
UpdatableHeap(Comparator<? super O> comparator)
Constructor with comparator
|
UpdatableHeap(int size)
Constructor with predefined size.
|
UpdatableHeap(int size,
Comparator<? super O> comparator)
Constructor with predefined size and comparator
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
protected boolean |
heapifyDownComparable(int ipos,
Object reinsert)
Execute a "Heapify Downwards" aka "SiftDown".
|
protected boolean |
heapifyDownComparator(int ipos,
Object cur)
Execute a "Heapify Downwards" aka "SiftDown".
|
protected void |
heapifyUpComparable(int pos,
Object elem)
Execute a "Heapify Upwards" aka "SiftUp".
|
protected void |
heapifyUpComparator(int pos,
Object cur)
Execute a "Heapify Upwards" aka "SiftUp".
|
boolean |
offer(O e) |
protected boolean |
offerAt(int pos,
O e) |
O |
poll() |
protected O |
removeAt(int pos)
Remove the element at the given position.
|
O |
removeObject(O e)
Remove the given object from the queue.
|
add, addAll, castQueueElement, checkHeap, contains, ensureValid, heapifyDown, heapifyUp, iterator, peek, resize, size, toSortedArrayList
element, remove
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
protected static final int NO_VALUE
protected static final int IN_TIES
private static final long serialVersionUID
protected final gnu.trove.map.TObjectIntMap<Object> index
public UpdatableHeap()
public UpdatableHeap(int size)
size
- Sizepublic UpdatableHeap(Comparator<? super O> comparator)
comparator
- Comparatorpublic UpdatableHeap(int size, Comparator<? super O> comparator)
size
- Sizecomparator
- Comparatorpublic void clear()
public boolean offer(O e)
protected boolean offerAt(int pos, O e)
protected O removeAt(int pos)
Heap
public O removeObject(O e)
e
- Object to removeprotected void heapifyUpComparable(int pos, Object elem)
heapifyUpComparable
in class Heap<O>
pos
- insertion positionelem
- Element to insertprotected void heapifyUpComparator(int pos, Object cur)
heapifyUpComparator
in class Heap<O>
pos
- insertion positioncur
- Element to insertprotected boolean heapifyDownComparable(int ipos, Object reinsert)
Heap
heapifyDownComparable
in class Heap<O>
ipos
- re-insertion positionprotected boolean heapifyDownComparator(int ipos, Object cur)
Heap
heapifyDownComparator
in class Heap<O>
ipos
- re-insertion position