Queue 构造函数

定义

初始化 Queue 类的新实例。Initializes a new instance of the Queue class.

重载

Queue()

初始化 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)

初始化 Queue 类的新实例,该实例包含从指定集合复制的元素,具有与所复制的元素数相同的初始容量并使用默认增长因子。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)

初始化 Queue 类的新实例,该实例为空,具有指定的初始容量并使用默认增长因子。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)

初始化 Queue 类的新实例,该实例为空,具有指定的初始容量并使用指定的增长因子。Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the specified growth factor.

Queue()

初始化 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 ()

注解

的容量 Queue 是可容纳的元素数 QueueThe capacity of a Queue is the number of elements the Queue can hold. 向添加元素时,会 Queue 根据需要通过重新分配来自动增加容量。As elements are added to a Queue, the capacity is automatically increased as required through reallocation. 可以通过调用来减少容量 TrimToSizeThe 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. 此增长因子是在构造时确定的 QueueThe growth factor is determined when the Queue is constructed.

此构造函数是一种 O(1) 操作。This constructor is an O(1) operation.

适用于

Queue(ICollection)

初始化 Queue 类的新实例,该实例包含从指定集合复制的元素,具有与所复制的元素数相同的初始容量并使用默认增长因子。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)

参数

col
ICollection

ICollection,从其中复制元素。The ICollection to copy elements from.

例外

colnullcol is null.

注解

的容量 Queue 是可容纳的元素数 QueueThe capacity of a Queue is the number of elements the Queue can hold. 向添加元素时,会 Queue 根据需要通过重新分配来自动增加容量。As elements are added to a Queue, the capacity is automatically increased as required through reallocation. 可以通过调用来减少容量 TrimToSizeThe 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. 此增长因子是在构造时确定的 QueueThe growth factor is determined when the Queue is constructed.

将元素复制到,其 Queue 顺序与的读取顺序相同 IEnumerator ICollectionThe elements are copied onto the Queue in the same order they are read by the IEnumerator of the ICollection.

此构造函数是一个 O(n) 操作,其中 n 是中的元素数 colThis constructor is an O(n) operation, where n is the number of elements in col.

另请参阅

适用于

Queue(Int32)

初始化 Queue 类的新实例,该实例为空,具有指定的初始容量并使用默认增长因子。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)

参数

capacity
Int32

Queue 可包含的初始元素数。The initial number of elements that the Queue can contain.

例外

capacity 小于零。capacity is less than zero.

注解

的容量 Queue 是可容纳的元素数 QueueThe capacity of a Queue is the number of elements the Queue can hold. 向添加元素时,会 Queue 根据需要通过重新分配来自动增加容量。As elements are added to a Queue, the capacity is automatically increased as required through reallocation. 可以通过调用来减少容量 TrimToSizeThe 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. 此增长因子是在构造时确定的 QueueThe growth factor is determined when the Queue is constructed.

如果集合的大小可为估算值,则指定初始容量后,无需在将元素添加到时执行多个大小调整操作 QueueIf 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.

此构造函数是一个 O(n) 操作,其中 ncapacityThis constructor is an O(n) operation, where n is capacity.

适用于

Queue(Int32, Single)

初始化 Queue 类的新实例,该实例为空,具有指定的初始容量并使用指定的增长因子。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)

参数

capacity
Int32

Queue 可包含的初始元素数。The initial number of elements that the Queue can contain.

growFactor
Single

扩展 Queue 容量要使用的因子。The factor by which the capacity of the Queue is expanded.

例外

capacity 小于零。capacity is less than zero.

- 或 --or- growFactor 小于 1.0 或大于 10.0。growFactor is less than 1.0 or greater than 10.0.

注解

的容量 Queue 是可容纳的元素数 QueueThe capacity of a Queue is the number of elements the Queue can hold. 向添加元素时,会 Queue 根据需要通过重新分配来自动增加容量。As elements are added to a Queue, the capacity is automatically increased as required through reallocation. 可以通过调用来减少容量 TrimToSizeThe 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. 此增长因子是在构造时确定的 QueueThe growth factor is determined when the Queue is constructed. 的容量 Queue 始终按最小值增加,无论增长系数如何; 1.0 的增长系数都不会阻止 Queue 增加大小。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.

如果集合的大小可为估算值,则指定初始容量后,无需在将元素添加到时执行多个大小调整操作 QueueIf 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.

此构造函数是一个 O(n) 操作,其中 ncapacityThis constructor is an O(n) operation, where n is capacity.

适用于