-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWithPred.cpp
78 lines (62 loc) · 1.59 KB
/
WithPred.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* \file WithPred.cpp
* \brief
*
* \todo
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
struct Hash
{
std::size_t operator() (const int value) const
{
return std::hash<int>()(value);
}
};
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
// Less
{
using int_unordered_map_less_t = std::unordered_map<int, int, Hash, std::less<int>>;
const int_unordered_map_less_t mapLess
{
{11, 9},
{22, 8},
{33, 7}
};
std::cout << "Less: " << std::endl;
for (const auto &[it_key, it_value] : mapLess) {
std::cout << "{" << it_key << ", " << it_value << "}" << std::endl;
}
}
std::cout << std::endl;
// Greater
{
using int_unordered_map_greater_t = std::unordered_map<int, int, Hash, std::greater<int>>;
const int_unordered_map_greater_t mapGreater
{
{11, 9},
{22, 8},
{33, 7}
};
std::cout << "Greater: " << std::endl;
for (const auto &[it_key, it_value] : mapGreater) {
std::cout << "{" << it_key << ", " << it_value << "}" << std::endl;
}
}
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
Less:
{33, 7}
{22, 8}
{11, 9}
Greater:
{33, 7}
{22, 8}
{11, 9}
#endif