-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_map_initialization.cpp
42 lines (36 loc) · 1.01 KB
/
static_map_initialization.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
#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
using namespace std;
int main()
{
map<string, int> ordered;
ordered["hello"] = 1;
ordered["world"] = 2;
for (auto &p : ordered)
cout << p.first << p.second << endl;
cout << "ordered map size:" << ordered.size() << endl
<< endl;
unordered_map<string, int> unordered;
unordered["hello"] = 3;
for (auto &p : unordered)
cout << p.first << p.second << endl;
cout << "unordered map size:" << unordered.size() << endl
<< endl;
set<int> _s;
_s.insert(543);
_s.insert(123);
if (_s.find(123) != _s.end())
cout << "found: 123" << endl;
cout << "set size:" << _s.size() << endl
<< endl;
unordered_set<int> unordered_s;
unordered_s.insert(123);
if (unordered_s.find(123) != unordered_s.end())
unordered_s.erase(123);
cout << "unordered set size:" << unordered_s.size() << endl
<< endl;
}