Rolf Magnus wrote:
Henning Hasemann wrote:
I'm using a stl-priority queue and want
- find out if a certain item is contained in the queue
- to be able iterate over all items without having to pop() them, order
does not matter.
I couldnt find methods for these which suprises me as both should be
easily solvable with access to the underlying vector.
Well, they are not operations that are supposed to be done with a queue.
There is not much point in making a queue that offers random access. It
just wouldn't qualify as queue anymore.
I dont want random access. I just want a way to read all elements
without having to deconstruct the queue. (read-only acces is enough for me)
Did I just miss these methods? Can I somehow access the vector to get .
begin() .end() and .find()?
If you want the functionality of a vector, just use a vector.
That comment was rather unhelpful.
I want the functionality of a priority_queue because I need fast access
to the "highest" element.
I also need to be able to find out if a certain element is contained.
Iterating isnt even necessary if I'd had only a contains()-method or
something.
To give you the whole picture I'm talking about a container for the
open-"list" used in the dijkstra algorithm and the 3 operations done
with it are inerting an element, getting and removing the element with
the highest value and testing if a certain element is contained.
Unfortunately the code is really time-critical and using a list and
insertion sort is simply to slow.
Use private inheritance to inherit from priority_queue(). The
underlying container is a protected member. Make sure you make the