Advanced topics
Queue data structures can be built on several different underlying data structures. Each foundation provides different advantages, and the type that is chosen typically depends on the application's needs. The three most common implementations are array based, linked list based, and heap-based.
Queue data structures are also found in two additional variations, including the double-ended queue and the priority queue. Again, each variation offers advantages and disadvantages and the type that is chosen will largely depend on the needs of your application.
Array-based queues
Array-based queues utilize a mutable array to represent the queue. Both of the examples in Objective-C and Swift take this form. In this implementation, the [0]
position of the array represents the head or front of the queue. Although, generally speaking, queues are strictly FIFO collections and developers should not attempt to sort them, array-based queues are particularly difficult and costly to sort. If your...