Get full access to Data Structures and Algorithms in Swift: Implement Stacks, Queues, Dictionaries, and Lists in Your Apps and 60K+ other titles, with free 10-day trial of O'Reilly.
There's also live online events, interactive content, certification prep materials, and more.
A queue is a first in first out (FIFO) data structure which means first come first serve. It is also known as “waiting lines,” and as the name suggests, it can be easily imagined as a group of people waiting in a line (Figure 5-1).
Figure 5-1
Typical queue structure
When a new person comes, he stands at the end of the line conveniently adding data to a queue; the data is placed at the end. The term “enqueue” is used to refer to the act of adding an element to a queue. When extracting data ...
Get Data Structures and Algorithms in Swift: Implement Stacks, Queues, Dictionaries, and Lists in Your Apps now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.