std::vector
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <vector>
|
||
| template< class T, |
||
std::vector es un contenedor que encapsula secuencia de matrices dinámicas tamaño .Original:
std::vector 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.
Los elementos se almacenan de forma contigua, lo que significa que los elementos no se puede acceder sólo a través de los iteradores, pero también con los desplazamientos en punteros regulares a los elementos. Esto significa que un puntero a un elemento de un vector se puede hacer pasar a cualquier función que espera un puntero a un elemento de una 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.
El almacenamiento del vector se maneja automáticamente, siendo expandido y contraído, según sea necesario. Vectores suelen ocupar más espacio que las matrices estáticas, ya que se asigna más memoria para manejar el crecimiento futuro. De esta manera un vector no necesita reasignar cada vez que se inserta un elemento, pero sólo cuando la memoria adicional se agota. La cantidad total de memoria asignada puede ser consultada mediante la función
capacity(). Memoria adicional se puede devolver al sistema a través de una llamada 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 here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Las reasignaciones suelen ser operaciones costosas en términos de rendimiento.
reserve() función puede ser utilizada para eliminar las reasignaciones si el número de elementos que se conoce de antemano .Original:
Reallocations are usually costly operations in terms of performance.
reserve() function can be used to eliminate reallocations if the number of elements is known beforehand.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.
La complejidad (eficacia) de las operaciones comunes de vectores es el siguiente:
Original:
The complexity (efficiency) of common operations on vectors is as follows:
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.
- Acceso aleatorio - O(1) constanteOriginal:Random access - constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Inserción o extracción de elementos al final - O(1) constante amortizadoOriginal:Insertion or removal of elements at the end - amortized constant O(1)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - La inserción o la eliminación de los elementos - lineal en distancia hasta el extremo de la O(n) vectorOriginal:Insertion or removal of elements - linear in distance to the end of the vector O(n)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::vector cumple los requisitos de Container, AllocatorAwareContainer, SequenceContainer y ReversibleContainer .Original:
std::vector meets the requirements of Container, AllocatorAwareContainer, SequenceContainer and ReversibleContainer.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.
[editar] Especializaciones
La biblioteca estándar proporciona una especialización de
std::vector para la bool tipo, que está optimizado para la eficiencia del espacio .Original:
The standard library provides a specialization of
std::vector for the type bool, which is optimized for space efficiency.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.
| eficiente con el espacio bitset dinámico Original: space-efficient dynamic bitset The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (clase de plantilla) | |
[editar] Tipos de miembros
| Miembro de tipo
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
T
|
allocator_type
|
Allocator
|
size_type
|
Tipo entero sin signo (por lo general size_t)
Original: Unsigned integral type (usually size_t) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
difference_type
|
Signed integer type (usually ptrdiff_t) |
reference
|
Allocator::reference (hasta C++11)value_type& (desde C++11)
|
const_reference
|
Allocator::const_reference (hasta C++11)const value_type& (desde C++11)
|
pointer
|
Allocator::pointer (hasta C++11)std::allocator_traits<Allocator>::pointer (desde C++11) |
const_pointer
|
Allocator::const_pointer (hasta C++11) std::allocator_traits<Allocator>::const_pointer (desde C++11) |
iterator
|
RandomAccessIterator
|
const_iterator
|
Iterador constante de acceso aleatorio
Original: Constant random access iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
reverse_iterator
|
std::reverse_iterator<iterator> |
const_reverse_iterator
|
std::reverse_iterator<const_iterator> |
[editar] Las funciones miembro
| construye el vector Original: constructs the vector The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
destructs the vector (miembro público función) | |
| asigna valores para el contenedor Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| asigna valores para el contenedor Original: assigns values to the container The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el asignador asociado Original: returns the associated allocator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
Original: Element access The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| acceder al elemento especificado con comprobación de límites Original: access specified element with bounds checking The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| acceder al elemento especificado Original: access specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| acceso al primer elemento Original: access the first element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| access the last element (miembro público función) | |
| (C++11) |
dirigir el acceso a la matriz subyacente Original: direct access to the underlying array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) |
Original: Iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| devuelve un iterador al principio Original: returns an iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve un iterador hasta el final Original: returns an iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve un iterador inverso al principio Original: returns a reverse iterator to the beginning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve un iterador inverso hasta el final Original: returns a reverse iterator to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
Original: Capacity The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| comprueba si el recipiente está vacío Original: checks whether the container is empty The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el número de elementos Original: returns the number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el número máximo posible de elementos Original: returns the maximum possible number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| reservas de almacenamiento Original: reserves storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| devuelve el número de elementos que se pueden almacenar en el almacenamiento asignado actualmente Original: returns the number of elements that can be held in currently allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| (C++11) |
reduce el uso de memoria por la liberación de memoria no utilizada Original: reduces memory usage by freeing unused memory The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| borra el contenido Original: clears the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| Inserta elementos Original: inserts elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| (C++11) |
constructs element in-place (miembro público función) |
| borra elementos Original: erases elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| agrega elementos al final Original: adds elements to the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| (C++11) |
construye elementos en lugar de al final Original: constructs elements in-place at the end The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) |
| elimina el último elemento Original: removes the last element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
| changes the number of elements stored (miembro público función) | |
| intercambia los contenidos Original: swaps the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (miembro público función) | |
[editar] Terceros funciones
| lexicográficamente compara los valores del vector Original: lexicographically compares the values in the vector The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función de plantilla) | |
| el algoritmo se especializa std::swap Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función de plantilla) | |