std::unorde...ltimap::end,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay bestie, welcome to std::unorde...ltimap::end,(3) from the C++ Standard Libary (yes, that’s the spelling on the page, she’s quirky πŸ’…). This page is about std::unordered_multimap::end β€” and the NAME line literally says std::unordered_multimap::end, - std::unordered_multimap::end, (yes, twice, and we respect the repetition πŸ‘‘).

✨ Synopsis ✨

okay so the signatures are giving overload-family realness:

iterator end() noexcept;              (1) (since C++11)
const_iterator end() const noexcept;  (2) (since C++11)
const_iterator cend() const noexcept; (3) (since C++11)

Each one returns an iterator to the element following the last element of the unordered_multimap.

That element acts as a placeholder, bestie β€” attempting to access it results in undefined behavior. Not me warning you dramatically: do not touch the placeholder 😭.

There’s also a range-begin-end.svg reference here too, just vibing in the original. πŸ¦‹

πŸŽ€ Parameters πŸŽ€

(none) β€” literally none, no arguments, we love a no-param moment.

πŸ’– Return value πŸ’–

An iterator to the element following the last element. Periodt.

πŸ’« Complexity πŸ’«

Constant. literally constant, no cap. ⭐

πŸ“ Example πŸ“

here’s the whole code, copied exactly so you can run it and feel iconic:

        #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: 🌟

and it might print exactly this:

        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 🌈

the original See also section is a little chaotic, so here are all the tokens exactly as they show up:

  • begin β€” returns an iterator to the beginning
  • cbegin β€” (public member function)
  • end
  • cend β€” returns an iterator to the end of a container or array
  • (C++11) β€” (function template)
  • (C++14)

xoxo, your Unix bestie πŸ’– source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::unorde...ltimap::end,(3) ✨

πŸ“¦ where this page comes from