45 template<
typename,
typename>
72template<
typename T,
typename C = std::less<T>>
94 const T&
top()
const override;
154template<
typename T,
typename C>
158template<
typename T,
typename C>
164template<
typename T,
typename C>
175template<
typename T,
typename C>
179 if (this->comparator()(it->value, min->
value)) {
187template<
typename T,
typename C>
195template<
typename T,
typename C>
199 while (
curr->next !=
nullptr) {
200 if (this->comparator()(
curr->next->value, min->value)) {
215 while (child !=
nullptr) {
225template<
typename T,
typename C>
239template<
typename T,
typename C>
242 other.m_root =
nullptr;
245template<
typename T,
typename C>
259 while (b !=
nullptr) {
260 if (a->
next ==
nullptr) {
280template<
typename T,
typename C>
282 m_root = join(m_root,
other);
283 if (m_root ==
nullptr) {
288 while (next !=
nullptr) {
289 if (
curr->rank != next->rank || (next->next !=
nullptr && next->next->rank ==
curr->rank)) {
296 if (this->comparator()(
curr->value, next->value)) {
297 curr->next = next->next;
299 }
else if (prev ==
nullptr) {
312template<
typename T,
typename C>
316 parent->
child = child;
Interface for heap implementations.
Binomial heap implementation.
BinomialHeapNode< T > * m_root
Root node of the heap.
static void link(BinomialHeapNode< T > *parent, BinomialHeapNode< T > *child)
Makes child node a child of parent node.
virtual ~BinomialHeap()
Destructs the heap.
static void release(BinomialHeapNode< T > *heapNode)
Releases memory occupied by list of heaps given as heapNode.
BinomialHeapNode< T > * join(BinomialHeapNode< T > *a, BinomialHeapNode< T > *b)
Joins heap lists a and b into single list sorted by the ranks.
void pop() override
Removes the top element from the heap.
void merge(BinomialHeap< T, C > &other) override
Merges in values of other heap.
BinomialHeapNode< 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.
void decrease(BinomialHeapNode< T > *heapNode, const T &value) override
Decreases value of the given heapNode to value.
BinomialHeap(const C &cmp=C(), int initialSize=-1)
Creates empty binomial heap.
const T & value(BinomialHeapNode< T > *heapNode) const override
Returns the value of the node.
Common interface for all heap classes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
BinomialHeapNode< T > * child
First child of the node.
size_t rank
Determines rank of a node.
BinomialHeapNode< T > * parent
Parent of the node.
BinomialHeapNode(const T &nodeValue)
Creates heap node with a given nodeValue.
BinomialHeapNode< T > * next
Next sibling of the node.
T value
Value contained in the node.