std::unordered_map::size(3)
π¦ std::unordered_map::size(3) π¦
okay bestie, welcome to the std::unordered_map::size page from the C++ Standard Libary manual. this is literally the βhow many elements are in my containerβ moment, and itβs giving main character energy. π
β¨
πΈ NAME πΈ
std::unordered_map::size β std::unordered_map::size
β¨ Synopsis β¨
size_type size() const noexcept; (since C++11)
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
bestie, thatβs the whole vibe: count the elements. π«Ά
π Parameters π
(none) β zero arguments, not a single one. iconic. β¨
π Return value π
The number of elements in the container.
β Complexity β
Constant. literally constant, no cap. π
π₯ Example π₯
The following code uses size to display the number of elements in a std::unordered_map:
// Run this code
#include <iostream>
#include <unordered_map>
int main()
{
std::unordered_map<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/ssizeβreturns the size of a container or array;(C++17)/(C++20);(function template)
mwah π source: http://cppreference.com; version/date: 2024.06.10; this is the std::unordered_map::size(3) page β go count your elements, bestie! π«Άβ¨
π¦ 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