TPIE

2362a60
pq_overflow_heap.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2008, 2012, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
24 
25 #ifndef _TPIE_PQ_OVERFLOW_HEAP_H_
26 #define _TPIE_PQ_OVERFLOW_HEAP_H_
27 
29 
30 namespace tpie {
31 
38 template<typename T, typename Comparator = std::less<T> >
40 public:
46  pq_overflow_heap(memory_size_type maxsize, Comparator c=Comparator());
47 
53  void push(const T& x);
54 
58  void pop();
59 
65  const T& top();
66 
72  stream_size_type size() const;
73 
79  bool empty() const;
80 
84  static const double sorted_factor;
85 
91  bool full() const;
92 
99  T* sorted_array();
100 
106  memory_size_type sorted_size() const;
107 
111  void sorted_pop();
112 
113 private:
114  Comparator comp;
116  memory_size_type maxsize;
117  //T dummy;
118 };
119 
120  template<typename T, typename Comparator>
122 
123 #include "pq_overflow_heap.inl"
124 
125  namespace ami {
127  } // ami namespace
128 
129 } // tpie namespace
130 
131 #endif
void pop()
Remove the top element from the priority queue.
pq_overflow_heap(memory_size_type maxsize, Comparator c=Comparator())
Constructor.
Simple heap based priority queue implementation.
void push(const T &x)
Insert an element into the priority queue.
void sorted_pop()
Remove all elements from queue.
bool empty() const
Return true if queue is empty otherwise false.
stream_size_type size() const
Returns the size of the queue.
const T & top()
See what's on the top of the priority queue.
T * sorted_array()
Sorts the underlying array and returns a pointer to it, this operation invalidates the heap...
Overflow Priority Queue, based on a simple Heap.
static const double sorted_factor
The factor of the size, total, which is returned sorted.
bool full() const
Returns whether the overflow heap is full or not.
memory_size_type sorted_size() const
Return size of sorted array.