std::vector
Da cppreference.com
Definido no cabeçalho <vector>
|
||
template< class T, |
(1) | |
namespace pmr { template <class T> |
(2) | |
1)
std::vector
é um recipiente sequencial que encapsula vetores de tamanho dinâmico.
Original:
is a sequence container that encapsulates dynamic size arrays.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
std::pmr::vector
é um alias template que usa um polymorphic allocator.
Original:
is an alias template that uses a polymorphic allocator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Os elementos são armazenados de forma contígua, o que significa que os elementos podem ser acessados não só através de iteradores, mas também com deslocamentos em ponteiros regulares aos elementos. Isto significa que um ponteiro para um elemento de um vector pode ser passado para qualquer função que espera um ponteiro para um elemento de uma matriz.
Original:
The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets on regular pointers to elements. This means that a pointer to an element of a vector may be passed to any function that expects a pointer to an element of an array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
O armazenamento do vector é feita automaticamente, sendo expandido e contraído, conforme necessário. Vetores geralmente ocupam mais espaço do que arrays estáticos, porque mais memória é alocada para lidar com o crescimento futuro. Desta forma, um vector não necessita de reatribuir cada vez que um elemento é inserido, mas apenas quando a memória adicional está esgotado. A quantidade total de memória alocada pode ser consultada usando função
capacity()
. Memória extra pode ser retornada para o sistema através de uma chamada a shrink_to_fit()
.Original:
The storage of the vector is handled automatically, being expanded and contracted as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additional memory is exhausted. The total amount of allocated memory can be queried using
capacity()
function. Extra memory can be returned to the system via a call to shrink_to_fit()
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click
You can help to correct and verify the translation. Click