Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
HeapBase.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/basic.h>
35
36#include <stdexcept>
37
38namespace ogdf {
39
49template<typename IMPL, typename H, typename T, typename C>
50class HeapBase {
52
53public:
58 using Handle = H*;
59
60 explicit HeapBase(const C& comp = C()) : m_comp(comp) { }
61
67 virtual const C& comparator() const { return m_comp; }
68
74 virtual const T& top() const = 0;
75
82 virtual Handle push(const T& value) = 0;
83
87 virtual void pop() = 0;
88
95 virtual void decrease(Handle handle, const T& value) = 0;
96
103 virtual const T& value(const Handle handle) const = 0;
104
112 virtual void merge(IMPL& other);
113};
114
115template<typename IMPL, typename H, typename T, typename C>
117 throw std::runtime_error("Merging two binary heaps is not supported");
118}
119
120}
Basic declarations, included by all source files.
Common interface for all heap classes.
Definition HeapBase.h:50
virtual void merge(IMPL &other)
Merges in values of other heap.
Definition HeapBase.h:116
virtual void pop()=0
Removes the topmost value from the heap.
HeapBase(const C &comp=C())
Definition HeapBase.h:60
virtual Handle push(const T &value)=0
Inserts a value into the heap.
virtual const T & top() const =0
Returns the topmost value in the heap.
virtual const T & value(const Handle handle) const =0
Returns the value of that handle.
H * Handle
The type of handle used to identify stored values.
Definition HeapBase.h:58
virtual const C & comparator() const
Returns the comparator used to sort the values in the heap.
Definition HeapBase.h:67
virtual void decrease(Handle handle, const T &value)=0
Decreases a single value.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.