Chapter 5. Queues: FIFO Collections

A queue is an abstract data structure that serves as a linear collection of objects that are inserted and removed based on the first-in first-out (FIFO) principle. The two most notable operations of a queue are enqueue, which adds objects to the tail or back of the collection, and dequeue, which removes objects from the head or front of the collection. The following figure demonstrates the queue data structure as well as these two basic operations. Other common operations include peek, empty, and full, all of which will be examined later in this chapter:

Queues: FIFO Collections

Queues are very similar to stacks and they share some of ...

Get Everyday Data Structures now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.