sort_heap

sort_heap

template<class RanIt>
    void sort_heap(RanIt first, RanIt last);
template<class RanIt, class Pred>
    void sort_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 sequence that is ordered byoperator<. The original sequence must designate a heap, also ordered byoperator<. Thus, the elements are sorted in ascending order.

The function evaluates the ordering predicate X < Y at most ceil((last - first) * log(last - first)) times.

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).