STL Heap Algorithms
No, it doesn't. Why not? Well, to have a separate heap container class would be redundant since a heap is just a vector in which the values have a certain arrangement. What it does have, instead, is some algorithms especially designed for working with vectors that are heaps, or that we want to be heaps.
There are four STL algorithms that are quite useful when you are dealing with a heap structure:
As is often the case when dealing with the STL, not all of them work exactly the way you might guess they would.
For purposes of describing how they do work, assume we have a vector of integers v, of arbitrary size, and containing values in some arbitrary (random, or unsorted) order. We could also have an array, for example, and of course the component value does not have to be integer. Also, we assume we are dealing with a "maximum heap", but "minimum heaps" are also possible.
Each algorithm is shown in the form of a typical call to that algorithm. This does not show the return type, which is void in each case, nor the parameter types, both of which must be random access iterators. Each of the algorithms has a second version which takes a third parameter to indicate how comparison of elements is to be performed.