-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLRUCacheTest.cpp
More file actions
39 lines (33 loc) · 766 Bytes
/
LRUCacheTest.cpp
File metadata and controls
39 lines (33 loc) · 766 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
31
32
33
34
35
36
37
38
39
#include <string>
#include <iostream>
#include "LRUCache.h"
using namespace std;
class MyData {
public:
MyData() {}
int X;
string Y;
};
int main() {
LRUCache<string, MyData> cache(20, 0.4);
for(int i =0; i<10; i++) {
MyData data;
data.X = i;
data.Y = to_string(i);
cache.Put(to_string(i), data);
}
for(int i =0; i<30; i++) {
cout<<i<<" - "<<cache.Exists(to_string(i))<<endl;
if(cache.Exists(to_string(i))) {
cout<<"\t=> "<<cache.Get(to_string(i)).X<<endl;
}
}
for(int i =11; i<30; i++) {
MyData data;
data.X = i;
data.Y = to_string(i);
cout<<"Adding: "<<i<<endl;
cache.Put(to_string(i), data);
}
return 0;
}