Skip to content
Sean Raven edited this page Oct 28, 2015 · 1 revision

A Queue is a first-in, first-out (FIFO) structure. It is used by certain algorithms which must process items in the order they were encountered.

Java's ArrayDeque can be used directly as a Queue.

Note that in C++, you must use top() to retrieve the item before using pop() to remove it from the queue, whereas in Java, remove() returns the item it is removing.

  • C++: int item = q.top; q.pop()
  • Java: int item = q.remove();

Clone this wiki locally