PageRenderTime 35ms CodeModel.GetById 12ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 1ms

/project/jni/stlport/stlport/stl/_iterator_old.h

https://github.com/aichunyu/FFPlayer
C Header | 351 lines | 280 code | 36 blank | 35 comment | 15 complexity | 4393296946dc3d95d8696b6360e272bb MD5 | raw file
  1/*
  2 *
  3 * Copyright (c) 1994
  4 * Hewlett-Packard Company
  5 *
  6 * Copyright (c) 1996-1998
  7 * Silicon Graphics Computer Systems, Inc.
  8 *
  9 * Copyright (c) 1997
 10 * Moscow Center for SPARC Technology
 11 *
 12 * Copyright (c) 1999
 13 * Boris Fomitchev
 14 *
 15 * This material is provided "as is", with absolutely no warranty expressed
 16 * or implied. Any use is at your own risk.
 17 *
 18 * Permission to use or copy this software for any purpose is hereby granted
 19 * without fee, provided the above notices are retained on all copies.
 20 * Permission to modify the code and to distribute modified code is granted,
 21 * provided the above notices are retained, and a notice that the code was
 22 * modified is included with the above copyright notice.
 23 *
 24 */
 25
 26/* NOTE: This is an internal header file, included by other STL headers.
 27 *   You should not attempt to use it directly.
 28 */
 29
 30#ifndef _STLP_INTERNAL_ITERATOR_OLD_H
 31#define _STLP_INTERNAL_ITERATOR_OLD_H
 32
 33#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
 34# include <stl/_iterator_base.h>
 35#endif
 36
 37_STLP_BEGIN_NAMESPACE
 38
 39# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
 40
 41template <class _Container>
 42inline output_iterator_tag _STLP_CALL
 43iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
 44template <class _Container>
 45inline output_iterator_tag _STLP_CALL
 46iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
 47template <class _Container>
 48inline output_iterator_tag _STLP_CALL
 49iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
 50
 51# endif
 52
 53# if defined (_STLP_MSVC50_COMPATIBILITY)
 54# define __Reference _Reference, class _Pointer
 55# define Reference__ _Reference, _Pointer
 56template <class _BidirectionalIterator, class _Tp,
 57    _STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
 58    _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
 59    _STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
 60# else
 61# define __Reference _Reference
 62# define Reference__ _Reference
 63template <class _BidirectionalIterator, class _Tp, _STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
 64    _STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
 65# endif
 66class reverse_bidirectional_iterator {
 67  typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
 68                                         Reference__, _Distance> _Self;
 69  //  friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& x, const _Self& y);
 70protected:
 71  _BidirectionalIterator current;
 72public:
 73  typedef bidirectional_iterator_tag iterator_category;
 74  typedef _Tp                        value_type;
 75  typedef _Distance                  difference_type;
 76# if defined (_STLP_MSVC50_COMPATIBILITY)
 77  typedef _Pointer                   pointer;
 78# else
 79  typedef _Tp*                       pointer;
 80# endif
 81  typedef _Reference                 reference;
 82
 83  reverse_bidirectional_iterator() {}
 84  explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
 85    : current(__x) {}
 86  _BidirectionalIterator base() const { return current; }
 87  _Reference operator*() const {
 88    _BidirectionalIterator __tmp = current;
 89    return *(--__tmp);
 90  }
 91# if !(defined _STLP_NO_ARROW_OPERATOR)
 92  _STLP_DEFINE_ARROW_OPERATOR
 93# endif
 94  _Self& operator++() {
 95    --current;
 96    return *this;
 97  }
 98  _Self operator++(int) {
 99    _Self __tmp = *this;
100    --current;
101    return __tmp;
102  }
103  _Self& operator--() {
104    ++current;
105    return *this;
106  }
107  _Self operator--(int) {
108    _Self __tmp = *this;
109    ++current;
110    return __tmp;
111  }
112};
113
114# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
115template <class _BidirectionalIterator, class _Tp, class __Reference,
116          class _Distance>
117inline bidirectional_iterator_tag _STLP_CALL
118iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
119{ return bidirectional_iterator_tag(); }
120template <class _BidirectionalIterator, class _Tp, class __Reference,
121  class _Distance>
122inline _Tp* _STLP_CALL
123value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
124{ return (_Tp*) 0; }
125template <class _BidirectionalIterator, class _Tp, class __Reference,
126          class _Distance>
127inline _Distance* _STLP_CALL
128distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
129{ return (_Distance*) 0; }
130#endif
131
132template <class _BidirectionalIterator, class _Tp, class __Reference,
133          class _Distance>
134inline bool  _STLP_CALL operator==(
135    const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
136                                               Reference__, _Distance>& __x,
137    const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
138                                               Reference__, _Distance>& __y)
139{
140  return __x.base() == __y.base();
141}
142
143#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
144
145template <class _BiIter, class _Tp, class __Reference, class _Distance>
146inline bool  _STLP_CALL operator!=(
147    const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __x,
148    const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __y)
149{
150  return !(__x == __y);
151}
152
153#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
154
155#if ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
156
157// This is the old version of reverse_iterator, as found in the original
158//  HP STL.  It does not use partial specialization.
159
160template <class _RandomAccessIterator,
161# if defined (__MSL__) && (__MSL__ >= 0x2405) \
162  || defined(__MRC__) || (defined(__SC__) && !defined(__DMC__))    //*ty 03/22/2001 - give the default to the secont param under MPW.
163                        // I believe giving the default will cause any harm even though the 2nd type parameter
164                        // still have to be provided for T* type iterators.
165  _STLP_DFL_TMPL_PARAM(_Tp,iterator_traits<_RandomAccessIterator>::value_type),
166# else
167  class _Tp,
168#endif
169 _STLP_DFL_TMPL_PARAM(_Reference,_Tp&),
170# if defined (_STLP_MSVC50_COMPATIBILITY)
171        _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
172# endif
173        _STLP_DFL_TYPE_PARAM(_Distance,ptrdiff_t)>
174class reverse_iterator {
175  typedef reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>
176          _Self;
177protected:
178  _RandomAccessIterator __current;
179public:
180  typedef random_access_iterator_tag iterator_category;
181  typedef _Tp                        value_type;
182  typedef _Distance                  difference_type;
183# if defined (_STLP_MSVC50_COMPATIBILITY)
184  typedef _Pointer                   pointer;
185# else
186  typedef _Tp*                       pointer;
187# endif
188  typedef _Reference                 reference;
189
190  reverse_iterator() {}
191  reverse_iterator(const _Self& __x) : __current(__x.base()) {}
192  explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {}
193  _Self& operator=(const _Self& __x) {__current = __x.base(); return *this; }
194
195  _RandomAccessIterator base() const { return __current; }
196  _Reference operator*() const { return *(__current - (difference_type)1); }
197
198# if !(defined _STLP_NO_ARROW_OPERATOR)
199  _STLP_DEFINE_ARROW_OPERATOR
200# endif
201
202  _Self& operator++() {
203    --__current;
204    return *this;
205  }
206  _Self operator++(int) {
207    _Self __tmp = *this;
208    --__current;
209    return __tmp;
210  }
211  _Self& operator--() {
212    ++__current;
213    return *this;
214  }
215  _Self operator--(int) {
216    _Self __tmp = *this;
217    ++__current;
218    return __tmp;
219  }
220  _Self operator+(_Distance __n) const {
221    return _Self(__current - __n);
222  }
223  _Self& operator+=(_Distance __n) {
224    __current -= __n;
225    return *this;
226  }
227  _Self operator-(_Distance __n) const {
228    return _Self(__current + __n);
229  }
230  _Self& operator-=(_Distance __n) {
231    __current += __n;
232    return *this;
233  }
234  _Reference operator[](_Distance __n) const { return *(*this + __n); }
235};
236
237# ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
238template <class _RandomAccessIterator, class _Tp,
239          class __Reference, class _Distance>
240inline random_access_iterator_tag _STLP_CALL
241iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
242{ return random_access_iterator_tag(); }
243template <class _RandomAccessIterator, class _Tp,
244  class __Reference, class _Distance>
245inline _Tp*  _STLP_CALL value_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
246{ return (_Tp*) 0; }
247template <class _RandomAccessIterator, class _Tp,
248          class __Reference, class _Distance>
249inline _Distance*  _STLP_CALL
250distance_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
251{ return (_Distance*) 0; }
252#endif
253
254template <class _RandomAccessIterator, class _Tp,
255          class __Reference, class _Distance>
256inline bool  _STLP_CALL
257operator==(const reverse_iterator<_RandomAccessIterator, _Tp,
258                                  Reference__, _Distance>& __x,
259           const reverse_iterator<_RandomAccessIterator, _Tp,
260                                  Reference__, _Distance>& __y)
261{
262  return __x.base() == __y.base();
263}
264
265template <class _RandomAccessIterator, class _Tp,
266          class __Reference, class _Distance>
267inline bool _STLP_CALL
268operator<(const reverse_iterator<_RandomAccessIterator, _Tp,
269                                 Reference__, _Distance>& __x,
270          const reverse_iterator<_RandomAccessIterator, _Tp,
271                                 Reference__, _Distance>& __y)
272{
273  return __y.base() < __x.base();
274}
275
276#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
277
278template <class _RandomAccessIterator, class _Tp,
279          class __Reference, class _Distance>
280inline bool _STLP_CALL
281operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
282                                  Reference__, _Distance>& __x,
283           const reverse_iterator<_RandomAccessIterator, _Tp,
284                                  Reference__, _Distance>& __y) {
285  return !(__x == __y);
286}
287
288template <class _RandomAccessIterator, class _Tp,
289          class __Reference, class _Distance>
290inline bool _STLP_CALL
291operator>(const reverse_iterator<_RandomAccessIterator, _Tp,
292                                 Reference__, _Distance>& __x,
293          const reverse_iterator<_RandomAccessIterator, _Tp,
294                                 Reference__, _Distance>& __y) {
295  return __y < __x;
296}
297
298template <class _RandomAccessIterator, class _Tp,
299          class __Reference, class _Distance>
300inline bool _STLP_CALL
301operator<=(const reverse_iterator<_RandomAccessIterator, _Tp,
302                                  Reference__, _Distance>& __x,
303           const reverse_iterator<_RandomAccessIterator, _Tp,
304                                  Reference__, _Distance>& __y) {
305  return !(__y < __x);
306}
307
308template <class _RandomAccessIterator, class _Tp,
309          class __Reference, class _Distance>
310inline bool _STLP_CALL
311operator>=(const reverse_iterator<_RandomAccessIterator, _Tp,
312                                  Reference__, _Distance>& __x,
313           const reverse_iterator<_RandomAccessIterator, _Tp,
314                                  Reference__, _Distance>& __y) {
315  return !(__x < __y);
316}
317
318#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
319
320template <class _RandomAccessIterator, class _Tp,
321          class __Reference, class _Distance>
322inline _Distance  _STLP_CALL
323operator-(const reverse_iterator<_RandomAccessIterator, _Tp,
324                                 Reference__, _Distance>& __x,
325          const reverse_iterator<_RandomAccessIterator, _Tp,
326                                 Reference__, _Distance>& __y)
327{
328  return __y.base() - __x.base();
329}
330
331template <class _RandomAccessIterator, class _Tp,
332          class __Reference, class _Distance>
333inline reverse_iterator<_RandomAccessIterator, _Tp,
334                        Reference__, _Distance>  _STLP_CALL
335operator+(_Distance __n,
336          const reverse_iterator<_RandomAccessIterator, _Tp,
337                                 Reference__, _Distance>& __x)
338{
339  return reverse_iterator<_RandomAccessIterator, _Tp,
340                          Reference__, _Distance>(__x.base() - __n);
341}
342
343#endif /* ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) */
344
345_STLP_END_NAMESPACE
346
347#endif /* _STLP_INTERNAL_ITERATOR_H */
348
349// Local Variables:
350// mode:C++
351// End: