std::unorde...ltimap::size(3)

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

πŸ’… std::unorde...ltimap::size(3) πŸ’…

okay so bestie, welcome to the C++ Standard Libary manual β€” yes, β€œLibary” is literally how the header spells it, and we’re not fixing it, we’re respecting the icon behavior. 😌 The title up top is the truncated-looking std::unorde...ltimap::size(3), and this whole page is about std::unordered_multimap::size. It’s lowkey the easiest win in the entire container world. 🫢


🌸 NAME 🌸

std::unordered_multimap::size β€” std::unordered_multimap::size

that’s it, that’s the name, no notes πŸ’…

✨ Synopsis ✨

size_type size() const noexcept;  (since C++11)

So you call .size() on your std::unordered_multimap, and it returns the number of elements in the container, i.e. std::distance(begin(), end()). periodt. ✨

πŸŽ€ Parameters πŸŽ€

(none) β€” not a single argument, not a secret optional vibe, nothing. πŸ’€

πŸ’– Return value πŸ’–

The number of elements in the container. That’s the whole tea. πŸ“

πŸ¦‹ Complexity πŸ¦‹

Constant. fr fr. πŸ’…

πŸ”₯ Example πŸ”₯

The following code uses size to display the number of elements in a std::unordered_multimap.

The page also drops a little // Run this code marker right before the block:

#include <iostream>
#include <unordered_map>

int main()
{
    std::unordered_multimap<int,char> nums{{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}};

    std::cout << "nums contains " << nums.size() << " elements.\n";
}

⭐ Output ⭐

nums contains 4 elements.

πŸ‘‘ See also πŸ‘‘

  • empty β€” checks whether the container is empty (public member function)
  • max_size β€” returns the maximum possible number of elements (public member function)
  • size β€” (C++17) β€” the original places it right above the shared returns the size of a container or array description
  • ssize β€” returns the size of a container or array (function template) (C++20)

and that’s the whole page, bestie! footer vibes, lovingly preserved: source http://cppreference.com, date 2024.06.10, and title std::unorde...ltimap::size(3). πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from