-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheImpl.h
More file actions
executable file
·75 lines (58 loc) · 1.55 KB
/
Copy pathCacheImpl.h
File metadata and controls
executable file
·75 lines (58 loc) · 1.55 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef CACHEIMPL_H
#define CACHEIMPL_H
#include "cache.h"
#include "key.h"
#include "CacheIterator.h"
#include "CacheConstIterator.h"
#include "common_includes.h"
#include "CacheIterHolder.h"
#include <map>
#include <list>
#include <iostream>
using namespace std;
class KeyCompare
{
public:
bool operator()(const Key* k)
{
return (k->hashCode() == _k->hashCode());
}
KeyCompare(const Key* k):_k(k) {};
private:
const Key* _k;
};
template <typename VALUE>
class CacheImpl : public Cache<VALUE>
{
public:
typedef typename CacheIteratorTags<VALUE>
::iterator iterator;
typedef typename CacheIteratorTags<VALUE>
::reverse_iterator reverse_iterator;
typedef typename CacheIteratorTags<VALUE>
::const_iterator const_iterator;
typedef typename CacheIteratorTags<VALUE>
::const_reverse_iterator const_reverse_iterator;
typedef pair<const Key*, VALUE*> KeyValuePair;
CacheImpl(unsigned int capacity);
void insert(const Key& k,const VALUE& v);
reverse_iterator rend();
const_iterator begin() const;
const_iterator end() const;
const_reverse_iterator rbegin() const;
VALUE lookup(const Key& k);
size_t size() const;
size_t capacity() const;
void clear();
iterator begin();
iterator end();
reverse_iterator rbegin();
const_reverse_iterator rend() const;
std::string snapshot() const;
private:
mutable map<const Key*, VALUE*, hashcode_compare> _map;
list<const Key*> _list;
unsigned int _capacity;
};
#include "CacheImpl.tem"
#endif