Heaps
You can create with std::make_heap
a heap. You can push with std::push_heap
new elements on the heap. On the contrary, you can pop the largest element with std::pop_heap
from the heap. Both operations respect the heap characteristics. std::push_heap
moves the last element of the range on the heap; std::pop_heap
moves the biggest element of the heap to the last position in the range. You can check with std::is_heap
if a range is a heap. You can determine with std::is_heap_until
until which position the range is a heap. std::sort_heap
sorts the heap.
The heap algorithms require that the ranges and the algorithm use the same sorting criterion. If not, the program is undefined. Per default the predefined sorting criterion std::less
is used. If you use your sorting criterion, it has...