45 template<
typename,
typename>
74template<
typename T,
typename C = std::less<T>>
96 const T&
top()
const override;
154template<
typename T,
typename C>
158template<
typename T,
typename C>
163template<
typename T,
typename C>
165 return m_root->
value;
168template<
typename T,
typename C>
176template<
typename T,
typename C>
179 m_root = merge(m_root->left, m_root->right);
180 if (m_root !=
nullptr) {
181 m_root->parent =
nullptr;
186template<
typename T,
typename C>
201template<
typename T,
typename C>
203 m_root = merge(m_root,
other.m_root);
204 other.m_root =
nullptr;
207template<
typename T,
typename C>
217 if (m_rand() % 2 == 0) {
219 if (a->
left !=
nullptr) {
224 if (a->
right !=
nullptr) {
225 a->
right->parent = a;
230 if (m_rand() % 2 == 0) {
232 if (b->
left !=
nullptr) {
237 if (b->
right !=
nullptr) {
238 b->
right->parent = b;
245template<
typename T,
typename C>
258template<
typename T,
typename C>
Interface for heap implementations.
Common interface for all heap classes.
virtual const T & value(const Handle handle) const =0
Returns the value of that handle.
Randomized meldable heap implementation.
virtual ~RMHeap()
Destructs the heap.
RMHeapNode< T > * push(const T &value) override
Inserts a new node with given value into a heap.
static void release(RMHeapNode< T > *heapNode)
Recursively releases memory occupied by heap pointed by heapNode.
void merge(RMHeap< T, C > &other) override
Merges in values of other heap.
RMHeap(const C &cmp=C(), int initialSize=-1)
Creates empty randomized meldable heap.
void pop() override
Removes the top element from the heap.
RMHeapNode< T > * m_root
Root node of the heap.
const T & top() const override
Returns reference to the top element in the heap.
const T & value(RMHeapNode< T > *heapNode) const override
Returns the value of the node.
std::default_random_engine m_rand
Random values generator.
void remove(RMHeapNode< T > *heapNode)
Removes given heapNode from the main tree (does not free memory!).
void decrease(RMHeapNode< T > *heapNode, const T &value) override
Decreases value of the given heapNode to value.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Randomized meldable heap node.
RMHeapNode< T > * parent
Parent of the node.
T value
Value contained in the node.
RMHeapNode< T > * left
Left child of the node.
RMHeapNode(const T &nodeValue)
Creates heap node with a given nodeValue.
RMHeapNode< T > * right
Right child of the node.