J
J.M.
I would like to use a data structure (e.g. from the STL) that always allows
me to retrieve the largest element. (I want to push in elements, and remove
the largest, push in further elements, etc.) It seems a priority_queue from
the STL would work fine. However at some point, I am finished (even though
the queue is not empty) and want to throw away the rest of the elements. It
seems, I have to do this using:
while (!Q.empty()) Q.pop();
Other classes offer a resize() or a clear() and my guess that this is much
more efficient than using a while-loop. However, these functions are not
available for a priority_queue. Any ideas? Thanks in advance for any help.
Jan
me to retrieve the largest element. (I want to push in elements, and remove
the largest, push in further elements, etc.) It seems a priority_queue from
the STL would work fine. However at some point, I am finished (even though
the queue is not empty) and want to throw away the rest of the elements. It
seems, I have to do this using:
while (!Q.empty()) Q.pop();
Other classes offer a resize() or a clear() and my guess that this is much
more efficient than using a while-loop. However, these functions are not
available for a priority_queue. Any ideas? Thanks in advance for any help.
Jan