summaryrefslogtreecommitdiffabout
path: root/include/opkele/iterator.h
Unidiff
Diffstat (limited to 'include/opkele/iterator.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/opkele/iterator.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/include/opkele/iterator.h b/include/opkele/iterator.h
index 812a786..28c1c83 100644
--- a/include/opkele/iterator.h
+++ b/include/opkele/iterator.h
@@ -21,22 +21,21 @@ namespace opkele {
21 21
22 }; 22 };
23 23
24 template<typename IT,typename T=typename IT::value_type> 24 template<typename IT,typename T=typename IT::value_type>
25 class output_iterator_proxy_impl : public basic_output_iterator_proxy_impl<T> { 25 class output_iterator_proxy_impl : public basic_output_iterator_proxy_impl<T> {
26 public: 26 public:
27 IT i; 27 IT i;
28 28
29 output_iterator_proxy_impl(const IT& i) : i(i) { } 29 output_iterator_proxy_impl(const IT& _i) : i(_i) { }
30 basic_output_iterator_proxy_impl<T>* dup() const { 30 basic_output_iterator_proxy_impl<T>* dup() const {
31 return new output_iterator_proxy_impl<IT,T>(i); } 31 return new output_iterator_proxy_impl<IT,T>(i); }
32 basic_output_iterator_proxy_impl<T>& operator=(const T& x) { 32 basic_output_iterator_proxy_impl<T>& operator=(const T& x) {
33 (*i) = x; 33 (*i) = x; return *this; }
34 }
35 }; 34 };
36 35
37 template<typename T> 36 template<typename T>
38 class output_iterator_proxy : public iterator<output_iterator_tag,T,void,T*,T&> { 37 class output_iterator_proxy : public iterator<output_iterator_tag,T,void,T*,T&> {
39 public: 38 public:
40 basic_output_iterator_proxy_impl<T> *I; 39 basic_output_iterator_proxy_impl<T> *I;
41 40
42 template<typename IT> 41 template<typename IT>
@@ -46,17 +45,17 @@ namespace opkele {
46 : I(x.I->dup()) { } 45 : I(x.I->dup()) { }
47 ~output_iterator_proxy() { delete I; } 46 ~output_iterator_proxy() { delete I; }
48 47
49 output_iterator_proxy& operator=(const output_iterator_proxy<T>& x) { 48 output_iterator_proxy& operator=(const output_iterator_proxy<T>& x) {
50 delete I; I = x.I->dup(); } 49 delete I; I = x.I->dup(); }
51 50
52 output_iterator_proxy& operator*() { return *this; } 51 output_iterator_proxy& operator*() { return *this; }
53 output_iterator_proxy& operator=(const T& x) { 52 output_iterator_proxy& operator=(const T& x) {
54 (**I) = x; } 53 (**I) = x; return *this; }
55 54
56 output_iterator_proxy& operator++() { return *this; } 55 output_iterator_proxy& operator++() { return *this; }
57 output_iterator_proxy& operator++(int) { return *this; } 56 output_iterator_proxy& operator++(int) { return *this; }
58 }; 57 };
59 58
60 template <typename T,typename TR=T&,typename TP=T*> 59 template <typename T,typename TR=T&,typename TP=T*>
61 class basic_forward_iterator_proxy_impl : public iterator<forward_iterator_tag,T,void,TP,TR> { 60 class basic_forward_iterator_proxy_impl : public iterator<forward_iterator_tag,T,void,TP,TR> {
62 public: 61 public:
@@ -72,17 +71,17 @@ namespace opkele {
72 virtual void advance() = 0; 71 virtual void advance() = 0;
73 }; 72 };
74 73
75 template <typename IT> 74 template <typename IT>
76 class forward_iterator_proxy_impl : public basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer> { 75 class forward_iterator_proxy_impl : public basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer> {
77 public: 76 public:
78 IT i; 77 IT i;
79 78
80 forward_iterator_proxy_impl(const IT& i) : i(i) { } 79 forward_iterator_proxy_impl(const IT& _i) : i(_i) { }
81 80
82 virtual basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>* dup() const { 81 virtual basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>* dup() const {
83 return new forward_iterator_proxy_impl<IT>(i); } 82 return new forward_iterator_proxy_impl<IT>(i); }
84 83
85 virtual bool operator==(const basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>& x) const { 84 virtual bool operator==(const basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>& x) const {
86 return i==static_cast<const forward_iterator_proxy_impl<IT>*>(&x)->i; } 85 return i==static_cast<const forward_iterator_proxy_impl<IT>*>(&x)->i; }
87 virtual bool operator!=(const basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>& x) const { 86 virtual bool operator!=(const basic_forward_iterator_proxy_impl<typename IT::value_type,typename IT::reference,typename IT::pointer>& x) const {
88 return i!=static_cast<const forward_iterator_proxy_impl<IT>*>(&x)->i; } 87 return i!=static_cast<const forward_iterator_proxy_impl<IT>*>(&x)->i; }
@@ -131,18 +130,18 @@ namespace opkele {
131 typename IT::pointer, 130 typename IT::pointer,
132 typename IT::reference> { 131 typename IT::reference> {
133 public: 132 public:
134 IT it; 133 IT it;
135 IT ei; 134 IT ei;
136 bool empty; 135 bool empty;
137 136
138 basic_filterator() : empty(true) { } 137 basic_filterator() : empty(true) { }
139 basic_filterator(const IT& bi,const IT& ei) 138 basic_filterator(const IT& _bi,const IT& _ei)
140 : it(bi), ei(ei) { empty = (bi==ei); } 139 : it(_bi), ei(_ei) { empty = (it==ei); }
141 basic_filterator(const basic_filterator<IT>& x) 140 basic_filterator(const basic_filterator<IT>& x)
142 : it(x.it), ei(x.ei), empty(x.empty) { } 141 : it(x.it), ei(x.ei), empty(x.empty) { }
143 virtual ~basic_filterator() { } 142 virtual ~basic_filterator() { }
144 143
145 bool operator==(const basic_filterator<IT>& x) const { 144 bool operator==(const basic_filterator<IT>& x) const {
146 return empty?x.empty:(it==x.it); } 145 return empty?x.empty:(it==x.it); }
147 bool operator!=(const basic_filterator<IT>& x) const { 146 bool operator!=(const basic_filterator<IT>& x) const {
148 return empty!=x.empty || it!=x.it; } 147 return empty!=x.empty || it!=x.it; }
@@ -180,19 +179,19 @@ namespace opkele {
180 T,void,TP,TR> { 179 T,void,TP,TR> {
181 public: 180 public:
182 typedef map_keys_iterator<IT,T,TR,TP> self_type; 181 typedef map_keys_iterator<IT,T,TR,TP> self_type;
183 IT it; 182 IT it;
184 IT ei; 183 IT ei;
185 bool empty; 184 bool empty;
186 185
187 map_keys_iterator() : empty(true) { } 186 map_keys_iterator() : empty(true) { }
188 map_keys_iterator(const IT& bi, 187 map_keys_iterator(const IT& _bi,
189 const IT& ei) 188 const IT& _ei)
190 : it(bi), ei(ei) { empty = (bi==ei); } 189 : it(_bi), ei(_ei) { empty = (it==ei); }
191 map_keys_iterator(const self_type& x) 190 map_keys_iterator(const self_type& x)
192 : it(x.it), ei(x.ei), empty(x.empty) { } 191 : it(x.it), ei(x.ei), empty(x.empty) { }
193 192
194 bool operator==(const self_type& x) const { 193 bool operator==(const self_type& x) const {
195 return empty?x.empty:(it==x.it); } 194 return empty?x.empty:(it==x.it); }
196 bool operator!=(const self_type& x) const { 195 bool operator!=(const self_type& x) const {
197 return empty!=x.empty || it!=x.it; } 196 return empty!=x.empty || it!=x.it; }
198 197