Tapkee
reservable_priority_queue.hpp
Go to the documentation of this file.
1 /* This software is distributed under BSD 3-clause license (see LICENSE file).
2  *
3  * Copyright (c) 2012-2013 Sergey Lisitsyn
4  */
5 
6 #ifndef RESERVABLE_PRIORITY_QUEUE_H_
7 #define RESERVABLE_PRIORITY_QUEUE_H_
8 
9 #include <queue>
10 #include <vector>
11 
12 namespace tapkee
13 {
14 namespace tapkee_internal
15 {
16 
17 //#pragma GCC diagnostic ignored "-Weffc++"
18 template <class T, class Comparator>
19 class reservable_priority_queue: public std::priority_queue<T,std::vector<T>,Comparator>
20 {
21 public:
22  typedef typename std::priority_queue<T>::size_type size_type;
23  reservable_priority_queue(size_type initial_capacity=0)
24  {
25  reserve(initial_capacity);
26  }
27  void reserve(size_type initial_capacity)
28  {
29  this->c.reserve(initial_capacity);
30  }
31  size_type capacity() const
32  {
33  return this->c.capacity();
34  }
35  void clear()
36  {
37  this->c.clear();
38  }
39 };
40 //#pragma GCC diagnostic pop
41 
42 } /* End of namespace tapkee_internal */
43 } /* End of namespace tapkee */
44 
45 #endif