 |
Open Graph Drawing Framework |
v. 2022.02 (Dogwood)
|
|
|
Go to the documentation of this file.
74 template<
typename T,
typename C = std::less<T>>
88 explicit BinomialHeap(
const C &cmp = C(),
int initialSize = -1);
99 const T &
top()
const override;
143 return heapNode->
value;
162 template<
typename T,
typename C>
167 template<
typename T,
typename C>
175 template<
typename T,
typename C>
178 while(heapNode !=
nullptr) {
179 release(heapNode->
child);
188 template<
typename T,
typename C>
193 if(this->comparator()(it->value, min->
value)) {
202 template<
typename T,
typename C>
212 template<
typename T,
typename C>
217 while(curr->
next !=
nullptr) {
218 if(this->comparator()(curr->
next->value, min->value)) {
228 minPrev->next = min->next;
233 while(child !=
nullptr) {
235 child->next = reversed;
244 template<
typename T,
typename C>
250 heapNode->
value = value;
252 while(heapNode->
parent !=
nullptr &&
253 this->comparator()(heapNode->
value, heapNode->
parent->value))
255 std::swap(heapNode->
value, heapNode->
parent->value);
256 heapNode = heapNode->
parent;
261 template<
typename T,
typename C>
269 template<
typename T,
typename C>
285 while(b !=
nullptr) {
286 if(a->
next ==
nullptr) {
307 template<
typename T,
typename C>
310 m_root = join(m_root, other);
311 if(m_root ==
nullptr) {
316 while(next !=
nullptr) {
317 if(curr->rank != next->rank || (next->next !=
nullptr &&
318 next->next->rank == curr->rank))
326 if(this->comparator()(curr->value, next->value)) {
327 curr->next = next->next;
329 }
else if(prev ==
nullptr) {
343 template<
typename T,
typename C>
349 parent->
child = child;
The namespace for all OGDF objects.
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.
void decrease(BinomialHeapNode< T > *heapNode, const T &value) override
Decreases value of the given heapNode to value.
size_t rank
Determines rank of a node.
BinomialHeapNode< T > * child
First child of the node.
const T & top() const override
Returns reference to the top element in the heap.
Binomial heap implementation.
static void release(BinomialHeapNode< T > *heapNode)
Releases memory occupied by list of heaps given as heapNode.
BinomialHeapNode< T > * push(const T &value) override
Inserts a new node with given value into a heap.
BinomialHeapNode< T > * join(BinomialHeapNode< T > *a, BinomialHeapNode< T > *b)
Joins heap lists a and b into single list sorted by the ranks.
BinomialHeapNode< T > * m_root
Root node of the heap.
virtual ~BinomialHeap()
Destructs the heap.
BinomialHeap(const C &cmp=C(), int initialSize=-1)
Creates empty binomial heap.
T value
Value contained in the node.
Interface for heap implementations.
BinomialHeapNode(const T &nodeValue)
Creates heap node with a given nodeValue.
void pop() override
Removes the top element from the heap.
static void link(BinomialHeapNode< T > *parent, BinomialHeapNode< T > *child)
Makes child node a child of parent node.
void merge(BinomialHeap< T, C > &other) override
Merges in values of other heap.
BinomialHeapNode< T > * next
Next sibling of the node.
BinomialHeapNode< T > * parent
Parent of the node.