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.

How to use this reference page

Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.

  • Scan the top of the page first to identify the primary types, functions, or algorithm families involved.
  • Use the nearby-page links when your question is really about a companion header, related algorithm family, or broader subsystem.
  • Validate tricky behavior with a small compileable example before relying on memory for details like invalidation, ordering, allocation, or lifetime rules.

All Heap Algorithms

Core heap algorithms

Ranges equivalents

Practical rules

Example in practice

#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();
}