-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARC.hpp
40 lines (30 loc) · 1006 Bytes
/
ARC.hpp
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
#include <list>
#include <map>
#include <iostream>
#include <algorithm>
#ifndef ARC_H
#define ARC_H
#define PAGE_SIZE 5
namespace arc {
template<typename T1 , typename T2>
class ARC {
public:
ARC();
void print();
T2 fetch(T1 key , T2 &value);
bool load_master_data(T1 key, T2 value);
void clear();
std::list<std::pair<T1, T2>> t1, t2, b1, b2; // b1 and b2 should ideally be vectors as they are proposed to be just history , keeping as list for simplicity for now
private:
void replace(float& p , const T1 & key);
void moveList(std::list<std::pair<T1, T2>> &from, std::list<std::pair<T1, T2>> &to, const T1 & key);
void moveToTop(std::list<std::pair<T1, T2>>& list, const T1 &key , const T2 &value);
void fetchMaster(T1 key , T2 & value , std::list<std::pair<T1, T2>>& to);
void print(std::list<std::pair<T1, T2>>);
bool hit(std::list<std::pair<T1, T2>>, const T1 & key, T2& value);
float p;
unsigned int c;
std::map<T1, T2> masterData;
};
}
#endif // !ARC_H