Using queues to store data
A queue is an example of a dynamic data structure. This means the size of the queue can be changed at runtime. This is a huge advantage when it comes to programming in games. Queues are enqeued/inserted from the rear of the data structure and dequeued/deleted/pushed out from the front of the data structure. This makes it a first in first out (FIFO) data structure. Imagine, in a game, we have an inventory but we want to make the player use the first item he has picked up unless he manually changes to a different item. This can be easily achieved by a queue. If we want to design it so that the current item switches to the most powerful item in the inventory, we can use a priority queue for that purpose.
Getting ready
For this recipe, you will need a Windows machine with a working copy of Visual Studio.
How to do it…
In this recipe, we will implement the queue data structure using a linked list. It is very easy to implement a queue and it is a very robust data structure...