
Creating Queues for In-Order Executions
A queue is a programming construct that bears a heavy resemblance to real-world queues, for example, a queue at the movie theater, ATMs, or the bank. Queues, as opposed to stacks, are first-in first-out (FIFO), so whatever goes in first comes out first as well. This is especially helpful when you would like to maintain data in the same sequence in which it flows in.
A more computer/scientific definition of a queue would be as follows:
An abstract data collection in which the elements can be added to the back called enqueue and removed from the front called dequeue which makes it a FIFO data structure.
Of course, having only enqueue and dequeue operations may be enough for the majority of cases to cover a wider spectrum of issues that we may encounter; however, we can expand the API and make our queue future-proof.
In this chapter, we will discuss the following topics:
- Types of queue
- Implementation of different types of queue
- Use cases showing the usefulness of queues
- Performance of queues as compared to other native data structures