pop_heap
pop_heap
template<class RanIt>
void pop_heap(RanIt first, RanIt last);
template<class RanIt, class Pred>
void pop_heap(RanIt first, RanIt last, Pred pr);
The first template function reorders the sequence designated by iterators in the range [first, last)
to form a new heap, ordered byoperator<
and designated by iterators in the range [first, last - 1)
, leaving the original element at *first
subsequently at *(last - 1)
. The original sequence must designate an existing heap, also ordered by operator<
. Thus, first != last
must be true and *(last - 1)
is the element to remove from (pop off) the heap.
The function evaluates the ordering predicate X < Y``ceil(2 * log(last - first))
times, at most.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pr(X, Y)
.
Sample programs: heap and heap (predicate version).