Espacios de nombres
Variantes
Acciones

Biblioteca de contenedores

De cppreference.com
< cpp

La biblioteca de contenedores es una colección genérica de plantillas de clase que permiten a los programadores implementar estructuras de datos comunes fácilmente, como colas, listas y pilas. Hay tres clases de contenedores - contenedores de secuencias, contenedores asociativos y contenedores asociativos desordenados - cada uno de los cuales está diseñado para dar soporte a un conjunto diferente de operaciones.

El contenedor gestiona el espacio de almacenamiento que es asignado a sus elementos y proporciona funciones miembro para acceder a ellos, ya sea directamente o mediante iteradores (objetos con propiedades similares a los punteros).

La mayoría de los contenedores tienen varias funciones miembro en común, y comparten ciertas funcionalidades. Qué contenedor es mejor para una aplicación particular no sólo depende de la funcionalidad ofrecida, sino también de su eficiencia para los diferentes tipos de trabajo.

Contenido

[editar] Contenedores de secuencias

Los contenedores de secuencias implementan estructuras de datos que pueden ser accedidas de manera secuencial.

(desde C++11)
array contiguo estática
Original:
static contiguous array
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) [edit]
array contiguo dinámico
Original:
dynamic contiguous array
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) [edit]
de doble punta de la cola
Original:
double-ended queue
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) [edit]
(desde C++11)
la lista simplemente enlazada
Original:
singly-linked list
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) [edit]
lista doblemente enlazada
Original:
doubly-linked list
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) [edit]

[editar] Contenedores asociativos

Los contenedores asociativos implementan estructuras de datos ordenadas en las que se puede buscar rápidamente (complejidad O(log n)).

colección de claves únicas, ordenados por claves
Original:
collection of unique keys, sorted by keys
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) [edit]
colección de pares de valores clave, ordenados por teclas, las teclas son únicos
Original:
collection of key-value pairs, sorted by keys, keys are unique
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) [edit]
collection of keys, sorted by keys
(clase de plantilla) [edit]
colección de pares de clave-valor, ordenados por claves
Original:
collection of key-value pairs, sorted by keys
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) [edit]

[editar] Contenedores asociativos desordenados

Los contenedores asociativos desordenados implementan estructuras de datos desordenadas (hasheadas) en las que se puede buscar rápidamente (O(1) amortizado, O(n) complejidad en el peor de los casos).

(desde C++11)
colección de claves únicas, ordenados por claves
Original:
collection of unique keys, hashed by keys
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) [edit]
(desde C++11)
colección de pares de clave-valor hash, ordenados por claves, las claves son únicas
Original:
collection of key-value pairs, hashed by keys, keys are unique
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) [edit]
(desde C++11)
recogida de llaves, ordenados por claves
Original:
collection of keys, hashed by keys
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) [edit]
(desde C++11)
colección de pares de clave-valor hash, ordenados por claves
Original:
collection of key-value pairs, hashed by keys
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) [edit]

[editar] Adaptadores de contenedor

Los adaptadores de contenedor proporcionan una interfaz diferente para contenedores de secuencias.

adapta un recipiente para proporcionar pila LIFO (estructura de datos)
Original:
adapts a container to provide stack (LIFO data structure)
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) [edit]
adapta un recipiente para proporcionar cola (FIFO estructura de datos)
Original:
adapts a container to provide queue (FIFO data structure)
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) [edit]
adapta un recipiente para proporcionar cola de prioridad
Original:
adapts a container to provide priority queue
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) [edit]

[editar] Tabla de funciones miembro

- funciones presentes en C++03
- funciones presentes desde C++11
Contenedores de secuencia Contenedores asociativos Contenedores asociativos desordenados Adaptadores de contenedor
Cabeceras <array> <vector> <deque> <forward_list> <list> <set> <map> <unordered_set> <unordered_map> <stack> <queue>
 
array
vector
deque
forward_list
list
set
multiset
map
multimap
unordered_set
unordered_multiset
unordered_map
unordered_multimap
stack
queue
priority_queue
(constructor)
(implicit)
vector
deque
forward_list
list
set
multiset
map
multimap
unordered_set
unordered_multiset
unordered_map
unordered_multimap
stack
queue
priority_queue
(destructor)
(implicit)
~vector
~deque
~forward_list
~list
~set
~multiset
~map
~multimap
~unordered_set
~unordered_multiset
~unordered_map
~unordered_multimap
~stack
~queue
~priority_queue
operator=
(implicit)
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
operator=
assign
N/A
assign
assign
assign
assign
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Iterators
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
begin
cbegin
N/A N/A N/A
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
end
cend
N/A N/A N/A
rbegin
crbegin
rbegin
crbegin
rbegin
crbegin
rbegin
crbegin
N/A
rbegin
crbegin
rbegin
crbegin
rbegin
crbegin
rbegin
crbegin
rbegin
crbegin
N/A N/A N/A N/A N/A N/A N/A
rend
crend
rend
crend
rend
crend
rend
crend
N/A
rend
crend
rend
crend
rend
crend
rend
crend
rend
crend
N/A N/A N/A N/A N/A N/A N/A
Element
access
at
at
at
at
N/A N/A N/A N/A
at
N/A N/A N/A
at
N/A N/A N/A N/A
operator[]
operator[]
operator[]
operator[]
N/A N/A N/A N/A
operator[]
N/A N/A N/A
operator[]
N/A N/A N/A N/A
front
front
front
front
front
front
N/A N/A N/A N/A N/A N/A N/A N/A N/A
front
top
back
back
back
back
N/A
back
N/A N/A N/A N/A N/A N/A N/A N/A
top
back
N/A
Capacity
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
empty
size
size
size
size
N/A
size
size
size
size
size
size
size
size
size
size
size
size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
max_size
N/A N/A N/A
resize
N/A
resize
resize
resize
resize
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
capacity
N/A
capacity
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
reserve
N/A
reserve
N/A N/A N/A N/A N/A N/A N/A
reserve
reserve
reserve
reserve
N/A N/A N/A
shrink_to_fit
N/A
shrink_to_fit
shrink_to_fit
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Modifiers
clear
N/A
clear
clear
clear
clear
clear
clear
clear
clear
clear
clear
clear
clear
N/A N/A N/A
insert
N/A
insert
insert
insert_after
insert
insert
insert
insert
insert
insert
insert
insert
insert
N/A N/A N/A
emplace
N/A
emplace
emplace
emplace_after
emplace
emplace
emplace
emplace
emplace
emplace
emplace
emplace
emplace
N/A N/A N/A
emplace_hint
N/A N/A N/A N/A N/A
emplace_hint
emplace_hint
emplace_hint
emplace_hint
emplace_hint
emplace_hint
emplace_hint
emplace_hint
N/A N/A N/A
erase
N/A
erase
erase
erase_after
erase
erase
erase
erase
erase
erase
erase
erase
erase
N/A N/A N/A
push_front
N/A N/A
push_front
push_front
push_front
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
emplace_front
N/A N/A
emplace_front
emplace_front
emplace_front
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
pop_front
N/A N/A
pop_front
pop_front
pop_front
N/A N/A N/A N/A N/A N/A N/A N/A N/A
pop
N/A
push_back
N/A
push_back
push_back
N/A
push_back
N/A N/A N/A N/A N/A N/A N/A N/A
push
push
push
emplace_back
N/A
emplace_back
emplace_back
N/A
emplace_back
N/A N/A N/A N/A N/A N/A N/A N/A
emplace
emplace
emplace
pop_back
N/A
pop_back
pop_back
N/A
pop_back
N/A N/A N/A N/A N/A N/A N/A N/A
pop
N/A
pop
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
swap
List operations
merge
N/A N/A N/A N/A
merge
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
splice
N/A N/A N/A N/A
splice
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
remove
N/A N/A N/A N/A
remove
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
remove_if
N/A N/A N/A N/A
remove_if
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
reverse
N/A N/A N/A N/A
reverse
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
unique
N/A N/A N/A N/A
unique
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
sort
N/A N/A N/A N/A
sort
N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
Lookup
count
N/A N/A N/A N/A N/A
count
count
count
count
count
count
count
count
N/A N/A N/A
find
N/A N/A N/A N/A N/A
find
find
find
find
find
find
find
find
N/A N/A N/A
lower_bound
N/A N/A N/A N/A N/A
lower_bound
lower_bound
lower_bound
lower_bound
N/A N/A N/A N/A N/A N/A N/A
upper_bound
N/A N/A N/A N/A N/A
upper_bound
upper_bound
upper_bound
upper_bound
N/A N/A N/A N/A N/A N/A N/A
equal_range
N/A N/A N/A N/A N/A
equal_range
equal_range
equal_range
equal_range
equal_range
equal_range
equal_range
equal_range
N/A N/A N/A
Observers
key_comp
N/A N/A N/A N/A N/A
key_comp
key_comp
key_comp
key_comp
N/A N/A N/A N/A N/A N/A N/A
value_comp
N/A N/A N/A N/A N/A
value_comp
value_comp
value_comp
value_comp
N/A N/A N/A N/A N/A N/A N/A
hash_function
N/A N/A N/A N/A N/A N/A N/A N/A N/A
hash_function
hash_function
hash_function
hash_function
N/A N/A N/A
key_eq
N/A N/A N/A N/A N/A N/A N/A N/A N/A
key_eq
key_eq
key_eq
key_eq
N/A N/A N/A
Allocator
get_allocator
N/A
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
get_allocator
N/A N/A N/A
 
array
vector
deque
forward_list
list
set
multiset
map
multimap
unordered_set
unordered_multiset
unordered_map
unordered_multimap
stack
queue
priority_queue
Contenedores de secuencia Contenedores asociativos Contenedores asociativos desordenados Adaptadores de contenedor