A queue is a pattern that is frequently used in computer science to implement a first in first out (FIFO) data buffer. The first thing to come into the queue is also the first thing to leave. This happens in an ordered fashion in order to process sorted data. Adding things to the queue is known as enqueueing the data into the queue, and removing it from the end of the queue is known as dequeuing. Queues are commonly used as a fixture in which data is stored and processed at another time.
Queues are beneficial because they don't have a fixed capacity. A new element can be added to the queue at any time, which makes a queue an ideal solution for asynchronous implementations such as a keyboard buffer or a printer queue. Queues are used in situations where tasks must be completed in the order that they were received, but when real-time occurs, it may not be possible...