STL: heap相关算法
make_heap
Converts elements from a specified range into a heap in which the first element is the largest and for which a sorting criterion may be specified with a binary predicate.
template<class RandomAccessIterator> void make_heap( RandomAccessIterator _First, RandomAccessIterator _Last ); template<class RandomAccessIterator, class BinaryPredicate> void make_heap( RandomAccessIterator _First, RandomAccessIterator _Last, BinaryPredicate _Comp );
pop_heap
Removes the largest element from the front of a heap to the next-to-last position in the range and then forms a new heap from the remaining elements.
template<class RandomAccessIterator> void pop_heap( RandomAccessIterator _First, RandomAccessIterator _Last ); template<class RandomAccessIterator, class BinaryPredicate> void pop_heap( RandomAccessIterator _First, RandomAccessIterator _Last, BinaryPredicate _Comp );
push_heap
Adds an element that is at the end of a range to an existing heap consisting of the prior elements in the range.
template<class RandomAccessIterator> void push_heap( RandomAccessIterator _First, RandomAccessIterator _Last ); template<class RandomAccessIterator, class BinaryPredicate> void push_heap( RandomAccessIterator _First, RandomAccessIterator _Last, BinaryPredicate _Comp );
注,The element must first be pushed back to the end of an existing heap and then the algorithm is used to add this element to the existing heap.
sort_heap
Converts a heap into a sorted range
template<class RandomAccessIterator> void sort_heap( RandomAccessIterator _First, RandomAccessIterator _Last ); template<class RandomAccessIterator, class Predicate> void sort_heap( RandomAccessIterator _First, RandomAccessIterator _Last, Predicate _Comp );