Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

HeapBase.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <stdexcept>
35 
36 #include <ogdf/basic/basic.h>
37 
38 namespace ogdf {
39 
49 template<
50  typename IMPL,
51  typename H,
52  typename T,
53  typename C
54 >
55 class HeapBase
56 {
57 
58  C m_comp;
59 
60 public:
61 
66  using Handle = H*;
67 
68  explicit HeapBase(C const &comp = C()) : m_comp(comp) {}
69 
75  virtual const C &comparator() const { return m_comp; }
76 
82  virtual const T &top() const = 0;
83 
90  virtual Handle push(const T &value) = 0;
91 
95  virtual void pop() = 0;
96 
103  virtual void decrease(Handle handle, const T &value) = 0;
104 
111  virtual const T &value(const Handle handle) const = 0;
112 
120  virtual void merge(IMPL &other);
121 
122 };
123 
124 
125 template<
126  typename IMPL,
127  typename H,
128  typename T,
129  typename C
130 >
131 void HeapBase<IMPL, H, T, C>::merge(IMPL &/*other*/) {
132  throw std::runtime_error("Merging two binary heaps is not supported");
133 }
134 
135 }
Pairing heap node.
Definition: PairingHeap.h:43
virtual const T & value(const Handle handle) const =0
Returns the value of that handle.
virtual void decrease(Handle handle, const T &value)=0
Decreases a single value.
virtual const C & comparator() const
Returns the comparator used to sort the values in the heap.
Definition: HeapBase.h:75
HeapBase(C const &comp=C())
Definition: HeapBase.h:68
Basic declarations, included by all source files.
Common interface for all heap classes.
Definition: HeapBase.h:55
virtual void merge(IMPL &other)
Merges in values of other heap.
Definition: HeapBase.h:131
virtual void pop()=0
Removes the topmost value from the heap.
The namespace for all OGDF objects.
virtual const T & top() const =0
Returns the topmost value in the heap.
virtual Handle push(const T &value)=0
Inserts a value into the heap.