Deep RTS
PriorityQueue.hpp
Go to the documentation of this file.
1//
2// Created by Per-Arne on 26.02.2017.
3//
4
5#ifndef WARC2SIM_PRIORITYQUEUE_H
6#define WARC2SIM_PRIORITYQUEUE_H
7
8#include <functional>
9#include <vector>
10#include <queue>
11#include <iostream>
12template<typename T, typename priority_t>
14 typedef std::pair<priority_t, T> PQElement;
15 std::priority_queue<PQElement, std::vector<PQElement>,
16 std::greater<PQElement>> elements;
17
18 inline bool empty() const { return elements.empty(); }
19
20 inline void put(T item, priority_t priority) {
21 elements.emplace(priority, item);
22 }
23
24 inline T get() {
25 T best_item = elements.top().second;
26 elements.pop();
27 return best_item;
28 }
29 inline void clear()
30 {
31
32 while(!empty()){
33
34 elements.pop();
35 }
36 }
37
38};
39#endif //WARC2SIM_PRIORITYQUEUE_H
Definition: PriorityQueue.hpp:13
void put(T item, priority_t priority)
Definition: PriorityQueue.hpp:20
std::priority_queue< PQElement, std::vector< PQElement >, std::greater< PQElement > > elements
Definition: PriorityQueue.hpp:16
void clear()
Definition: PriorityQueue.hpp:29
T get()
Definition: PriorityQueue.hpp:24
std::pair< priority_t, T > PQElement
Definition: PriorityQueue.hpp:14
bool empty() const
Definition: PriorityQueue.hpp:18