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

#include <queue>
#include <iostream>

using namespace std;

int main()
{
  // create a priority queue min of integers
  // - first template argument: what the container will contain
  // - second template argument: internal data structure
  // - third template argument: ordering method
  priority_queue<int, vector<int>, greater<int> > q;

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

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

  cout << "priority queue min 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;
}
