Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

bprioqueue.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #pragma GCC visibility push(default)
32 namespace abacus {
33 
34 
35 template<class Type, class Key>
37 { }
38 
39 
40 template<class Type, class Key>
41 void AbaPrioQueue<Type, Key>::insert(Type elem, Key key)
42 {
43  heap_.insert(elem, key);
44 }
45 
46 
47 template<class Type, class Key>
48 int AbaPrioQueue<Type, Key>::getMin(Type &min) const
49 {
51  if (heap_.empty()) return 1;
52 
53  min = heap_.getMin();
54  return 0;
55 }
56 
57 
58 template<class Type, class Key>
59 int AbaPrioQueue<Type, Key>::getMinKey(Key &minKey) const
60 {
62  if (heap_.empty()) return 1;
63 
64  minKey = heap_.getMinKey();
65  return 0;
66 }
67 
68 
69 template<class Type, class Key>
71 {
73  if (heap_.empty()) return 1;
74 
75  min = heap_.extractMin();
76  return 0;
77 }
78 
79 
80 template<class Type, class Key>
82 {
83  heap_.clear();
84 }
85 
86 
87 template<class Type, class Key>
88 inline int AbaPrioQueue<Type, Key>::size() const
89 {
90  return heap_.size();
91 }
92 
93 
94 template<class Type, class Key>
95 inline int AbaPrioQueue<Type, Key>::number() const
96 {
97  return heap_.number();
98 }
99 
100 
101 template<class Type, class Key>
102 void AbaPrioQueue<Type, Key>::realloc(int newSize)
103 {
104  if (newSize < size()) {
105  Logger::ifout() << "AbaPrioQueue::realloc : priority queue cannot be decreased\n";
106  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::BPrioQueue);
107  }
108 
109  heap_.realloc(newSize);
110 }
111 
112 }
113 #pragma GCC visibility pop
abacus::AbaPrioQueue::getMinKey
int getMinKey(Key &minKey) const
Retrieves the key of the minimal element in the priority queue.
abacus
Definition: ILPClusterPlanarity.h:50
ogdf::tlp::Attribute::size
@ size
abacus::AbaPrioQueue::AbaPrioQueue
AbaPrioQueue(int size)
The constructor of an empty priority queue.
abacus::AbaPrioQueue::insert
void insert(Type elem, Key key)
Inserts an element in the priority queue.
ogdf::AlgorithmFailureCode::BPrioQueue
@ BPrioQueue
abacus::AbaPrioQueue::getMin
int getMin(Type &min) const
Retrieves the element with minimal key from the priority queue.
abacus::AbaPrioQueue::number
int number() const
Returns the number of elements stored in the priority queue.
OGDF_THROW_PARAM
#define OGDF_THROW_PARAM(CLASS, PARAM)
Replacement for throw.
Definition: exceptions.h:71
ogdf::Logger::ifout
static std::ostream & ifout()
stream for forced output (global; used by internal libraries, e.g. Abacus)
Definition: Logger.h:218
abacus::AbaPrioQueue::clear
void clear()
Makes the priority queue empty.
abacus::AbaPrioQueue::realloc
void realloc(int newSize)
Increases the size of the priority queue.
abacus::AbaPrioQueue::extractMin
int extractMin(Type &min)
Retrieves and removes the minimal element from the priority queue.
abacus::AbaPrioQueue::size
int size() const
Returns the maximal number of elements which can be stored in the priority queue.