// priority queue max example
//
// - contains the same methods of a queue, but removes them in order
// - this example shows how to return the greatest element in the queue
// - see http://www.cppreference.com/cpppriorityqueue.html

#include <queue>
#include <iostream>

using namespace std;

int main()
{
  priority_queue<int> q; // create a priority queue max of integers

             // front <--> back
  q.push(5); // 5
  q.push(4); // 5 4
  q.push(7); // 7 5 4
  q.push(9); // 9 7 5 4
  q.push(2); // 9 7 5 4 2
  q.push(3); // 9 7 5 4 3 2

  cout << "priority queue max q has " << q.size() << " elements" << endl;

  cout << "priority queue max from the front contains ";
  while (!q.empty()) { // until the queue is not empty
    cout << q.top() << " ";   // returns the front element
    q.pop();                  // removes the front element
  }
  cout << endl;

  return 0;
}
