-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
30 lines (22 loc) · 706 Bytes
/
Copy pathtest.cpp
File metadata and controls
30 lines (22 loc) · 706 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
#include <iostream>
#include <map>
int main ()
{
std::map<char,int> mymap;
mymap['x']=1001;
mymap['y']=4004;
mymap['z']=3003;
std::cout << "mymap contains:\n";
std::pair<char,int> highest = *mymap.rbegin(); // last element
std::map<char,int>::iterator it = mymap.begin();
do {
std::cout << it->first << " => " << it->second << '\n';
} while ( mymap.value_comp()(*it++, highest) );
char highest2 = mymap.rbegin()->first; // key value of last element
std::map<char,int>::key_compare mycomp = mymap.key_comp();
it = mymap.begin();
do {
std::cout << it->first << " => " << it->second << '\n';
} while ( mycomp((*it++).first, highest2) );
return 0;
}