All Set Algorithms

All Set Algorithms

A compact scan page for sorted-range set algorithms from <algorithm> and their ranges-based counterparts.

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 Set Algorithms

Classic set algorithms

Ranges equivalents

Preconditions that matter

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