25 #ifndef _TPIE_PRIORITY_QUEUE_H_
26 #define _TPIE_PRIORITY_QUEUE_H_
28 #include <tpie/config.h>
42 #include <tpie/stream.h>
44 #include <boost/filesystem.hpp>
77 template<
typename T,
typename Comparator = std::less<T>,
typename OPQType = pq_overflow_heap<T, Comparator> >
79 typedef memory_size_type group_type;
80 typedef memory_size_type slot_type;
82 static constexpr
float default_blocksize = 0.0625;
90 priority_queue(
double f=1.0,
float b=default_blocksize, stream_size_type n = std::numeric_limits<stream_size_type>::max());
95 priority_queue(memory_size_type mm_avail,
float b=default_blocksize, stream_size_type n = std::numeric_limits<stream_size_type>::max());
104 static memory_size_type
memory_usage(stream_size_type n,
float b=default_blocksize);
120 void push(
const T& x);
145 stream_size_type
size()
const;
201 memory_size_type setting_k;
203 memory_size_type current_r;
205 memory_size_type setting_m;
207 memory_size_type setting_mmark;
209 memory_size_type slot_data_id;
211 stream_size_type m_size;
212 memory_size_type buffer_size;
213 memory_size_type buffer_start;
217 void init(memory_size_type mm_avail, stream_size_type n = std::numeric_limits<stream_size_type>::max() );
219 void slot_start_set(slot_type slot, memory_size_type n);
220 memory_size_type slot_start(slot_type slot)
const;
221 void slot_size_set(slot_type slot, memory_size_type n);
222 memory_size_type slot_size(slot_type slot)
const;
223 void group_start_set(group_type group, memory_size_type n);
224 memory_size_type group_start(group_type group)
const;
225 void group_size_set(group_type group, memory_size_type n);
226 memory_size_type group_size(group_type group)
const;
232 void slot_data_set(slot_type slotid, memory_size_type n);
233 temp_file & group_data(group_type groupid);
234 memory_size_type slot_max_size(slot_type slotid);
235 void write_slot(slot_type slotid, T* arr, memory_size_type len);
236 slot_type free_slot(group_type group);
237 void empty_group(group_type group);
239 void fill_group_buffer(group_type group);
240 void compact(slot_type slot);
242 void remove_group_buffer(group_type group);
246 #include "priority_queue.inl"
static memory_size_type memory_usage(stream_size_type n, float b=default_blocksize)
Compute the maximal amount of memory it makes sence to give a queue that will contain atmount n eleme...
External memory priority queue implementation.
Priority queue overflow heap.
Priority queue merge heap.
This file contains a few deprecated definitions for legacy code.
Logging functionality and log_level codes for different priorities of log messages.
Generic internal array with known memory requirements.
bool empty() const
Return true if queue is empty otherwise false.
Class representing a reference to a temporary file.
F pop_equals(F f)
Pop all elements with priority equal to that of the top element, and process each by invoking f's cal...
stream_size_type size() const
Returns the size of the queue.
~priority_queue()
Destructor.
const T & top()
See what's on the top of the priority queue.
std::unique_ptr< T, tpie_deleter > unique_ptr
like std::unique_ptr, but delete the object with tpie_delete.
void pop()
Remove the top element from the priority queue.
priority_queue(double f=1.0, float b=default_blocksize, stream_size_type n=std::numeric_limits< stream_size_type >::max())
Constructor.
void push(const T &x)
Insert an element into the priority queue.