-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnorderedMap.cpp
More file actions
54 lines (43 loc) · 1.05 KB
/
UnorderedMap.cpp
File metadata and controls
54 lines (43 loc) · 1.05 KB
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
/**
* \file UnorderedMap.cpp
* \brief
*
* \todo
*/
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
template<template<class...> class T>
void test()
{
T<std::string, int> x;
x.insert(std::make_pair("one", 1));
x.insert(std::make_pair("two", 2));
x.insert(std::make_pair("three", 3));
x.insert(std::make_pair("four", 4));
for (const auto& i : x) {
std::cout << "{" << i.first << ", " << i.second << "}" << std::endl;
}
}
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
std::cout << "std::map:" << std::endl;
test<std::map>();
std::cout << "\nstd::unordered_map:" << std::endl;
test<std::unordered_map>();
return 0;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
std::map:
{four, 4}
{one, 1}
{three, 3}
{two, 2}
std::unordered_map:
{four, 4}
{three, 3}
{one, 1}
{two, 2}
#endif