title: Can I access elements of a Priority Que using an iterator?
body: <h1>Vectors and Linked Lists</h1>
  <p>Vectors are stored in memory serially, and therefore any element may be accessed using the <code>operator[]</code>, just as in an array.</p>
  <p>A linked list contains elements which may not be stored continuously in memory, and therefore a random element must be accessed by following pointers, using an iterator.</p>
  <p>(You probably already knew this.)</p>
  <h1>Advantage of Priority Que</h1>
  <p>Recently I discovered the 'priority queue', which works kind of like a stack, but elements are <code>push()</code>-ed into the container, and this function places them in an order according to comparisons made with the <code>operator&lt;</code>, I believe.</p>
  <p>This suits me perfectly, as I am testing for events and placing them in the queue according to the time remaining until they occur. The queue automatically sorts them for me as I <code>push()</code> and <code>pop()</code> elements. (Popping does not affect the order.) I can write an <code>operator&lt;</code> so this isn't a problem.</p>
  <h1>Issues I have not been able to resolve</h1>
  <p>There are three things which I need to be able to do with this event queue:</p>
  <p>1:) Search the event queue for an item. I assume this can be done with an algorithm in the standard library? For example, 'find'? If not I can implement one myself, provided I can do point 2. (See below)</p>
  <p>2:) Iterate over the queue. I think the default underlying container is <code>std::vector</code>... Is there a way to access random elements within the underlying vector? What if I choose to use <code>std::deque</code> instead? I need to do this to modify certain event parameters. (Events are placed in the queue.) As an example, I may need to process an event and then subtract a constant amount of time from each remaining event's 'time_to_event' parameter. I suspect this cannot be done due to this <a href="https://stackoverflow.com/questions/4422933/random-access-priority-queue">question</a>.</p>
  <p>3:) Remove an element from the queue. Sometimes when processing events, other events become invalidated, and therefore need to be removed.</p>
  <p>Can points 1-3 be done? All the information I have on <code>std::priority_queue</code> has come from <a href="http://www.cplusplus.com/reference/queue/priority_queue/" rel="noreferrer">cplusplus.com</a>, and so my default answer would be &quot;no&quot;, there is no way to do any of these things. If I can't do all three things, then I guess I will have to write my own Priority Queue wrapper. (Oh boring)</p>