Pairing heap implementation. More...
#include <ogdf/basic/heap/PairingHeap.h>
Inheritance diagram for ogdf::PairingHeap< T, C >:Public Member Functions | |
| PairingHeap (const C &cmp=C(), int initialSize=-1) | |
| Creates empty pairing heap. | |
| virtual | ~PairingHeap () |
| Destructs pairing heap. | |
| void | decrease (PairingHeapNode< T > *heapNode, const T &value) override |
Decreases value of the given heapNode to value. | |
| void | merge (PairingHeap< T, C > &other) override |
Merges in values of other heap. | |
| void | pop () override |
| Removes the top element from the heap. | |
| PairingHeapNode< T > * | push (const T &value) override |
Inserts a new node with given value into a heap. | |
| const T & | top () const override |
| Returns reference to the top element in the heap. | |
| const T & | value (PairingHeapNode< T > *heapNode) const override |
| Returns the value of the node. | |
Public Member Functions inherited from ogdf::HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C > | |
| HeapBase (const C &comp=C()) | |
| virtual const C & | comparator () const |
| Returns the comparator used to sort the values in the heap. | |
| virtual void | decrease (Handle handle, const T &value)=0 |
| Decreases a single value. | |
| virtual void | merge (PairingHeap< T, C > &other) |
Merges in values of other heap. | |
| virtual const T & | value (const Handle handle) const=0 |
| Returns the value of that handle. | |
Private Types | |
| using | base_type = HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C > |
Private Member Functions | |
| PairingHeapNode< T > * | merge (PairingHeapNode< T > *a, PairingHeapNode< T > *b) |
Merges lists of heaps a and b. Returns resulting list. | |
| PairingHeapNode< T > * | pair (PairingHeapNode< T > *heapNode) |
Pairs list of heaps given as heapNode. Returns resulting list. | |
Static Private Member Functions | |
| static void | link (PairingHeapNode< T > *parent, PairingHeapNode< T > *child) |
Makes child node a child of parent node. | |
| static void | release (PairingHeapNode< T > *heapNode) |
Releases memory occupied by list of heaps given as heapNode. | |
| static void | unlink (PairingHeapNode< T > *heapNode) |
Removes heapNode from its parent children list. | |
Private Attributes | |
| PairingHeapNode< T > * | m_root |
| Root node of the heap. | |
Additional Inherited Members | |
Public Types inherited from ogdf::HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C > | |
| using | Handle = PairingHeapNode< T > * |
| The type of handle used to identify stored values. | |
Pairing heap implementation.
Code is mainly based on orginal paper "The Pairing Heap: A New Form of Self-Adjusting Heap" by Fredman, Sedgewick, Sleator and Tarjan.
| T | Denotes value type of inserted elements. |
| C | Denotes comparison functor determining value ordering. |
Definition at line 71 of file PairingHeap.h.
|
private |
Definition at line 72 of file PairingHeap.h.
|
explicit |
Creates empty pairing heap.
| cmp | Comparison functor determining value ordering. |
| initialSize | ignored by this implementation. |
Definition at line 155 of file PairingHeap.h.
|
virtual |
Destructs pairing heap.
If the heap is not empty, destructors of contained elements are called and used storage is deallocated.
Definition at line 159 of file PairingHeap.h.
|
override |
Decreases value of the given heapNode to value.
Behaviour of this function is undefined if node does not belong to a the heap or new value is greater than old one.
| heapNode | A node for which the value is to be decreased. |
| value | A new value for the node. |
Definition at line 187 of file PairingHeap.h.
|
inlinestaticprivate |
Makes child node a child of parent node.
Definition at line 262 of file PairingHeap.h.
|
override |
Merges in values of other heap.
After merge other heap becomes empty and is valid for further usage.
| other | A heap to be merged in. |
Definition at line 196 of file PairingHeap.h.
|
inlineprivate |
Merges lists of heaps a and b. Returns resulting list.
Definition at line 245 of file PairingHeap.h.
|
inlineprivate |
Pairs list of heaps given as heapNode. Returns resulting list.
Definition at line 202 of file PairingHeap.h.
|
overridevirtual |
Removes the top element from the heap.
Behaviour of this function is undefined if the heap is empty.
Implements ogdf::HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C >.
Definition at line 179 of file PairingHeap.h.
|
overridevirtual |
Inserts a new node with given value into a heap.
| value | A value to be inserted. |
Implements ogdf::HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C >.
Definition at line 171 of file PairingHeap.h.
|
inlinestaticprivate |
Releases memory occupied by list of heaps given as heapNode.
Definition at line 286 of file PairingHeap.h.
|
inlineoverridevirtual |
Returns reference to the top element in the heap.
Implements ogdf::HeapBase< PairingHeap< T, C >, PairingHeapNode< T >, T, C >.
Definition at line 165 of file PairingHeap.h.
|
inlinestaticprivate |
Removes heapNode from its parent children list.
Definition at line 272 of file PairingHeap.h.
|
inlineoverride |
Returns the value of the node.
| heapNode | The nodes handle |
Definition at line 135 of file PairingHeap.h.
|
private |
Root node of the heap.
Definition at line 138 of file PairingHeap.h.