// queue example
//
// - a queue is a first-in-first-out container adapter
// - when you insert an item, it goes to the back
// - when you take an item, you take from the front
// - the closest analogy is standing in a line at a bank
// - see http://www.cppreference.com/cppqueue.html

#include <queue>
#include <iostream>

using namespace std;

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

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

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

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

  return 0;
}
