16 #ifndef STXXL_CONTAINERS_PQ_HELPERS_HEADER
17 #define STXXL_CONTAINERS_PQ_HELPERS_HEADER
37 #if defined(STXXL_PARALLEL_MODE) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) < 40400)
38 #undef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_INTERNAL
39 #undef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_EXTERNAL
40 #undef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_DELETE_BUFFER
41 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_INTERNAL 0
42 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_EXTERNAL 0
43 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_DELETE_BUFFER 0
47 #ifndef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_INTERNAL
48 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_INTERNAL 1
50 #ifndef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_EXTERNAL
51 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_EXTERNAL 1
53 #ifndef STXXL_PARALLEL_PQ_MULTIWAY_MERGE_DELETE_BUFFER
54 #define STXXL_PARALLEL_PQ_MULTIWAY_MERGE_DELETE_BUFFER 1
57 #endif //STXXL_PARALLEL
59 #if STXXL_PARALLEL && STXXL_PARALLEL_PQ_MULTIWAY_MERGE_EXTERNAL
60 #define STXXL_PQ_EXTERNAL_LOSER_TREE 0 // no loser tree for the external sequences
62 #define STXXL_PQ_EXTERNAL_LOSER_TREE 1
65 #if STXXL_PARALLEL && STXXL_PARALLEL_PQ_MULTIWAY_MERGE_INTERNAL
66 #define STXXL_PQ_INTERNAL_LOSER_TREE 0 // no loser tree for the internal sequences
68 #define STXXL_PQ_INTERNAL_LOSER_TREE 1
71 #define STXXL_VERBOSE_PQ(msg) STXXL_VERBOSE2("[" << static_cast<void*>(this) << "] priority_queue::" << msg)
82 namespace priority_queue_local {
90 template <
typename _Tp,
typename _Sequence = std::vector<_Tp>,
91 typename _Compare = std::less<
typename _Sequence::value_type> >
114 : heap(capacity), current_size(0)
120 {
return current_size == 0; }
125 {
return current_size; }
148 heap[current_size] = __x;
150 std::push_heap(heap.begin(), heap.begin() + current_size, comp);
167 std::pop_heap(heap.begin(), heap.begin() + current_size, comp);
176 sort(heap.begin(), heap.begin() + current_size, comp);
177 std::reverse_copy(heap.begin(), heap.begin() + current_size, target);
188 template <
class Predicate,
typename first_argument_type,
typename second_argument_type>
198 bool operator () (
const first_argument_type& x,
const second_argument_type& y)
const
209 template <
typename Tp_,
unsigned_type max_size_>
214 enum { max_size = max_size_ };
224 assert(size_ < max_size);
231 return array[size_ - 1];
262 #endif // !STXXL_CONTAINERS_PQ_HELPERS_HEADER
_Sequence::const_reference const_reference
_Sequence::value_type _Sequence_value_type
void sort(ExtIterator first, ExtIterator last, StrictWeakOrdering cmp, unsigned_type M)
Sort records comparison-based, see stxxl::sort -- Sorting Comparison-Based.
Inverts the order of a comparison functor by swapping its arguments.
void pop()
Removes first element.
void check_sort_settings()
void sort_to(value_type *target)
Sort all contained elements, write result to target.
Similar to std::stack, with the following differences:
_Sequence::size_type size_type
#define STXXL_BEGIN_NAMESPACE
void push(const value_type &__x)
Add data to the queue.
internal_priority_queue(size_type capacity)
Default constructor creates no elements.
Similar to std::priority_queue, with the following differences:
invert_order(const Predicate &_pred)
size_type size() const
Returns the number of elements in the queue.
void push(const value_type &x)
_Sequence::reference reference
bool empty() const
Returns true if the queue is empty.
_Sequence::value_type value_type
choose_int_types< my_pointer_size >::unsigned_type unsigned_type
const_reference top() const
Returns a read-only (constant) reference to the data at the first element of the queue.
const value_type & top() const
void clear()
Remove all contained elements.
#define STXXL_END_NAMESPACE