Queue Constructor (Int32)
Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the default growth factor.
Assembly: mscorlib (in mscorlib.dll)
Exception | Condition |
---|---|
ArgumentOutOfRangeException | capacity is less than zero. |
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.
If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the Queue.
This constructor is an O(n) operation, where n is capacity.
Available since 10
.NET Framework
Available since 1.1