pop_heap


Pop the top element from a heap.

Starting with [ first ... last ) as a heap, swap the first and last elements on the heap [ first ... last ), then make [ first... ( last - 1 )) a heap. The first version uses operator< to perform the comparisons, whereas the second version uses the binary function compare .

Library

Standards<ToolKit>

Declaration


#include <algorithm>

template< class RandomAccessIterator >
void pop_heap
  (
  RandomAccessIterator first,
  RandomAccessIterator last
  );

template< class RandomAccessIterator, class Compare >
void pop_heap
  (
  RandomAccessIterator first,
  RandomAccessIterator last,
  Compare compare
  );
  

Complexity

Time complexity is 2 * log ( last - first ). Space complexity is constant.

Examples

See make_heap() .


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.