O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Queue

A queue is a first-in, first-out (FIFO) collection. Basic operations are Enqueue and Dequeue, respectively, to add an element to the end of the queue and to retrieve the first element in the queue. Compare this to a queue in the supermarket: If you’re in front, you are served first. Figure 16.3 illustrates the principle of a queue’s operation.

Image

FIGURE 16.3 Dequeue, Peek, and Enqueue operations on a queue data structure.

The following is a real-world example of a queue:

var postOffice = new Queue();postOffice.Enqueue(new Person("Bart", 10));postOffice.Enqueue(new Person("Homer", 38));postOffice.Enqueue(new Person("Ned", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required