Files
2025-10-25 03:02:53 +03:00

3.6 KiB

[pop.heap]

26 Algorithms library [algorithms]

26.8.8 Heap operations [alg.heap.operations]

26.8.8.3 pop_heap [pop.heap]

🔗

`template constexpr void pop_heap(RandomAccessIterator first, RandomAccessIterator last);

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

template<random_access_iterator I, sentinel_for S, class Comp = ranges::less, class Proj = identity> requires sortable<I, Comp, Proj> constexpr I ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); template<random_access_range R, class Comp = ranges::less, class Proj = identity> requires sortable<iterator_t, Comp, Proj> constexpr borrowed_iterator_t ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); `

1

#

Let comp be less{} and proj be identity{} for the overloads with no parameters by those names.

2

#

Preconditions: The range [first, last) is a valid non-empty heap with respect to comp and proj.

For the overloads in namespace std,RandomAccessIterator meets the Cpp17ValueSwappable requirements ([swappable.requirements]) and the type of *first meets the Cpp17MoveConstructible (Table 31) andCpp17MoveAssignable (Table 33) requirements.

3

#

Effects: Swaps the value in the location first with the value in the locationlast - 1 and makes [first, last - 1) into a heap with respect to comp and proj.

4

#

Returns: last for the overloads in namespace ranges.

5

#

Complexity: At most 2log(last - first) comparisons and twice as many projections.