00001
00002
00008 #if !defined(__ads_IndirectIterator_h__)
00009 #define __ads_IndirectIterator_h__
00010
00011 #include "AdaptedIterator.h"
00012
00013 BEGIN_NAMESPACE_ADS
00014
00016
00021 template<typename _Iterator>
00022 class IndirectIterator :
00023 public AdaptedIterator<
00024 _Iterator,
00025 typename std::iterator_traits<_Iterator>::iterator_category,
00026 typename std::iterator_traits<
00027 typename std::iterator_traits<_Iterator>::value_type >::value_type,
00028 typename std::iterator_traits<_Iterator>::difference_type,
00029
00030
00031
00032
00033 typename std::iterator_traits<_Iterator>::value_type,
00034 typename std::iterator_traits<
00035 typename std::iterator_traits<_Iterator>::value_type >::reference> {
00036 private:
00037
00038
00039
00040
00041
00042 typedef AdaptedIterator<
00043 _Iterator,
00044 typename std::iterator_traits<_Iterator>::iterator_category,
00045 typename std::iterator_traits<
00046 typename std::iterator_traits<_Iterator>::value_type >::value_type,
00047 typename std::iterator_traits<_Iterator>::difference_type,
00048 typename std::iterator_traits<_Iterator>::value_type,
00049 typename std::iterator_traits<
00050 typename std::iterator_traits<_Iterator>::value_type >::reference>
00051 Base;
00052
00053 public:
00054
00055
00056
00057
00058
00060 typedef typename Base::Iterator Iterator;
00061
00062
00063
00065 typedef typename Base::iterator_category iterator_category;
00067 typedef typename Base::value_type value_type;
00069 typedef typename Base::difference_type difference_type;
00071 typedef typename Base::pointer pointer;
00073 typedef typename Base::reference reference;
00074
00075 public:
00076
00077
00079
00080
00082 IndirectIterator() :
00083 Base()
00084 {}
00085
00087 IndirectIterator(const IndirectIterator& other) :
00088 Base(other)
00089 {}
00090
00092 IndirectIterator&
00093 operator=(const IndirectIterator& other) {
00094 Base::operator=(other);
00095 return *this;
00096 }
00097
00099 explicit
00100 IndirectIterator(const Iterator& i) :
00101 Base(i)
00102 {}
00103
00105 IndirectIterator&
00106 operator=(const Iterator& i) {
00107 Base::operator=(i);
00108 return *this;
00109 }
00110
00112
00114
00115
00117 const Iterator&
00118 base() const {
00119 return Base::base();
00120 }
00121
00123
00125
00126
00127
00128
00129
00130
00132 reference
00133 operator*() const {
00134 return **Base::_iterator;
00135 }
00136
00138 pointer
00139 operator->() const {
00140 return *Base::_iterator;
00141 }
00142
00143
00144
00145
00146
00148 IndirectIterator&
00149 operator++() {
00150 ++Base::_iterator;
00151 return *this;
00152 }
00153
00155 IndirectIterator
00156 operator++(int) {
00157 IndirectIterator tmp = *this;
00158 ++Base::_iterator;
00159 return tmp;
00160 }
00161
00162
00163
00164
00165
00167 IndirectIterator&
00168 operator--() {
00169 --Base::_iterator;
00170 return *this;
00171 }
00172
00174 IndirectIterator
00175 operator--(int) {
00176 IndirectIterator tmp = *this;
00177 --Base::_iterator;
00178 return tmp;
00179 }
00180
00181
00182
00183
00184
00186 value_type
00187 operator[](const difference_type& n) const {
00188 return *Base::_iterator[n];
00189 }
00190
00192 IndirectIterator&
00193 operator+=(const difference_type& n) {
00194 Base::_iterator += n;
00195 return *this;
00196 }
00197
00199 IndirectIterator
00200 operator+(const difference_type& n) const {
00201 return IndirectIterator(Base::_iterator + n);
00202 }
00203
00205 IndirectIterator&
00206 operator-=(const difference_type& n) {
00207 Base::_iterator -= n;
00208 return *this;
00209 }
00210
00212 IndirectIterator
00213 operator-(const difference_type& n) const {
00214 return IndirectIterator(Base::_iterator - n);
00215 }
00216
00218 };
00219
00220
00221
00222
00223
00225
00228 template<typename _Iterator>
00229 inline
00230 IndirectIterator<_Iterator>
00231 operator+(typename IndirectIterator<_Iterator>::difference_type n,
00232 const IndirectIterator<_Iterator>& x) {
00233 return x + n;
00234 }
00235
00237
00240 template<typename _Iterator>
00241 inline
00242 IndirectIterator<_Iterator>
00243 constructIndirectIterator() {
00244 return IndirectIterator<_Iterator>();
00245 }
00246
00248
00251 template<typename _Iterator>
00252 inline
00253 IndirectIterator<_Iterator>
00254 constructIndirectIterator(const _Iterator& i) {
00255 return IndirectIterator<_Iterator>(i);
00256 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00269
00274 template<typename _Iterator>
00275 class IndirectIterator2 :
00276 public AdaptedIterator<
00277 _Iterator,
00278 typename std::iterator_traits<_Iterator>::iterator_category,
00279 typename std::iterator_traits<
00280 typename std::iterator_traits<
00281 typename std::iterator_traits<_Iterator>::value_type>::value_type >::value_type,
00282 typename std::iterator_traits<_Iterator>::difference_type,
00283 typename std::iterator_traits<
00284 typename std::iterator_traits<
00285 typename std::iterator_traits<_Iterator>::value_type>::value_type >::pointer,
00286 typename std::iterator_traits<
00287 typename std::iterator_traits<
00288 typename std::iterator_traits<_Iterator>::value_type>::value_type >::reference>
00289 {
00290 private:
00291
00292
00293
00294
00295
00296 typedef AdaptedIterator<
00297 _Iterator,
00298 typename std::iterator_traits<_Iterator>::iterator_category,
00299 typename std::iterator_traits<
00300 typename std::iterator_traits<
00301 typename std::iterator_traits<_Iterator>::value_type>::value_type >::value_type,
00302 typename std::iterator_traits<_Iterator>::difference_type,
00303 typename std::iterator_traits<
00304 typename std::iterator_traits<
00305 typename std::iterator_traits<_Iterator>::value_type>::value_type >::pointer,
00306 typename std::iterator_traits<
00307 typename std::iterator_traits<
00308 typename std::iterator_traits<_Iterator>::value_type>::value_type >::reference>
00309 Base;
00310
00311 public:
00312
00313
00314
00315
00316
00318 typedef typename Base::Iterator Iterator;
00319
00320
00321
00323 typedef typename Base::iterator_category iterator_category;
00325 typedef typename Base::value_type value_type;
00327 typedef typename Base::difference_type difference_type;
00329 typedef typename Base::pointer pointer;
00331 typedef typename Base::reference reference;
00332
00333 public:
00334
00335
00337
00338
00340 IndirectIterator2() :
00341 Base()
00342 {}
00343
00345 IndirectIterator2(const IndirectIterator2& x) :
00346 Base(x)
00347 {}
00348
00350 IndirectIterator2&
00351 operator=(const IndirectIterator2& other) {
00352 Base::operator=(other);
00353 return *this;
00354 }
00355
00357 explicit
00358 IndirectIterator2(const Iterator& i) :
00359 Base(i)
00360 {}
00361
00363 IndirectIterator2&
00364 operator=(const Iterator& other) {
00365 Base::operator=(other);
00366 return *this;
00367 }
00368
00370
00372
00373
00375 const Iterator&
00376 base() const {
00377 return Base::base();
00378 }
00379
00381
00383
00384
00385
00386
00387
00388
00390 reference
00391 operator*() const {
00392 return ***Base::_iterator;
00393 }
00394
00396 pointer
00397 operator->() const {
00398 return **Base::_iterator;
00399 }
00400
00401
00402
00403
00404
00406 IndirectIterator2&
00407 operator++() {
00408 ++Base::_iterator;
00409 return *this;
00410 }
00411
00413 IndirectIterator2
00414 operator++(int) {
00415 IndirectIterator2 tmp = *this;
00416 ++Base::_iterator;
00417 return tmp;
00418 }
00419
00420
00421
00422
00423
00425 IndirectIterator2&
00426 operator--() {
00427 --Base::_iterator;
00428 return *this;
00429 }
00430
00432 IndirectIterator2
00433 operator--(int) {
00434 IndirectIterator2 tmp = *this;
00435 --Base::_iterator;
00436 return tmp;
00437 }
00438
00439
00440
00441
00442
00444 value_type
00445 operator[](const difference_type& n) const {
00446 return **Base::_iterator[n];
00447 }
00448
00450 IndirectIterator2&
00451 operator+=(const difference_type& n) {
00452 Base::_iterator += n;
00453 return *this;
00454 }
00455
00457 IndirectIterator2
00458 operator+(const difference_type& n) const {
00459 return IndirectIterator2(Base::_iterator + n);
00460 }
00461
00463 IndirectIterator2&
00464 operator-=(const difference_type& n) {
00465 Base::_iterator -= n;
00466 return *this;
00467 }
00468
00470 IndirectIterator2
00471 operator-(const difference_type& n) const {
00472 return IndirectIterator2(Base::_iterator - n);
00473 }
00474
00476 };
00477
00478
00479
00480
00481
00483
00486 template<typename _Iterator>
00487 inline
00488 IndirectIterator2<_Iterator>
00489 operator+(typename IndirectIterator2<_Iterator>::difference_type n,
00490 const IndirectIterator2<_Iterator>& x) {
00491 return x + n;
00492 }
00493
00495
00498 template<typename _Iterator>
00499 inline
00500 IndirectIterator2<_Iterator>
00501 constructIndirectIterator2() {
00502 return IndirectIterator2<_Iterator>();
00503 }
00504
00506
00509 template<typename _Iterator>
00510 inline
00511 IndirectIterator2<_Iterator>
00512 constructIndirectIterator2(const _Iterator& i) {
00513 return IndirectIterator2<_Iterator>(i);
00514 }
00515
00516 END_NAMESPACE_ADS
00517
00518 #endif