Przejdź do głównej zawartości

std::unordered_multimap size() method

// Const version only
size_type size() const noexcept;

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

Parameters

(none)

Return value

The number of elements in the container.

Complexity

Constant - O(1).

Exceptions

(none)

Example

Main.cpp
#include <unordered_multimap>
#include <iostream>

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

std::cout << "nums contains " << nums.size() << " elements.\n";
}
Output
nums contains 4 elements.
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.

std::unordered_multimap size() method

// Const version only
size_type size() const noexcept;

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

Parameters

(none)

Return value

The number of elements in the container.

Complexity

Constant - O(1).

Exceptions

(none)

Example

Main.cpp
#include <unordered_multimap>
#include <iostream>

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

std::cout << "nums contains " << nums.size() << " elements.\n";
}
Output
nums contains 4 elements.
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.