Name
push_heap function template — Adds a value to a heap
Synopsis
template<typename RandIter> void push_heap(RandIter first, RandIter last); template<typename RandIter, typename Compare> void push_heap(RandIter first, RandIter last, Compare comp);
The push_heap
function
template adds the item at last
-
1 to the heap in [first
, last
- 1), forming a new heap in the range
[first
, last
).
The first form compares values using the <
operator. The second form calls
comp(*iter1
, *iter2)
.
Technical Notes
Precondition: [first,
last - 1) is a heap (see
make_heap
for the definition of a
heap).
Postcondition: [first, last) is a heap.
Complexity is logarithmic: at most log(last - first) comparisons are performed.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.