OK ... as we mentioned last time

the
STL does not have as part of its ... collection of facilities a heap structure

but
that is unnecessary because as we know ... as we saw last time

the
way we deal with heaps is to put ... the things that we want to contain in the heap

in
a vector

and
then we have some ... heap algorithms that are provided by the STL for manipulating that vector

and
unlike the other kinds of trees that we talked about ... which is to stay expression trees

and
binary search trees

the
representation ... the behind the scenes implementation

of
the heap structure ... the structure we use for a heap

is
not an actual tree structure like it was in those earlier cases

it is
a contiguous structure namely a vector

so
for that reason because the STL already has a vector

of
course all we really need if we want to make use of a heap ... in the STL is to use a vector and use the heap algorithms

in actual fact what. ..what is going on is that ... is that the ...
algorithms
make use of random access iterators right

so
that immediately tells you that you don't necessarily need a vector
and
you could in fact use a deck because a deck also provides ... as we know random access iterators

and


and
so you could use either one of those but you could not for example use a list ... to store the elements of a heap because these algorithms would then not apply

because
a list only has a bidirectional iterator

so
what algorithms do we have available then ... well these are the four so called heap algorithms provided by the STL

the
make heap

and
what that does of course is to take a vector or a deck containing an arbitrary bunch of
values

and
turn those values into a ... maximum heap by default OK

push
heap does the obvious thing ... it takes a value and puts it into the heap

pop
heap again does the obvious thing it takes a value out of the heap

all
of these algorithms by the way are void functions and so none of them returns anything

so
in particular the pop heap does not return the value that it pops

it
simply removes the value

and
sort heap ... sorts the values in the container being used for the heap ... and coming back to your question ... from last time

see

the
question was ... since the way the heap behaves ... if you take something out of the heap what you get is the largest value if it's a maximum heap or the optimum value

if
... some other criterion is being used ... to compare elements

and
in fact all of these algorithms ... the default interface for these algorithms by the way

here's
a little more detail on each of the algorithms ... the default interface is the two parameter interface right and on this page I've given those interfaces using a vector OK

a little more generic treatment would have simply