-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap_stl.cpp
35 lines (34 loc) · 838 Bytes
/
map_stl.cpp
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
#include <iostream>
#include <map>
using namespace std;
// map is key-value pair
//map only stores unique keys (overwrites when another same key is pushed inside)
// map is sorted according to keys lexo
namespace dudi{
void print(map<string, int> mpp){
for(auto i : mpp){
cout<<i.first<<"->"<<i.second;
cout<<endl;
}
}
}
// everthng is long(n)
int main(){
map<string, int> mpp;
mpp["dudi"] = 32;
mpp["adhi"] = 1;
mpp["vamc"] = 323;
mpp["aneesh"] = 122;
mpp["dudi"] = 100;
mpp["mani"] = 32;
mpp["sasank"] = 223;
mpp["varshith"] = 32;
mpp["aadummy"] = 321;
mpp["aavdummy"] =3234;
dudi::print(mpp);
mpp.erase(mpp.begin(),next(mpp.begin(),2));
cout<<"After deleting:"<<endl;
dudi::print(mpp);
cout<<"Is the map empty:";
cout<<mpp.empty();
}