Introduction
The Queue class implements a First In First Out data structure that places objects into a Queue. Object are inserted into the Queue at one end and removed from the other end. Sequential process of the objects are done inQueue.
Queue Interfaces
The queue class implements the three major collection interfaces. They are Icollection, Ienumerable and Icloneable.
Important Queue methods
The most commonly used methods exposed by the Queue class are
Enqueue - Adds a new item to the back of the Queue. Dequeue – Removes and returns an item from the front of the Queue. Peek - Returns an item from the front of the Queue but does not remove the item. Clear -Removes all the objects from the Queue. Contains – Returns true if the specified object is found in the Queue else returns false.
InvalidOperationException is thrown when an attempt to Dequeue or peek an empty queue is made.
We can specify the initial size of the Queue by passing the size to the Queue constructor.
Queue queue = new Queue(10); // here, the intitial size is 10.
We can also define the growth factor for the Queue object.One of the constructors of the Queue class allows us to specify the initial capacity for the Queue as well as its growth factor, as shown here.
Queue myQueue = new Queue(10, 4.0);
The default growth factor is 2.0 and the growth factor could be as large as 10.0;
Summary
The .NET framework also includes a wide variety of collection types, including types that implements Stack and HashTable.
|
| Author: codedefiner 25 Jul 2009 | Member Level: Bronze Points : 1 |
this is good explanation about Queue in vb.net.
You can find more about Queues in Vb.Net with example at
Queues in Vb.Net
|
| Author: codedefiner 08 Aug 2009 | Member Level: Bronze Points : 1 |
for more on Queuea in vb.net
|
| Author: Abhi 20 Aug 2009 | Member Level: Diamond Points : 1 |
Hi Vijayakumaran,
good one .
keep it up.
contribute more.
Thanks and Regards Abhay
|