std::unorde...imap::begin,(3)
π NAME π
okay so this is the std::unorde...imap::begin,(3) page from the C++ Standard Libary manual β yes, it really says Libary in the header, not my typo, bestie. The NAME line is literally std::unordered_multimap::begin, - std::unordered_multimap::begin, β comma chaos included, no cap. We're here for std::unordered_multimap::begin and its iterator besties. π
β¨ Synopsis β¨
iterator begin() noexcept; (1) (since C++11)
const_iterator begin() const noexcept; (2) (since C++11)
const_iterator cbegin() const noexcept; (3) (since C++11)
Three overloads, all since C++11, all doing the "gimme the first element" thing. π«Ά
Returns an iterator to the first element of the unordered_multimap.
If the unordered_multimap is empty, the returned iterator will be equal to end().
There's also a diagram asset named range-begin-end.svg β it's giving "visual aid" energy. β¨
π Parameters π
(none) β not a single parameter. Nada. The void. π
π¦ Return value π¦
Iterator to the first element. That's the whole tea. β
πΈ Complexity πΈ
Constant.
π₯ Example π₯
okay so here's the code, untouched, because we do not edit code in this house π
// Run this code
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <utility>
#include <unordered_map>
int main()
{
auto show_node = [](const std::pair<std::string, std::string>& node)
{
std::cout << node.first << " : " << node.second << '\n';
};
std::unordered_multimap<std::string, std::string> lemmas;
assert(lemmas.begin() == lemmas.end());
assert(lemmas.cbegin() == lemmas.cend());
lemmas.insert({ "1. βx β N βy β N", "x β€ y" });
show_node(*lemmas.cbegin());
assert(lemmas.begin() != lemmas.end());
assert(lemmas.cbegin() != lemmas.cend());
lemmas.begin()->second = "x < y";
show_node(*lemmas.cbegin());
lemmas.insert({ "2. βx, y β N ", "x = y V x β y" });
show_node(*lemmas.cbegin());
lemmas.insert({ "3. βx β N βy β N", "y = x + 1" });
show_node(*lemmas.cbegin());
std::cout << "Lemmas: \n";
std::for_each(lemmas.cbegin(), lemmas.cend(), [&](const auto& n)
{
show_node(n);
});
std::cout << '\n';
}
π Possible output π
Possible output, exactly as the page lists it:
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
Lemmas:
3. βx β N βy β N : y = x + 1
1. βx β N βy β N : x < y
2. βx, y β N : x = y V x β y
π See also π
endβ returns an iterator to the endcendβ (public member function)begincbeginβ returns an iterator to the beginning of a container or array(C++11)β (function template)(C++14)
okay bye bestie π«Ά this page came from http://cppreference.com, dated 2024.06.10, and the footer says std::unorde...imap::begin,(3). slay, periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms