Skip to the content of the web site.

The math library

A queue is a container that:

  • allows you to put objects into the container one at a time, and
  • when you ask for an object to be removed from the container, the object that has been in the container the longest is the one that is removed.

We use queues in real life: when you go to a bank, you wait in a queue (or line-up) and the next person to be served is the person at the front of the queue; that is, the person who has been waiting the longest to be served. Similarly, in a grocery store, you wait in a queue to have your groceries checked out.

Now, some questions you may have about the container include

  • how many items are in the queue, and
  • what is at the front (the next person to be served) of the queue?

The Standard Template Library

The std::queue data structure is very efficient, and has already been described.