Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

bprioqueue.inc
Go to the documentation of this file.
1 
29 #pragma once
30 
31 namespace abacus {
32 
33 
34 template<class Type, class Key>
36 { }
37 
38 
39 template<class Type, class Key>
40 void AbaPrioQueue<Type, Key>::insert(Type elem, Key key)
41 {
42  heap_.insert(elem, key);
43 }
44 
45 
46 template<class Type, class Key>
47 int AbaPrioQueue<Type, Key>::getMin(Type &min) const
48 {
50  if (heap_.empty()) return 1;
51 
52  min = heap_.getMin();
53  return 0;
54 }
55 
56 
57 template<class Type, class Key>
58 int AbaPrioQueue<Type, Key>::getMinKey(Key &minKey) const
59 {
61  if (heap_.empty()) return 1;
62 
63  minKey = heap_.getMinKey();
64  return 0;
65 }
66 
67 
68 template<class Type, class Key>
70 {
72  if (heap_.empty()) return 1;
73 
74  min = heap_.extractMin();
75  return 0;
76 }
77 
78 
79 template<class Type, class Key>
81 {
82  heap_.clear();
83 }
84 
85 
86 template<class Type, class Key>
87 inline int AbaPrioQueue<Type, Key>::size() const
88 {
89  return heap_.size();
90 }
91 
92 
93 template<class Type, class Key>
94 inline int AbaPrioQueue<Type, Key>::number() const
95 {
96  return heap_.number();
97 }
98 
99 
100 template<class Type, class Key>
101 void AbaPrioQueue<Type, Key>::realloc(int newSize)
102 {
103  if (newSize < size()) {
104  Logger::ifout() << "AbaPrioQueue::realloc : priority queue cannot be decreased\n";
105  OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::BPrioQueue);
106  }
107 
108  heap_.realloc(newSize);
109 }
110 
111 }
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.