Stack Construtores

Definição

Inicializa uma nova instância da classe Stack.Initializes a new instance of the Stack class.

Sobrecargas

Stack()

Inicializa uma nova instância da classe Stack que está vazia e tem a capacidade inicial padrão.Initializes a new instance of the Stack class that is empty and has the default initial capacity.

Stack(ICollection)

Inicializa uma nova instância da classe Stack, que contém os elementos copiados da coleção especificada e tem a mesma capacidade inicial que o número de elementos copiados.Initializes a new instance of the Stack class that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied.

Stack(Int32)

Inicializa uma nova instância da classe Stack que está vazia e tem a capacidade inicial especificada ou a capacidade inicial padrão, a que for maior.Initializes a new instance of the Stack class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater.

Stack()

Inicializa uma nova instância da classe Stack que está vazia e tem a capacidade inicial padrão.Initializes a new instance of the Stack class that is empty and has the default initial capacity.

public:
 Stack();
public Stack ();
Public Sub New ()

Comentários

A capacidade de um Stack é o número de elementos que o Stack pode conter.The capacity of a Stack is the number of elements that the Stack can hold. À medida que os elementos são adicionados a um Stack , a capacidade é aumentada automaticamente conforme necessário, realocando a matriz interna.As elements are added to a Stack, the capacity is automatically increased as required by reallocating the internal array.

Se o tamanho da coleção puder ser estimado, a especificação da capacidade inicial elimina a necessidade de executar uma série de operações de redimensionamento ao adicionar elementos ao Stack .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 Stack.

Esse construtor é uma O(1) operação.This constructor is an O(1) operation.

Aplica-se a

Stack(ICollection)

Inicializa uma nova instância da classe Stack, que contém os elementos copiados da coleção especificada e tem a mesma capacidade inicial que o número de elementos copiados.Initializes a new instance of the Stack class that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied.

public:
 Stack(System::Collections::ICollection ^ col);
public Stack (System.Collections.ICollection col);
new System.Collections.Stack : System.Collections.ICollection -> System.Collections.Stack
Public Sub New (col As ICollection)

Parâmetros

col
ICollection

A ICollection da qual copiar elementos.The ICollection to copy elements from.

Exceções

col é null.col is null.

Comentários

A capacidade de um Stack é o número de elementos que o Stack pode conter.The capacity of a Stack is the number of elements that the Stack can hold. À medida que os elementos são adicionados a um Stack , a capacidade é aumentada automaticamente conforme necessário, realocando a matriz interna.As elements are added to a Stack, the capacity is automatically increased as required by reallocating the internal array.

Se o tamanho da coleção puder ser estimado, a especificação da capacidade inicial elimina a necessidade de executar uma série de operações de redimensionamento ao adicionar elementos ao Stack .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 Stack.

Os elementos são copiados para o Stack na mesma ordem em que são lidos pelo IEnumerator do ICollection .The elements are copied onto the Stack in the same order they are read by the IEnumerator of the ICollection.

Esse construtor é uma O(n) operação, em que n é o número de elementos no col .This constructor is an O(n) operation, where n is the number of elements in col.

Confira também

Aplica-se a

Stack(Int32)

Inicializa uma nova instância da classe Stack que está vazia e tem a capacidade inicial especificada ou a capacidade inicial padrão, a que for maior.Initializes a new instance of the Stack class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater.

public:
 Stack(int initialCapacity);
public Stack (int initialCapacity);
new System.Collections.Stack : int -> System.Collections.Stack
Public Sub New (initialCapacity As Integer)

Parâmetros

initialCapacity
Int32

O número inicial de elementos que o Stack pode conter.The initial number of elements that the Stack can contain.

Exceções

initialCapacity é menor que zero.initialCapacity is less than zero.

Comentários

A capacidade de um Stack é o número de elementos que o Stack pode conter.The capacity of a Stack is the number of elements that the Stack can hold. À medida que os elementos são adicionados a um Stack , a capacidade é aumentada automaticamente conforme necessário, realocando a matriz interna.As elements are added to a Stack, the capacity is automatically increased as required by reallocating the internal array.

Se o tamanho da coleção puder ser estimado, a especificação da capacidade inicial elimina a necessidade de executar uma série de operações de redimensionamento ao adicionar elementos ao Stack .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 Stack.

Esse construtor é uma O(n) operação, em que n é initialCapacity .This constructor is an O(n) operation, where n is initialCapacity.

Aplica-se a