All Heap Algorithms
All Heap Algorithms
A compact scan page for heap construction, maintenance, and ordering algorithms from <algorithm> and the related priority_queue context.
All Heap Algorithms
A compact scan page for heap construction, maintenance, and ordering algorithms from <algorithm> and the related priority_queue context.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
make_heappush_heappop_heapsort_heapis_heapis_heap_untilstd::ranges::make_heapstd::ranges::push_heapstd::ranges::pop_heapstd::ranges::sort_heapstd::ranges::is_heapstd::ranges::is_heap_untilpriority_queue wraps these ideas behind an adapter interface.pop_heap, the last element holds the former top heap element but is still part of the sequence until removed explicitly.#include <algorithm>
#include <vector>
int main() {
std::vector<int> values{7, 2, 5, 1};
std::ranges::make_heap(values);
std::ranges::pop_heap(values);
return values.back();
}