title: How to tell a std::priority_queue to refresh its ordering?
body: <p>I have a priority queue of pointers to a <code>struct city</code>. I modify the objects pointed by these pointers outside the priority queue, and want to tell the priority queue to "reorder" itself according to the new values.</p>
  
  <p>What should I do?</p>
  
  <p>Example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  
  using namespace std;
  
  struct city {
      int data;
      city *previous;
  };
  
  struct Compare {
      bool operator() ( city *lhs, city *rhs )
      {
          return ( ( lhs -&gt; data ) &gt;= ( rhs -&gt; data ) );
      }
  };
  
  typedef priority_queue&lt; city *, vector&lt; city * &gt;, Compare &gt; pqueue;
  
  int main()
  {
      pqueue cities;
  
      city *city1 = new city;
      city1 -&gt; data = 5;
      city1 -&gt; previous = NULL;
      cities.push( city1 );
  
      city *city2 = new city;
      city2 -&gt; data = 3;
      city2 -&gt; previous = NULL;
      cities.push( city2 );
  
      city1 -&gt; data = 2;
      // Now how do I tell my priority_queue to reorder itself so that city1 is at the top now?
  
      cout &lt;&lt; ( cities.top() -&gt; data ) &lt;&lt; "\n";
      // 3 is printed :(
  
      return 0;
  }
  </code></pre>