Επεξεργασία

Κοινή χρήση μέσω


Queue Constructors

Definition

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()

Source:
Queue.cs
Source:
Queue.cs
Source:
Queue.cs

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)

Source:
Queue.cs
Source:
Queue.cs
Source:
Queue.cs

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)

Source:
Queue.cs
Source:
Queue.cs
Source:
Queue.cs

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

capacity
Int32

The initial number of elements that the Queue can contain.

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)

Source:
Queue.cs
Source:
Queue.cs
Source:
Queue.cs

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

capacity
Int32

The initial number of elements that the Queue can contain.

growFactor
Single

The factor by which the capacity of the Queue is expanded.

Exceptions

capacity is less than zero.

-or-

growFactor is less than 1.0 or greater than 10.0.

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