O
- object typepublic class UpdatableHeap<O> extends Heap<O>
Heap.UnorderedIter
Modifier and Type | Field and Description |
---|---|
protected static int |
IN_TIES
Constant for "in ties list", for tied heaps.
|
protected it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap<java.lang.Object> |
index
Holds the indices in the heap of each element.
|
protected static int |
NO_VALUE
Constant for "not in heap".
|
comparator, queue, size
Constructor and Description |
---|
UpdatableHeap()
Simple constructor with default size.
|
UpdatableHeap(java.util.Comparator<? super O> comparator)
Constructor with comparator.
|
UpdatableHeap(int size)
Constructor with predefined size.
|
UpdatableHeap(int size,
java.util.Comparator<? super O> comparator)
Constructor with predefined size and comparator.
|
Modifier and Type | Method and Description |
---|---|
void |
add(O e)
Add an element to the heap.
|
void |
clear()
Clear the heap.
|
protected boolean |
heapifyDown(int ipos,
java.lang.Object cur)
Execute a "Heapify Downwards" aka "SiftDown".
|
protected void |
heapifyUp(int pos,
java.lang.Object cur)
Execute a "Heapify Upwards" aka "SiftUp".
|
protected void |
offerAt(int pos,
O e)
Offer element at the given position.
|
O |
poll()
Remove the top element.
|
protected O |
removeAt(int pos)
Remove the element at the given position.
|
O |
removeObject(O e)
Remove the given object from the queue.
|
O |
replaceTopElement(O e)
Combined operation that removes the top element, and inserts a new element
instead.
|
checkHeap, heapModified, isEmpty, peek, resize, size, unorderedIter
protected static final int NO_VALUE
protected static final int IN_TIES
protected final it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap<java.lang.Object> index
public UpdatableHeap()
public UpdatableHeap(int size)
size
- Sizepublic UpdatableHeap(java.util.Comparator<? super O> comparator)
comparator
- Comparatorpublic UpdatableHeap(int size, java.util.Comparator<? super O> comparator)
size
- Sizecomparator
- Comparatorpublic void clear()
Heap
protected void offerAt(int pos, O e)
pos
- Positione
- Elementprotected O removeAt(int pos)
Heap
public O removeObject(O e)
e
- Object to removepublic O replaceTopElement(O e)
Heap
replaceTopElement
in class Heap<O>
e
- New element to insertprotected void heapifyUp(int pos, java.lang.Object cur)
protected boolean heapifyDown(int ipos, java.lang.Object cur)
Heap
heapifyDown
in class Heap<O>
ipos
- re-insertion positioncur
- Object to reinsertCopyright © 2019 ELKI Development Team. License information.