Three types of queues
We'll look at an application of the list structure to create a queue. A queue is a special kind of buffer, summarized as First In First Out (FIFO). The idea is to act as a temporary stash so one part of an application can write to the queue while another part consumes items from the queue.
A database might have a queue of data to be written to disk. When our application performs an update, the local cache version of the data is updated so all other applications can see the change. The write to the disk, however, may be placed in a queue for a writer to deal with a few milliseconds later.
When we're looking at files and directories, a queue can be a handy place to stash details of the directories so they can be processed later. We'll often represent a directory as the path from the root of the filesystem to the file of interest. We'll look at
Path objects in detail in Chapter 9, Strings, Serialization, and File Paths. The algorithm...