Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
38 namespace ogdf {
39 
49 template<typename IMPL, typename H, typename T, typename C>
50 class HeapBase {
51  C m_comp;
52 
53 public:
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 
115 template<typename IMPL, typename H, typename T, typename C>
116 void HeapBase<IMPL, H, T, C>::merge(IMPL& /*other*/) {
117  throw std::runtime_error("Merging two binary heaps is not supported");
118 }
119 
120 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::HeapBase::comparator
virtual const C & comparator() const
Returns the comparator used to sort the values in the heap.
Definition: HeapBase.h:67
ogdf::HeapBase
Common interface for all heap classes.
Definition: HeapBase.h:50
ogdf::HeapBase::HeapBase
HeapBase(const C &comp=C())
Definition: HeapBase.h:60
ogdf::HeapBase::value
virtual const T & value(const Handle handle) const =0
Returns the value of that handle.
ogdf::HeapBase::top
virtual const T & top() const =0
Returns the topmost value in the heap.
ogdf::HeapBase::decrease
virtual void decrease(Handle handle, const T &value)=0
Decreases a single value.
ogdf::HeapBase::merge
virtual void merge(IMPL &other)
Merges in values of other heap.
Definition: HeapBase.h:116
ogdf::HeapBase::Handle
H * Handle
The type of handle used to identify stored values.
Definition: HeapBase.h:58
ogdf::HeapBase::pop
virtual void pop()=0
Removes the topmost value from the heap.
ogdf::FibonacciHeapNode
Fibonacci heap node.
Definition: FibonacciHeap.h:45
ogdf::HeapBase::push
virtual Handle push(const T &value)=0
Inserts a value into the heap.
ogdf::HeapBase::m_comp
C m_comp
Definition: HeapBase.h:51
basic.h
Basic declarations, included by all source files.