Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

HeapBase.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <stdexcept>
35 
36 namespace ogdf {
37 
47 template<typename IMPL, typename H, typename T, typename C>
48 class HeapBase {
49  C m_comp;
50 
51 public:
56  using Handle = H*;
57 
58  explicit HeapBase(const C& comp = C()) : m_comp(comp) { }
59 
65  virtual const C& comparator() const { return m_comp; }
66 
72  virtual const T& top() const = 0;
73 
80  virtual Handle push(const T& value) = 0;
81 
85  virtual void pop() = 0;
86 
93  virtual void decrease(Handle handle, const T& value) = 0;
94 
101  virtual const T& value(const Handle handle) const = 0;
102 
110  virtual void merge(IMPL& other);
111 };
112 
113 template<typename IMPL, typename H, typename T, typename C>
114 void HeapBase<IMPL, H, T, C>::merge(IMPL& /*other*/) {
115  throw std::runtime_error("Merging two binary heaps is not supported");
116 }
117 
118 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::HeapBase::comparator
virtual const C & comparator() const
Returns the comparator used to sort the values in the heap.
Definition: HeapBase.h:65
ogdf::HeapBase
Common interface for all heap classes.
Definition: HeapBase.h:48
ogdf::HeapBase::HeapBase
HeapBase(const C &comp=C())
Definition: HeapBase.h:58
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:114
ogdf::HeapBase::Handle
H * Handle
The type of handle used to identify stored values.
Definition: HeapBase.h:56
ogdf::HeapBase::pop
virtual void pop()=0
Removes the topmost value from the heap.
ogdf::FibonacciHeapNode
Fibonacci heap node.
Definition: FibonacciHeap.h:47
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:49