44 template<
typename,
typename>
69template<
typename T,
typename C>
91 const T&
top()
const override;
153template<
typename T,
typename C>
157template<
typename T,
typename C>
163template<
typename T,
typename C>
166 return m_root->value;
169template<
typename T,
typename C>
177template<
typename T,
typename C>
182 m_root = pair(children);
185template<
typename T,
typename C>
194template<
typename T,
typename C>
196 m_root = merge(m_root,
other.m_root);
197 other.m_root =
nullptr;
200template<
typename T,
typename C>
214 while (it->
next !=
nullptr) {
221 if (children % 2 == 1) {
229 a->
prev = a->
next = b->prev = b->next =
nullptr;
230 result = merge(a, b);
233 for (
size_t i = 0; i < (children - 1) / 2; i++) {
236 a->
prev = a->
next = b->prev = b->next =
nullptr;
237 result = merge(merge(a, b), result);
243template<
typename T,
typename C>
254template<
typename T,
typename C>
256 if (root->
child !=
nullptr) {
258 root->
child->prev = child;
264template<
typename T,
typename C>
278template<
typename T,
typename C>
292 if (it->
child !=
nullptr) {
296 if (it->
next !=
nullptr) {
306 if (prev ==
nullptr) {
309 if (
curr == prev->child && prev->next !=
nullptr) {
Interface for heap implementations.
Common interface for all heap classes.
Pairing heap implementation.
static void release(PairingHeapNode< T > *heapNode)
Releases memory occupied by list of heaps given as heapNode.
static void link(PairingHeapNode< T > *parent, PairingHeapNode< T > *child)
Makes child node a child of parent node.
PairingHeapNode< T > * m_root
Root node of the heap.
void merge(PairingHeap< T, C > &other) override
Merges in values of other 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.
PairingHeapNode< T > * pair(PairingHeapNode< T > *heapNode)
Pairs list of heaps given as heapNode. Returns resulting list.
void pop() override
Removes the top element from the heap.
PairingHeap(const C &cmp=C(), int initialSize=-1)
Creates empty pairing heap.
virtual ~PairingHeap()
Destructs pairing heap.
static void unlink(PairingHeapNode< T > *heapNode)
Removes heapNode from its parent children list.
void decrease(PairingHeapNode< T > *heapNode, const T &value) override
Decreases value of the given heapNode to value.
const T & value(PairingHeapNode< T > *heapNode) const override
Returns the value of the node.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
PairingHeapNode(const T &valueOfNode)
Creates heap node with a given valueOfNode.
PairingHeapNode< T > * next
Next sibling of the node.
PairingHeapNode< T > * child
First child of the node.
T value
Value contained in the node.
PairingHeapNode< T > * prev
Previous sibling of the node or parent.