std::unordered_set::size(3)

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

std::unordered_set::size(3) πŸ‘‘

okay so bestie πŸ’– this is the C++ Standard Libary manual page for std::unordered_set::size, and it is literally the "how many things are in this container" button. No cap.


NAME πŸ’…

std::unordered_set::size - std::unordered_set::size

Synopsis πŸ¦‹

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

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

Parameters πŸŽ€

(none) β€” not a single parameter, bestie. The vibe check is empty, and that's iconic.

Return value 🌸

The number of elements in the container. That's it. That's the whole gift 🫢.

Complexity ⭐

Constant.

Example πŸ’…

The following code uses size to display the number of elements in a std::unordered_set<int>:

// Run this code

#include <iostream>
#include <unordered_set>

int main()
{
    std::unordered_set<int> nums{1, 3, 5, 7};

    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
  • ssize β€” returns the size of a container or array
  • (C++17) β€” (function template)
  • (C++20)

mwah πŸ’‹ this page is from http://cppreference.com and dated 2024.06.10.

πŸ“¦ where this page comes from