Class Queue
- Namespace
- System.Collections
- Assembly
- nanoFramework.System.Collections.dll
A circular-array implementation of a queue. Enqueue can be O(n). Dequeue is O(1).
public class Queue : ICollection, IEnumerable, ICloneable
- Inheritance
-
Queue
- Implements
- Inherited Members
- Extension Methods
Constructors
Queue()
Initializes a new instance of the Queue class that is empty, has the default initial capacity, and uses the default growth factor (2x).
public Queue()
Properties
Count
Gets the number of elements contained in the Queue.
public virtual int Count { get; }
Property Value
IsSynchronized
Gets a value indicating whether access to the Queue is synchronized (thread safe). Always return false.
public virtual bool IsSynchronized { get; }
Property Value
SyncRoot
Gets an object that can be used to synchronize access to the Queue.
public virtual object SyncRoot { get; }
Property Value
Methods
Clear()
Removes all objects from the Queue.
public virtual void Clear()
Clone()
Creates a shallow copy of the Queue.
public virtual object Clone()
Returns
- object
A shallow copy of the Queue.
Contains(object)
Determines whether an element is in the Queue.
public virtual bool Contains(object obj)
Parameters
obj
objectThe Object to locate in the Queue.
Returns
- bool
true if obj is found in the Queue; otherwise, false.
CopyTo(Array, int)
Copies the Queue elements to an existing one-dimensional Array, starting at the specified array index.
public virtual void CopyTo(Array array, int index)
Parameters
array
ArrayThe one-dimensional Array that is the destination of the elements copied from Queue.
index
intThe zero-based index in array at which copying begins.
Dequeue()
Removes and returns the object at the beginning of the Queue.
public virtual object Dequeue()
Returns
- object
The object that is removed from the beginning of the Queue.
Enqueue(object)
Adds an object to the end of the Queue.
public virtual void Enqueue(object obj)
Parameters
obj
objectThe object to add to the Queue.
GetEnumerator()
Returns an enumerator that iterates through the Queue.
public virtual IEnumerator GetEnumerator()
Returns
- IEnumerator
An IEnumerator for the Queue.
Peek()
Returns the object at the beginning of the Queue without removing it.
public virtual object Peek()
Returns
- object
The object at the beginning of the Queue.
ToArray()
Copies the Queue elements to a new array. The order of the elements in the new array is the same as the order of the elements from the beginning of the Queue to its end.
public virtual object[] ToArray()
Returns
- object[]
A new array containing elements copied from the Queue.