Represents a first-in, first-out collection of objects.
Assembly: mscorlib (in mscorlib.dll)
Initializes a new instance of theclass that is empty, has the default initial capacity, and uses the default growth factor.
Initializes a new instance of theclass that contains elements copied from the specified collection, has the same initial capacity as the number of elements copied, and uses the default growth factor.
Initializes a new instance of theclass that is empty, has the specified initial capacity, and uses the default growth factor.
Initializes a new instance of theclass that is empty, has the specified initial capacity, and uses the specified growth factor.
Removes all objects from the.
Creates a shallow copy of the.
Determines whether an element is in the.
Copies the Array, starting at the specified array index.elements to an existing one-dimensional
Removes and returns the object at the beginning of the.
Adds an object to the end of the.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Returns an enumerator that iterates through the.
Serves as the default hash function. (Inherited from Object.)
Returns the object at the beginning of thewithout removing it.
Returns a newthat wraps the original queue, and is thread safe.
Copies theelements to a new array.
Returns a string that represents the current object.(Inherited from Object.)
Sets the capacity to the actual number of elements in the.
Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)
This class implements a queue as a circular array. Objects stored in aare inserted at one end and removed from the other.
Queues and stacks are useful when you need temporary storage for information; that is, when you might want to discard an element after retrieving its value. Use Stack if you need to access the information in reverse order. Use ConcurrentQueue<'T> or ConcurrentStack<'T> if you need to access the collection from multiple threads concurrently.if you need to access the information in the same order that it is stored in the collection. Use
Three main operations can be performed on aand its elements:
Enqueue adds an element to the end of the .
Dequeue removes the oldest element from the start of the .
Peek returns the oldest element that is at the start of the but does not remove it from the .
The capacity of a TrimToSize.is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling
The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when theis constructed. The default growth factor is 2.0. The capacity of the will always increase by at least a minimum of four, regardless of the growth factor. For example, a with a growth factor of 1.0 will always increase in capacity by four when a greater capacity is required.
accepts null as a valid value and allows duplicate elements.
For the generic version of this collection, see System.Collections.Generic.Queue<'T>
Available since 10
Available since 1.1
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
To guarantee the thread safety of the Synchronized method., all operations must be done through the wrapper returned by the
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.