Storm
A Modern Probabilistic Model Checker
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DynamicPriorityQueue.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DYNAMICPRIORITYQUEUE_H_
2#define STORM_STORAGE_DYNAMICPRIORITYQUEUE_H_
3
4#include <algorithm>
5#include <vector>
6
7namespace storm {
8namespace storage {
9
10template<typename T, typename Container = std::vector<T>, typename Compare = std::less<T>>
12 private:
13 Container container;
14 Compare compare;
15
16 public:
17 explicit DynamicPriorityQueue(Compare const& compare) : container(), compare(compare) {
18 // Intentionally left empty
19 }
20
21 explicit DynamicPriorityQueue(Container&& container, Compare const& compare) : container(std::move(container)), compare(compare) {
22 std::make_heap(container.begin(), container.end(), compare);
23 }
24
25 void fix() {
26 std::make_heap(container.begin(), container.end(), compare);
27 }
28
29 bool empty() const {
30 return container.empty();
31 }
32
33 std::size_t size() const {
34 return container.size();
35 }
36
37 const T& top() const {
38 return container.front();
39 }
40
41 void push(const T& item) {
42 container.push_back(item);
43 std::push_heap(container.begin(), container.end(), compare);
44 }
45
46 void push(T&& item) {
47 container.push_back(std::move(item));
48 std::push_heap(container.begin(), container.end(), compare);
49 }
50
51 void pop() {
52 std::pop_heap(container.begin(), container.end(), compare);
53 container.pop_back();
54 }
55
56 T popTop() {
57 T item = top();
58 pop();
59 return item;
60 }
61
62 Container getContainer() const {
63 return container;
64 }
65};
66} // namespace storage
67} // namespace storm
68
69#endif // STORM_STORAGE_DYNAMICPRIORITYQUEUE_H_
DynamicPriorityQueue(Container &&container, Compare const &compare)
LabParser.cpp.
Definition cli.cpp:18