16 #ifndef STXXL_PQ_HELPERS_HEADER
17 #define STXXL_PQ_HELPERS_HEADER
21 __STXXL_BEGIN_NAMESPACE
29 namespace priority_queue_local
37 template <
typename _Tp,
typename _Sequence = std::vector<_Tp>,
38 typename _Compare = std::less<
typename _Sequence::value_type> >
42 typedef typename _Sequence::value_type _Sequence_value_type;
45 typedef typename _Sequence::value_type value_type;
46 typedef typename _Sequence::reference reference;
47 typedef typename _Sequence::const_reference const_reference;
48 typedef typename _Sequence::size_type size_type;
49 typedef _Sequence container_type;
55 size_type current_size;
63 : heap(capacity), current_size(0)
71 {
return current_size == 0; }
76 {
return current_size; }
97 push(
const value_type & __x)
99 heap[current_size] = __x;
101 std::push_heap(heap.begin(), heap.begin() + current_size, comp);
118 std::pop_heap(heap.begin(), heap.begin() + current_size, comp);
128 sort(heap.begin(), heap.begin() + current_size, comp);
129 std::reverse_copy(heap.begin(), heap.begin() + current_size, target);
144 template <
class Predicate,
typename first_argument_type,
typename second_argument_type>
154 bool operator () (
const first_argument_type & x,
const second_argument_type & y)
const
166 template <
typename Tp_,
unsigned_type max_size_>
169 typedef Tp_ value_type;
170 typedef unsigned_type size_type;
171 enum { max_size = max_size_ };
174 value_type array[max_size];
179 void push(
const value_type & x)
181 assert(size_ < max_size);
185 const value_type & top()
const
188 return array[size_ - 1];
202 size_type size()
const
216 __STXXL_END_NAMESPACE
218 #endif // !STXXL_PQ_HELPERS_HEADER
const_reference top() const
Definition: pq_helpers.h:83
void sort(ExtIterator_ first, ExtIterator_ last, StrictWeakOrdering_ cmp, unsigned_type M)
Sort records comparison-based.
Definition: sort.h:700
bool empty() const
Definition: pq_helpers.h:70
Inverts the order of a comparison functor by swapping its arguments.
Definition: pq_helpers.h:145
void clear()
Remove all contained elements.
Definition: pq_helpers.h:135
void sort_to(value_type *target)
Sort all contained elements, write result to target.
Definition: pq_helpers.h:125
Similar to std::priority_queue, with the following differences:
Definition: pq_helpers.h:39
internal_priority_queue(size_type capacity)
Default constructor creates no elements.
Definition: pq_helpers.h:62
void push(const value_type &__x)
Add data to the queue.
Definition: pq_helpers.h:97
Similar to std::stack, with the following differences:
Definition: pq_helpers.h:167
void pop()
Removes first element.
Definition: pq_helpers.h:116
size_type size() const
Definition: pq_helpers.h:75