Table of Contents

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

int

IsSynchronized

Gets a value indicating whether access to the Queue is synchronized (thread safe). Always return false.

public virtual bool IsSynchronized { get; }

Property Value

bool

SyncRoot

Gets an object that can be used to synchronize access to the Queue.

public virtual object SyncRoot { get; }

Property Value

object

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 object

The 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 Array

The one-dimensional Array that is the destination of the elements copied from Queue.

index int

The 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 object

The 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.