Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::priority_queue

 

std::priority_queue is an STL container that stores elements in a sorted order.

 

#include <cassert>
#include <queue>
#include <string>

int main()
{
  std::priority_queue<int> q;
  q.push(3);
  q.push(1);
  q.push(2);
  assert(q.top() == 3);
  q.pop();
  assert(q.top() == 2);
  q.pop();
  assert(q.top() == 1);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict