# Queue Constructors

## Definition

Important

Some information relates to prerelease product that may be substantially modified before itâ€™s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Initializes a new instance of the Queue class.

## Overloads

Queue() |
Initializes a new instance of the Queue class that is empty, has the default initial capacity, and uses the default growth factor. |

Queue(ICollection) |
Initializes a new instance of the Queue class 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. |

Queue(Int32) |
Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the default growth factor. |

Queue(Int32, Single) |
Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the specified growth factor. |

## Queue()

Initializes a new instance of the Queue class that is empty, has the default initial capacity, and uses the default growth factor.

```
public:
Queue();
```

`public Queue ();`

`Public Sub New ()`

### Remarks

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.

This constructor is an `O(1)`

operation.

### Applies to

## Queue(ICollection)

Initializes a new instance of the Queue class 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.

```
public:
Queue(System::Collections::ICollection ^ col);
```

`public Queue (System.Collections.ICollection col);`

`new System.Collections.Queue : System.Collections.ICollection -> System.Collections.Queue`

`Public Sub New (col As ICollection)`

#### Parameters

- col
- ICollection

The ICollection to copy elements from.

#### Exceptions

`col`

is `null`

.

### Remarks

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 elements are copied onto the Queue in the same order they are read by the IEnumerator of the ICollection.

This constructor is an `O(n)`

operation, where `n`

is the number of elements in `col`

.

### See also

### Applies to

## Queue(Int32)

Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the default growth factor.

```
public:
Queue(int capacity);
```

`public Queue (int capacity);`

`new System.Collections.Queue : int -> System.Collections.Queue`

`Public Sub New (capacity As Integer)`

#### Parameters

#### Exceptions

`capacity`

is less than zero.

### Remarks

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`

.

### Applies to

## Queue(Int32, Single)

Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the specified growth factor.

```
public:
Queue(int capacity, float growFactor);
```

`public Queue (int capacity, float growFactor);`

`new System.Collections.Queue : int * single -> System.Collections.Queue`

`Public Sub New (capacity As Integer, growFactor As Single)`

#### Parameters

#### Exceptions

`capacity`

is less than zero.

-or-

`growFactor`

is less than 1.0 or greater than 10.0.

### Remarks

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 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`

.

### Applies to

## Feedback

Submit and view feedback for