-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.cpp
More file actions
37 lines (29 loc) · 673 Bytes
/
Copy pathmap.cpp
File metadata and controls
37 lines (29 loc) · 673 Bytes
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
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<int, string> m; // this is a key->value pair
m[1] = "Shouvik";
m[2] = "Bajpayee";
m.insert({5, "bheem"});
cout << "before erase.." << endl;
for (auto i : m)
{
cout << i.first << " : " << i.second << endl;
}
cout << "finding 13 -> " << m.count(13) << endl;
cout << "finding 5 -> " << m.count(5) << endl;
cout << "after erase.." << endl;
m.erase(2);
for (auto i : m)
{
cout << i.first << " : " << i.second << endl;
}
auto it = m.find(5);
for (auto i = it; i != m.end(); i++)
{
cout << (*i).first << " : " << (*i).second << endl;
}
return 0;
}