Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BucketPriorityQueue.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <functional>
5#include <unordered_map>
6#include <vector>
7
9
10namespace storm::dft {
11namespace storage {
12
18template<class PriorityType>
20 using PriorityTypePointer = std::shared_ptr<PriorityType>;
21
22 public:
30 explicit BucketPriorityQueue(size_t nrBuckets, double lowerValue, double ratio, bool higher);
31
33
34 virtual ~BucketPriorityQueue() = default;
35
36 void fix();
37
42 bool empty() const;
43
48 std::size_t size() const;
49
54 PriorityTypePointer const& top() const;
55
60 void push(PriorityTypePointer const& item);
61
67 void update(PriorityTypePointer const& item, double oldPriority);
68
73 PriorityTypePointer pop();
74
79 void print(std::ostream& out) const;
80
85 void printSizes(std::ostream& out) const;
86
87 private:
93 size_t getBucket(double priority) const;
94
95 // List of buckets
96 std::vector<std::vector<PriorityTypePointer>> buckets;
97
98 // Bucket containing all items which should be considered immediately
99 std::vector<PriorityTypePointer> immediateBucket;
100
101 // Index of first bucket which contains items
102 size_t currentBucket;
103
104 // Number of unsorted items in current bucket
105 size_t nrUnsortedItems;
106
107 // Comparison function for priorities
108 std::function<bool(PriorityTypePointer, PriorityTypePointer)> compare;
109
110 // Minimal value
111 double lowerValue;
112
113 bool higher;
114
115 bool AUTOSORT = false;
116
117 double logBase;
118
119 // Number of available buckets
120 size_t nrBuckets;
121};
122
123} // namespace storage
124} // namespace storm::dft
Priority queue based on buckets.
void update(PriorityTypePointer const &item, double oldPriority)
Update existing element.
void print(std::ostream &out) const
Print info about priority queue.
void push(PriorityTypePointer const &item)
Add element.
BucketPriorityQueue(BucketPriorityQueue const &queue)=default
PriorityTypePointer const & top() const
Get element with highest priority.
PriorityTypePointer pop()
Get element with highest priority and remove it from the queue.
std::size_t size() const
Return number of entries.
void printSizes(std::ostream &out) const
Print sizes of buckets.
bool empty() const
Check whether queue is empty.