std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>::begin, std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>::cbegin
De cppreference.com
< cpp | container | unordered multimap
iterator begin() noexcept; |
(desde C++11) | |
const_iterator begin() const noexcept; |
(desde C++11) | |
const_iterator cbegin() const noexcept; |
(desde C++11) | |
Devuelve un iterador al primer elemento del unordered_multimap
.
Si el unordered_multimap
está vacío, el iterador devuelto será igual a end().
Contenido |
[editar] Parámetros
(Ninguno)
[editar] Valor de retorno
Iterador al primer elemento.
[editar] Complejidad
Constante.
[editar] Ejemplo
Ejecuta este código
#include <unordered_map> #include <algorithm> #include <cassert> #include <iostream> #include <string> #include <utility> int main() { auto mostrar_nodo = [](const std::pair<std::string, std::string>& nodo) { std::cout << nodo.first << " : " << nodo.second << '\n'; }; std::unordered_multimap<std::string, std::string> lemas; assert(lemas.begin() == lemas.end()); // de acuerdo assert(lemas.cbegin() == lemas.cend()); // de acuerdo lemas.insert({ "1. ∀x ∈ N ∃y ∈ N", "x ≤ y" }); mostrar_nodo(*lemas.cbegin()); assert(lemas.begin() != lemas.end()); // de acuerdo assert(lemas.cbegin() != lemas.cend()); // de acuerdo lemas.begin()->second = "x < y"; mostrar_nodo(*lemas.cbegin()); lemas.insert({ "2. ∀x,y ∈ N", "x = y V x ≠ y" }); mostrar_nodo(*lemas.cbegin()); lemas.insert({ "3. ∀x ∈ N ∃y ∈ N", "y = x + 1" }); mostrar_nodo(*lemas.cbegin()); std::cout << "lemas: \n"; std::for_each(lemas.cbegin(), lemas.cend(), [&](const auto& n) { mostrar_nodo(n); }); std::cout << "\n"; }
Posible salida:
1. ∀x ∈ N ∃y ∈ N : x ≤ y 1. ∀x ∈ N ∃y ∈ N : x < y 2. ∀x,y ∈ N : x = y V x ≠ y 3. ∀x ∈ N ∃y ∈ N : y = x + 1 lemas: 3. ∀x ∈ N ∃y ∈ N : y = x + 1 1. ∀x ∈ N ∃y ∈ N : x < y 2. ∀x,y ∈ N : x = y V x ≠ y
[editar] Véase también
(C++11) |
Devuelve un iterador al final. (función miembro pública) |