C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Using Queue in C#


Posted Date: 20 Sep 2005    Resource Type: Articles    Category: .NET Framework
Author: VijayakumaranMember Level: Silver    
Rating: 1 out of 5Points: 7



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.





Responses

Author: codedefiner    25 Jul 2009Member 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 2009Member Level: Bronze   Points : 1
for more on Queuea in vb.net


Author: Abhi    20 Aug 2009Member Level: Diamond   Points : 1
Hi Vijayakumaran,

good one .

keep it up.

contribute more.

Thanks and Regards
Abhay


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Understanding Garbage Collection in C#
Previous Resource: Using Stack in C#
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use