25 Algorithms library [algorithms]

25.8 Sorting and related operations [alg.sorting]

25.8.8 Heap operations [alg.heap.operations]

25.8.8.1 General [alg.heap.operations.general]

A random access range [a, b) is a heap with respect to comp and proj for a comparator and projection comp and proj if its elements are organized such that:
  • With N = b - a, for all i, , bool(invoke(comp, invoke(proj, a[]), invoke(​proj, a[i]))) is false.
  • *a may be removed by pop_­heap, or a new element added by push_­heap, in time.
These properties make heaps useful as priority queues.
make_­heap converts a range into a heap and sort_­heap turns a heap into a sorted sequence.