forked from yangxu02/LFUCache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
59 lines (51 loc) · 1.82 KB
/
Main.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
#include "LFUCache.h"
int main(int argc, char* argv[]) {
LFUCache lfu(2);
std::cerr << lfu.repr() << std::endl;
lfu.set(1, 1);
std::cerr << lfu.repr() << std::endl;
lfu.set(2, 2);
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(1) << std::endl;
std::cerr << lfu.repr() << std::endl;
lfu.set(3, 3);
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(2) << std::endl;
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(3) << std::endl;
std::cerr << lfu.repr() << std::endl;
lfu.set(4, 4);
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(1) << std::endl;
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(3) << std::endl;
std::cerr << lfu.repr() << std::endl;
std::cerr << lfu.get(4) << std::endl;
std::cerr << lfu.repr() << std::endl;
std::cerr << "===================" << std::endl;
LFUCache lfu2(3);
std::cerr << lfu2.repr() << std::endl;
lfu2.set(2, 2);
std::cerr << lfu2.repr() << std::endl;
lfu2.set(1, 1);
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(2) << std::endl;
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(1) << std::endl;
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(2) << std::endl;
std::cerr << lfu2.repr() << std::endl;
lfu2.set(3, 3);
std::cerr << lfu2.repr() << std::endl;
lfu2.set(4, 4);
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(3) << std::endl;
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(2) << std::endl;
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(1) << std::endl;
std::cerr << lfu2.repr() << std::endl;
std::cerr << lfu2.get(4) << std::endl;
std::cerr << lfu2.repr() << std::endl;
return 0;
}