-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaptest.cpp
executable file
·32 lines (29 loc) · 1.03 KB
/
maptest.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
#include <iostream>
#include <map>
int main()
{
map<const char*, int> months;
months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;
cout << "june -> " << months["june"] << endl;
map<const char*, int>::iterator cur = months.find("june");
map<const char*, int>::iterator test= months.find("mom");
if (!(*test).first)
cout<<"example of find that isnt there: "<<(*test).first<<endl;
map<const char*, int>::iterator prev = cur;
map<const char*, int>::iterator next = cur;
++next;
--prev;
cout << "Previous (in alphabetical order) is " << (*prev).first << endl;
cout << "Next (in alphabetical order) is " << (*next).first << endl;
}