Queue.Enqueue Method (Object)

 

Adds an object to the end of the Queue.

Namespace:   System.Collections
Assembly:  mscorlib (in mscorlib.dll)

abstract Enqueue : 
        obj:Object -> unit
override Enqueue : 
        obj:Object -> unit

Parameters

obj
Type: System.Object

The object to add to the Queue. The value can be null.

The capacity of a Queue is the number of elements the Queue can hold. As elements are added to a Queue, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize.

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 the Queue is constructed. The capacity of the Queue will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the Queue from increasing in size.

If Count is less than the capacity of the internal array, this method is an O(1) operation. If the internal array needs to be reallocated to accommodate the new element, this method becomes an O(n) operation, where n is Count.

The following example shows how to add elements to the Queue, remove elements from the Queue, or view the element at the beginning of the Queue.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: