=====insert=====
Syntax:
#include
The function insert() either:
*inserts val after the element at pos (where pos is really just a suggestion as to where val should go, since multimaps are ordered), and returns an iterator to that element.
* inserts val into the multimap, returning an iterator to the element inserted.
* inserts a range of elements from start to end.
For example, the following code uses the insert() function to add several
pairs to a employee multimap:
multimap m;
int employeeID = 0;
m.insert( pair("Bob Smith",employeeID++) );
m.insert( pair("Bob Thompson",employeeID++) );
m.insert( pair("Bob Smithey",employeeID++) );
m.insert( pair("Bob Smith",employeeID++) );
cout << "Number of employees named 'Bob Smith': " << m.count("Bob Smith") << endl;
cout << "Number of employees named 'Bob Thompson': " << m.count("Bob Thompson") << endl;
cout << "Number of employees named 'Bob Smithey': " << m.count("Bob Smithey") << endl;
cout << "Employee list: " << endl;
for( multimap::iterator iter = m.begin(); iter != m.end(); ++iter ) {
cout << " Name: " << iter->first << ", ID #" << iter->second << endl;
}
When run, the above code produces the following output:
Number of employees named 'Bob Smith': 2
Number of employees named 'Bob Thompson': 1
Number of employees named 'Bob Smithey': 1
Employee list:
Name: Bob Smith, ID #0
Name: Bob Smith, ID #3
Name: Bob Smithey, ID #2
Name: Bob Thompson, ID #1