Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PriorityQueue.hxx
Go to the documentation of this file.
1 #ifndef PRIORITY_QUEUE_HXX_
2 #define PRIORITY_QUEUE_HXX_
3 
4 #include <vector>
5 #include <algorithm>
6 
10 template <typename T, typename Comparator = std::less<T>> class PriorityQueue
11 {
12 public:
13  using Container = std::vector<T>;
15  using value_compare = Comparator;
16  using value_type = typename Container::value_type;
17  using size_type = typename Container::size_type;
18  using reference = typename Container::reference;
19  using const_reference = typename Container::const_reference;
20  using allocator_type = typename Container::allocator_type;
21  using different_type = typename Container::difference_type;
22  using pointer = typename Container::pointer;
23  using const_pointer = typename Container::const_pointer;
24  using iterator = typename Container::iterator;
25  using const_iterator = typename Container::const_iterator;
26 
31  bool empty() const noexcept;
32 
37  reference top();
38 
43  const_reference top() const;
44 
49  void push(value_type &&element);
50 
55  void push(const value_type &element);
56 
60  void pop();
61 
66  template <typename Predicate> size_type erase_if(Predicate &&predicate);
67 
71  void clear(void) noexcept;
72 
73 private:
75 };
76 
77 #include "PriorityQueue.inl.hxx"
78 
79 #endif // PRIORITY_QUEUE_HXX_
PriorityQueue::m_container
Container m_container
Definition: PriorityQueue.hxx:74
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::const_pointer
typename Container::const_pointer const_pointer
Definition: PriorityQueue.hxx:23
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::pointer
typename Container::pointer pointer
Definition: PriorityQueue.hxx:22
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::value_type
typename Container::value_type value_type
Definition: PriorityQueue.hxx:16
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::iterator
typename Container::iterator iterator
Definition: PriorityQueue.hxx:24
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::different_type
typename Container::difference_type different_type
Definition: PriorityQueue.hxx:21
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::reference
typename Container::reference reference
Definition: PriorityQueue.hxx:18
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::const_iterator
typename Container::const_iterator const_iterator
Definition: PriorityQueue.hxx:25
PriorityQueue::empty
bool empty() const noexcept
Check whether queue is empty.
Definition: PriorityQueue.inl.hxx:1
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::value_compare
std::greater< GameClock::ClockTask > value_compare
Definition: PriorityQueue.hxx:15
PriorityQueue::clear
void clear(void) noexcept
Remove all elements from queue.
Definition: PriorityQueue.inl.hxx:53
PriorityQueue
Priority queue with erase element functionality.
Definition: PriorityQueue.hxx:10
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::size_type
typename Container::size_type size_type
Definition: PriorityQueue.hxx:17
PriorityQueue::pop
void pop()
Remove first element from the queue (from top).
Definition: PriorityQueue.inl.hxx:30
PriorityQueue::erase_if
size_type erase_if(Predicate &&predicate)
Remove all elements from queue for which predicate returns true.
Definition: PriorityQueue.inl.hxx:38
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::allocator_type
typename Container::allocator_type allocator_type
Definition: PriorityQueue.hxx:20
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::Container
std::vector< GameClock::ClockTask > Container
Definition: PriorityQueue.hxx:13
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::container_type
Container container_type
Definition: PriorityQueue.hxx:14
PriorityQueue::push
void push(value_type &&element)
Add new element to the queue.
Definition: PriorityQueue.inl.hxx:18
PriorityQueue< GameClock::ClockTask, std::greater< GameClock::ClockTask > >::const_reference
typename Container::const_reference const_reference
Definition: PriorityQueue.hxx:19
PriorityQueue::top
reference top()
Get top element from the queue.
Definition: PriorityQueue.inl.hxx:7