00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _STLP_INTERNAL_ITERATOR_OLD_H
00031 #define _STLP_INTERNAL_ITERATOR_OLD_H
00032
00033 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
00034 # include <stl/_iterator_base.h>
00035 #endif
00036
00037 _STLP_BEGIN_NAMESPACE
00038
00039 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00040
00041 template <class _Container>
00042 inline output_iterator_tag _STLP_CALL
00043 iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
00044 template <class _Container>
00045 inline output_iterator_tag _STLP_CALL
00046 iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
00047 template <class _Container>
00048 inline output_iterator_tag _STLP_CALL
00049 iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
00050
00051 # endif
00052
00053 # if defined (_STLP_MSVC50_COMPATIBILITY)
00054 # define __Reference _Reference, class _Pointer
00055 # define Reference__ _Reference, _Pointer
00056 template <class _BidirectionalIterator, class _Tp,
00057 __DFL_TMPL_PARAM(_Reference, _Tp& ),
00058 __DFL_TMPL_PARAM(_Pointer, _Tp*),
00059 __DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
00060 # else
00061 # define __Reference _Reference
00062 # define Reference__ _Reference
00063 template <class _BidirectionalIterator, class _Tp, __DFL_TMPL_PARAM(_Reference, _Tp& ),
00064 __DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
00065 # endif
00066 class reverse_bidirectional_iterator {
00067 typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
00068 Reference__, _Distance> _Self;
00069
00070 protected:
00071 _BidirectionalIterator current;
00072 public:
00073 typedef bidirectional_iterator_tag iterator_category;
00074 typedef _Tp value_type;
00075 typedef _Distance difference_type;
00076 # if defined (_STLP_MSVC50_COMPATIBILITY)
00077 typedef _Pointer pointer;
00078 # else
00079 typedef _Tp* pointer;
00080 # endif
00081 typedef _Reference reference;
00082
00083 reverse_bidirectional_iterator() {}
00084 explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
00085 : current(__x) {}
00086 _BidirectionalIterator base() const { return current; }
00087 _Reference operator*() const {
00088 _BidirectionalIterator __tmp = current;
00089 return *--__tmp;
00090 }
00091 # if !(defined _STLP_NO_ARROW_OPERATOR) && ! defined (_STLP_MSVC50_COMPATIBILITY)
00092 _STLP_DEFINE_ARROW_OPERATOR
00093 # endif
00094 _Self& operator++() {
00095 --current;
00096 return *this;
00097 }
00098 _Self operator++(int) {
00099 _Self __tmp = *this;
00100 --current;
00101 return __tmp;
00102 }
00103 _Self& operator--() {
00104 ++current;
00105 return *this;
00106 }
00107 _Self operator--(int) {
00108 _Self __tmp = *this;
00109 ++current;
00110 return __tmp;
00111 }
00112 };
00113
00114 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00115 template <class _BidirectionalIterator, class _Tp, class __Reference,
00116 class _Distance>
00117 inline bidirectional_iterator_tag _STLP_CALL
00118 iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
00119 { return bidirectional_iterator_tag(); }
00120 template <class _BidirectionalIterator, class _Tp, class __Reference,
00121 class _Distance>
00122 inline _Tp* _STLP_CALL
00123 value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
00124 { return (_Tp*) 0; }
00125 template <class _BidirectionalIterator, class _Tp, class __Reference,
00126 class _Distance>
00127 inline _Distance* _STLP_CALL
00128 distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
00129 { return (_Distance*) 0; }
00130 #endif
00131
00132 template <class _BidirectionalIterator, class _Tp, class __Reference,
00133 class _Distance>
00134 inline bool _STLP_CALL operator==(
00135 const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
00136 Reference__, _Distance>& __x,
00137 const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
00138 Reference__, _Distance>& __y)
00139 {
00140 return __x.base() == __y.base();
00141 }
00142
00143 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
00144
00145 template <class _BiIter, class _Tp, class __Reference, class _Distance>
00146 inline bool _STLP_CALL operator!=(
00147 const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __x,
00148 const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __y)
00149 {
00150 return !(__x == __y);
00151 }
00152
00153 #endif
00154
00155 #if ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
00156
00157
00158
00159
00160 template <class _RandomAccessIterator,
00161 # if defined (__MSL__) && (__MSL__ >= 0x2405) \
00162 || defined(__MRC__) || defined(__SC__) //*ty 03/22/2001 - give the default to the secont param under MPW.
00163
00164
00165 __DFL_TMPL_PARAM(_Tp,iterator_traits<_RandomAccessIterator>::value_type),
00166 # else
00167 class _Tp,
00168 #endif
00169 __DFL_TMPL_PARAM(_Reference,_Tp&),
00170 # if defined (_STLP_MSVC50_COMPATIBILITY)
00171 __DFL_TMPL_PARAM(_Pointer, _Tp*),
00172 # endif
00173 __DFL_TYPE_PARAM(_Distance,ptrdiff_t)>
00174 class reverse_iterator {
00175 typedef reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>
00176 _Self;
00177 protected:
00178 _RandomAccessIterator __current;
00179 public:
00180 typedef random_access_iterator_tag iterator_category;
00181 typedef _Tp value_type;
00182 typedef _Distance difference_type;
00183 # if defined (_STLP_MSVC50_COMPATIBILITY)
00184 typedef _Pointer pointer;
00185 # else
00186 typedef _Tp* pointer;
00187 # endif
00188 typedef _Reference reference;
00189
00190 reverse_iterator() {}
00191 reverse_iterator(const _Self& __x) : __current(__x.base()) {}
00192 explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {}
00193 _Self& operator=(const _Self& __x) {__current = __x.base(); return *this; }
00194
00195 _RandomAccessIterator base() const { return __current; }
00196 _Reference operator*() const { return *(__current - (difference_type)1); }
00197
00198 # if !(defined _STLP_NO_ARROW_OPERATOR) && ! defined (_STLP_MSVC50_COMPATIBILITY)
00199 _STLP_DEFINE_ARROW_OPERATOR
00200 # endif
00201
00202 _Self& operator++() {
00203 --__current;
00204 return *this;
00205 }
00206 _Self operator++(int) {
00207 _Self __tmp = *this;
00208 --__current;
00209 return __tmp;
00210 }
00211 _Self& operator--() {
00212 ++__current;
00213 return *this;
00214 }
00215 _Self operator--(int) {
00216 _Self __tmp = *this;
00217 ++__current;
00218 return __tmp;
00219 }
00220 _Self operator+(_Distance __n) const {
00221 return _Self(__current - __n);
00222 }
00223 _Self& operator+=(_Distance __n) {
00224 __current -= __n;
00225 return *this;
00226 }
00227 _Self operator-(_Distance __n) const {
00228 return _Self(__current + __n);
00229 }
00230 _Self& operator-=(_Distance __n) {
00231 __current += __n;
00232 return *this;
00233 }
00234 _Reference operator[](_Distance __n) const { return *(*this + __n); }
00235 };
00236
00237 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00238 template <class _RandomAccessIterator, class _Tp,
00239 class __Reference, class _Distance>
00240 inline random_access_iterator_tag _STLP_CALL
00241 iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
00242 { return random_access_iterator_tag(); }
00243 template <class _RandomAccessIterator, class _Tp,
00244 class __Reference, class _Distance>
00245 inline _Tp* _STLP_CALL value_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
00246 { return (_Tp*) 0; }
00247 template <class _RandomAccessIterator, class _Tp,
00248 class __Reference, class _Distance>
00249 inline _Distance* _STLP_CALL
00250 distance_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
00251 { return (_Distance*) 0; }
00252 #endif
00253
00254 template <class _RandomAccessIterator, class _Tp,
00255 class __Reference, class _Distance>
00256 inline bool _STLP_CALL
00257 operator==(const reverse_iterator<_RandomAccessIterator, _Tp,
00258 Reference__, _Distance>& __x,
00259 const reverse_iterator<_RandomAccessIterator, _Tp,
00260 Reference__, _Distance>& __y)
00261 {
00262 return __x.base() == __y.base();
00263 }
00264
00265 template <class _RandomAccessIterator, class _Tp,
00266 class __Reference, class _Distance>
00267 inline bool _STLP_CALL
00268 operator<(const reverse_iterator<_RandomAccessIterator, _Tp,
00269 Reference__, _Distance>& __x,
00270 const reverse_iterator<_RandomAccessIterator, _Tp,
00271 Reference__, _Distance>& __y)
00272 {
00273 return __y.base() < __x.base();
00274 }
00275
00276 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
00277
00278 template <class _RandomAccessIterator, class _Tp,
00279 class __Reference, class _Distance>
00280 inline bool _STLP_CALL
00281 operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
00282 Reference__, _Distance>& __x,
00283 const reverse_iterator<_RandomAccessIterator, _Tp,
00284 Reference__, _Distance>& __y) {
00285 return !(__x == __y);
00286 }
00287
00288 template <class _RandomAccessIterator, class _Tp,
00289 class __Reference, class _Distance>
00290 inline bool _STLP_CALL
00291 operator>(const reverse_iterator<_RandomAccessIterator, _Tp,
00292 Reference__, _Distance>& __x,
00293 const reverse_iterator<_RandomAccessIterator, _Tp,
00294 Reference__, _Distance>& __y) {
00295 return __y < __x;
00296 }
00297
00298 template <class _RandomAccessIterator, class _Tp,
00299 class __Reference, class _Distance>
00300 inline bool _STLP_CALL
00301 operator<=(const reverse_iterator<_RandomAccessIterator, _Tp,
00302 Reference__, _Distance>& __x,
00303 const reverse_iterator<_RandomAccessIterator, _Tp,
00304 Reference__, _Distance>& __y) {
00305 return !(__y < __x);
00306 }
00307
00308 template <class _RandomAccessIterator, class _Tp,
00309 class __Reference, class _Distance>
00310 inline bool _STLP_CALL
00311 operator>=(const reverse_iterator<_RandomAccessIterator, _Tp,
00312 Reference__, _Distance>& __x,
00313 const reverse_iterator<_RandomAccessIterator, _Tp,
00314 Reference__, _Distance>& __y) {
00315 return !(__x < __y);
00316 }
00317
00318 #endif
00319
00320 template <class _RandomAccessIterator, class _Tp,
00321 class __Reference, class _Distance>
00322 inline _Distance _STLP_CALL
00323 operator-(const reverse_iterator<_RandomAccessIterator, _Tp,
00324 Reference__, _Distance>& __x,
00325 const reverse_iterator<_RandomAccessIterator, _Tp,
00326 Reference__, _Distance>& __y)
00327 {
00328 return __y.base() - __x.base();
00329 }
00330
00331 template <class _RandomAccessIterator, class _Tp,
00332 class __Reference, class _Distance>
00333 inline reverse_iterator<_RandomAccessIterator, _Tp,
00334 Reference__, _Distance> _STLP_CALL
00335 operator+(_Distance __n,
00336 const reverse_iterator<_RandomAccessIterator, _Tp,
00337 Reference__, _Distance>& __x)
00338 {
00339 return reverse_iterator<_RandomAccessIterator, _Tp,
00340 Reference__, _Distance>(__x.base() - __n);
00341 }
00342
00343 #endif
00344
00345 _STLP_END_NAMESPACE
00346
00347 #endif
00348
00349
00350
00351