forked from ad-freiburg/util
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueue.h
More file actions
39 lines (31 loc) · 836 Bytes
/
Copy pathPriorityQueue.h
File metadata and controls
39 lines (31 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2019, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#ifndef UTIL_PRIORITYQUEUE_H_
#define UTIL_PRIORITYQUEUE_H_
#include<iomanip>
#include<queue>
#include<iostream>
namespace util {
template <typename K, typename V>
class PriorityQueue {
struct _ByFirst {
bool operator()(const std::pair<K, V>& a, const std::pair<K, V>& b) {
return a.first > b.first;
}
};
public:
PriorityQueue() : _last(std::numeric_limits<K>::lowest()) {}
void push(K k, const V& v);
const K topKey() ;
const V& topVal() ;
void pop();
bool empty() const;
private:
K _last;
std::priority_queue<std::pair<K, V>, std::vector<std::pair<K, V>>, _ByFirst>
_pq;
};
#include "util/PriorityQueue.tpp"
} // namespace util
#endif