-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultimap.cpp
More file actions
43 lines (30 loc) · 1.09 KB
/
Multimap.cpp
File metadata and controls
43 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "stdafx.h"
#include <iostream>
#include <map>
#include <string>
using namespace std;
int _main8(int argc, _TCHAR* argv[]) {
multimap<int, string> lookup;
lookup.insert(make_pair(30, "Mike"));
lookup.insert(make_pair(10, "Vicky"));
lookup.insert(make_pair(30, "Raj"));
lookup.insert(make_pair(20, "Bob"));
for(multimap<int, string>::iterator it = lookup.begin(); it != lookup.end(); it++) {
cout << it->first << ": " << it->second << endl;
}
cout << endl;
for(multimap<int, string>::iterator it = lookup.find(20); it != lookup.end(); it++) {
cout << it->first << ": " << it->second << endl;
}
cout << endl;
pair<multimap<int, string>::iterator, multimap<int, string>::iterator> its = lookup.equal_range(30);
for(multimap<int, string>::iterator it = its.first; it != its.second; it++) {
cout << it->first << ": " << it->second << endl;
}
cout << endl;
auto its2 = lookup.equal_range(30);
for(multimap<int, string>::iterator it = its2.first; it != its2.second; it++) {
cout << it->first << ": " << it->second << endl;
}
return 0;
}