-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheIterator.h
More file actions
executable file
·141 lines (112 loc) · 3.01 KB
/
Copy pathCacheIterator.h
File metadata and controls
executable file
·141 lines (112 loc) · 3.01 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef INTERNAL_CACHE_ITERATOR_PROTECTOR
#define INTERNAL_CACHE_ITERATOR_PROTECTOR
#include "strkey.h"
#include "Exceptions.h"
#include "common_includes.h"
#include <map>
#include <list>
#include <iterator>
#define FOR_ITERATOR 1
#define CONST_FOR_ITER 2
#define REV_ITER 3
#define CONST_REV_ITER 4
#define START_ITER 1
#define BACKW_ITER 2
/*
* Dont forget to overload the -- ++ on both sides of the
* value
* */
/*
*
* dont forget to write code to assign a
* non_const iterator to a const_iterator
*
* */
using namespace std;
template <typename VALUE>
class CacheInternalIterator
{
list<CacheInternalIterator<VALUE>*>* _observerList;
public:
CacheInternalIterator();
CacheInternalIterator(int type);
CacheInternalIterator
(
int type ,
map <const Key*,VALUE*,hashcode_compare>* MapPtr,
int start_or_end
);
~CacheInternalIterator();
/*
* compare if 2 operators are the same
* */
bool operator==(const CacheInternalIterator& CI);
bool operator!=(const CacheInternalIterator& CI);
/*
* incremenet the iterator to the next one
* */
CacheInternalIterator
operator++(int add);
/*
* decrement the iterator to the previous one
* */
CacheInternalIterator
operator--(int take);
CacheInternalIterator&
operator++();
CacheInternalIterator&
operator--();
/*
* assign to this iterator
* */
CacheInternalIterator&
operator=( CacheInternalIterator input_type);
/*
* dereference this operator
* */
VALUE&
operator*() const;
/*
* we want to call a function out of this
* iterator
* */
VALUE*
operator->() const ;
/*
* will return if the iterator is
* valid or not
* */
void setIteratorStatus(bool status);
bool getIteratorStatus();
// get the internal map address
map <const Key*,VALUE*, hashcode_compare>*
getInternalMapAddress() const;
// gets the internal map iterator
typename map<const Key*,VALUE*,hashcode_compare>::iterator
getInternalMapIterator() const;
typename map<const Key*,VALUE*,hashcode_compare>::reverse_iterator
getInternalReverseMapIterator() const;
int mapsize;
int getBeginOrEnd() const;
int getIteratorType() const;
const Key* getInternalKeyMapInterator() const;
bool getIsIteratorValid() {return isIteratorValid;}
list<CacheInternalIterator<VALUE>*>* getList();
private:
typename map<const Key*,VALUE*,hashcode_compare>
::iterator _current_map_iter;
typename map<const Key*,VALUE*,hashcode_compare>
::reverse_iterator _current_rev_map_iter;
typename map<const Key*,VALUE*,hashcode_compare>
::const_iterator _current_const_map_iter;
typename map<const Key*,VALUE*, hashcode_compare>
::const_reverse_iterator _current_const_rev_map_iter;
map<const Key*,VALUE*,hashcode_compare>* _MapPtr;
int currentHashCode;
int iterator_type;
int iterator_beginEnd;
mutable bool isIteratorValid;
protected:
};
#include "CacheIterator.tem"
#endif