Member of System.Collection.Queue
Meaning in Life
Dequeue()
Removes and returns the object at the beginning of the
Queue
Enqueue()
Adds an object to the end of the Queue
Peek()
Returns the object at the beginning of the Queue without
removing it
To illustrate these methods, we will leverage our automobile theme once again and build a
Queue object that simulates a line of cars waiting to enter a car wash. First, assume the following
static helper method:
static void WashCar(Car c)
{
Console.WriteLine("Cleaning {0}", c.PetName);
}
Now assume this additional helper method, which calls WashCar() internally:
static void QueueTest()
{
Console.WriteLine("\n=> Queue Test:\n");
Do'stlaringiz bilan baham: |