unordered_multimap begin() and end() function in C++ STL
Last Updated :
17 Jun, 2022
The unordered_multimap::begin() is a built-in function in C++ STL that returns an iterator pointing to the first element in the container or to the first element in one of its buckets.
Syntax:
unordered_multimap_name.begin(n)
Parameters: The function accepts one parameter. If a parameter is passed, it returns an iterator pointing to the first element in the bucket. If no parameter is passed, then it returns a constant iterator pointing to the first element in the unordered_multimap container.
Return Value: It returns an iterator. It cannot be used to change the value of the unordered_multimap element.
Below are programs that illustrate the above function:
Program 1:
CPP
// C++ program to illustrate the
// unordered_multimap::begin() function
#include& lt; bits / stdc++.h & gt;
using namespace std;
int main()
{
// declaration
unordered_multimap& lt;
int, int& gt;
sample;
// inserts element
sample.insert({ 1, 2 });
sample.insert({ 3, 4 });
sample.insert({ 3, 4 });
sample.insert({ 2, 3 });
sample.insert({ 2, 3 });
// prints all element
cout& lt;
<
"
Key and Elements : \n& quot;
;
for (auto it = sample.