GOA - System.Collections.Queue

Queue Class


Represents a first-in, first-out collection of objects.

Definition

public class Queue: Object, ICollection, ICloneable

Members Table

MethodDescription
ClearRemoves all objects from the Queue.
CloneCreates a shallow copy of the Queue.
ContainsDetermines whether an element is in the Queue.
CopyToCopies the Queue elements to an existing one-dimensional Array instance at the specified index.
DequeueRemoves and returns the object at the beginning of the Queue.
EnqueueAdds an object to the end of the Queue.
EqualsOverloaded. Compares two objects to determine if they are equal. (Inherited from Object)
GetEnumeratorReturns an enumerator that can iterate through the Queue.
GetHashCodeServes as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object)
GetTypeGets the Type of the current instance. (Inherited from Object)
PeekReturns the object at the beginning of the Queue without removing it.
QueueOverloaded. Initializes a new instance of Queue.
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
SynchronizedReturns a Queue wrapper that is synchronized.
ToArrayCopies the Queue elements to a new array.
ToStringReturns a String that represents the current Object. (Inherited from Object)
TrimToSizeSets the capacity to the actual number of elements in the Queue.
PropertyDescription
CountGets the number of elements contained in the Queue.
IsSynchronizedGets a value indicating whether access to the Queue is synchronized.
SyncRootGets an object that can be used to synchronize access to the Queue.

Inheritance Hierarchy

Object
Queue

Examples

// This sample shows how to implement the Queue class.

 

using System.Diagnostics;

using System.Collections;

 

public class SampleQueue

{

     static void Main()

     {

          // Creates a new Queue.

          Queue myDaysQueue = new Queue();

 

          // Initializes for the Queue.

          myDaysQueue.Enqueue("Monday");

          myDaysQueue.Enqueue("Tuesday");

          myDaysQueue.Enqueue("Wednesday");

          myDaysQueue.Enqueue("Thursday");

          myDaysQueue.Enqueue("Friday");

          myDaysQueue.Enqueue("Saturday");

          myDaysQueue.Enqueue("Sunday");

 

          // Displaying .

          Debug.WriteLine("The number of elements in the Queue: " + myDaysQueue.Count);

          Debug.WriteLine("\nThe values of the Queue:");

          DisplayQueue(myDaysQueue);

     }

 

     static void DisplayQueue(IEnumerable myCollection )

     {

          IEnumerator myIEnum = myCollection.GetEnumerator();

          while (myIEnum.MoveNext())

            Debug.WriteLine("\t\t" +myIEnum.Current);

     }

}

 

/*

The output of the sample.

 

The number of elements in the Queue: 7

 

The value of the Queue:

          Monday

          Tuesday

          Wednesday

          Thursday

          Friday

          Saturday

          Sunday

*/

 

Class Information

NamespaceSystem.Collections
Flash Librarycorlib.scl
Flash Library Version2.0.0.2466
Silverlight LibrarySystem.Windows.Forms.dll



© 2003-2007 NETiKA Technologies. All rights reserved.