Multimaps are associative containers available in the C++ Standard Library. They are similar to a map with an addition that multiple elements can have the same keys. The multimap::end()
is a method available in the STL that returns an iterator to a theoretical element that follows the last element in the container.
Syntax:
map_name.end();
Parameters: The multimap::end()
does not accept any parameter:
Return value: Iterator to a theoretical element that follows the last element in the container
Example of multimap::end() method
#include<iostream> #include<map> using namespace std; int main() { multimap<char,int> m; m.insert( pair<int,int> ('a',1) ); m.insert( pair<int,int> ('b',2) ); m.insert( pair<int,int> ('c',3) ); m.insert( pair<int,int> ('d',4) ); multimap<char, int>::iterator it; for( it = m.begin(); it != m.end(); ++it) { cout<< it->first <<" : "<< it->second<< endl; } }
Output:
a : 1 b : 2 c : 3 d : 4