ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_iterator.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996-1998
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_ITERATOR_H
00031 #define _STLP_INTERNAL_ITERATOR_H
00032 
00033 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
00034 #  include <stl/_iterator_base.h>
00035 #endif
00036 
00037 _STLP_BEGIN_NAMESPACE
00038 
00039 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00040 // This is the new version of reverse_iterator, as defined in the
00041 //  draft C++ standard.  It relies on the iterator_traits template,
00042 //  which in turn relies on partial specialization.  The class
00043 //  reverse_bidirectional_iterator is no longer part of the draft
00044 //  standard, but it is retained for backward compatibility.
00045 
00046 template <class _Iterator>
00047 class reverse_iterator :
00048   public iterator<typename iterator_traits<_Iterator>::iterator_category,
00049                   typename iterator_traits<_Iterator>::value_type,
00050                   typename iterator_traits<_Iterator>::difference_type,
00051                   typename iterator_traits<_Iterator>::pointer,
00052                   typename iterator_traits<_Iterator>::reference> {
00053 protected:
00054   _Iterator current;
00055   typedef reverse_iterator<_Iterator> _Self;
00056 public:
00057   typedef typename iterator_traits<_Iterator>::difference_type difference_type;
00058   // pointer type required for arrow operator hidden behind _STLP_DEFINE_ARROW_OPERATOR:
00059   typedef typename iterator_traits<_Iterator>::pointer pointer;
00060   typedef typename iterator_traits<_Iterator>::reference reference;
00061   typedef _Iterator iterator_type;
00062 public:
00063   reverse_iterator() {}
00064   explicit reverse_iterator(iterator_type __x) : current(__x) {}
00065   reverse_iterator(const _Self& __x) : current(__x.current) {}
00066   _Self& operator = (const _Self& __x) { current = __x.base(); return *this; }
00067 #  if defined (_STLP_MEMBER_TEMPLATES)
00068   template <class _Iter>
00069   reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {}
00070   template <class _Iter>
00071   _Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; }
00072 #  endif /* _STLP_MEMBER_TEMPLATES */
00073 
00074   iterator_type base() const { return current; }
00075   reference operator*() const {
00076     _Iterator __tmp = current;
00077     return *--__tmp;
00078   }
00079   _STLP_DEFINE_ARROW_OPERATOR
00080   _Self& operator++() {
00081     --current;
00082     return *this;
00083   }
00084   _Self operator++(int) {
00085     _Self __tmp = *this;
00086     --current;
00087     return __tmp;
00088   }
00089   _Self& operator--() {
00090     ++current;
00091     return *this;
00092   }
00093   _Self operator--(int) {
00094     _Self __tmp = *this;
00095     ++current;
00096     return __tmp;
00097   }
00098 
00099   _Self operator+(difference_type __n) const { return _Self(current - __n); }
00100   _Self& operator+=(difference_type __n) {
00101     current -= __n;
00102     return *this;
00103   }
00104   _Self operator-(difference_type __n) const { return _Self(current + __n); }
00105   _Self& operator-=(difference_type __n) {
00106     current += __n;
00107     return *this;
00108   }
00109   reference operator[](difference_type __n) const { return *(*this + __n); }
00110 };
00111 
00112 template <class _Iterator>
00113 inline bool  _STLP_CALL operator==(const reverse_iterator<_Iterator>& __x,
00114                                    const reverse_iterator<_Iterator>& __y)
00115 { return __x.base() == __y.base(); }
00116 
00117 template <class _Iterator>
00118 inline bool _STLP_CALL operator<(const reverse_iterator<_Iterator>& __x,
00119                                  const reverse_iterator<_Iterator>& __y)
00120 { return __y.base() < __x.base(); }
00121 
00122 #  if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
00123 template <class _Iterator>
00124 inline bool _STLP_CALL operator!=(const reverse_iterator<_Iterator>& __x,
00125                                   const reverse_iterator<_Iterator>& __y)
00126 { return !(__x == __y); }
00127 
00128 template <class _Iterator>
00129 inline bool _STLP_CALL operator>(const reverse_iterator<_Iterator>& __x,
00130                                  const reverse_iterator<_Iterator>& __y)
00131 { return __y < __x; }
00132 
00133 template <class _Iterator>
00134 inline bool _STLP_CALL operator<=(const reverse_iterator<_Iterator>& __x,
00135                                   const reverse_iterator<_Iterator>& __y)
00136 { return !(__y < __x); }
00137 
00138 template <class _Iterator>
00139 inline bool _STLP_CALL operator>=(const reverse_iterator<_Iterator>& __x,
00140                                   const reverse_iterator<_Iterator>& __y)
00141 { return !(__x < __y); }
00142 #  endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
00143 
00144 template <class _Iterator>
00145 #  if defined (__SUNPRO_CC)
00146 inline ptrdiff_t _STLP_CALL
00147 #  else
00148 inline typename reverse_iterator<_Iterator>::difference_type _STLP_CALL
00149 #  endif
00150 operator-(const reverse_iterator<_Iterator>& __x,
00151           const reverse_iterator<_Iterator>& __y)
00152 { return __y.base() - __x.base(); }
00153 
00154 template <class _Iterator, class _DifferenceType>
00155 inline reverse_iterator<_Iterator>  _STLP_CALL
00156 operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x)
00157 { return x.operator+(n); }
00158 #endif
00159 
00160 template <class _Container>
00161 class back_insert_iterator
00162   : public iterator<output_iterator_tag, void, void, void, void> {
00163   typedef back_insert_iterator<_Container> _Self;
00164 protected:
00165   //c is a Standard name (24.4.2.1), do no make it STLport naming convention compliant.
00166   _Container *container;
00167 public:
00168   typedef _Container          container_type;
00169   typedef output_iterator_tag iterator_category;
00170 
00171   explicit back_insert_iterator(_Container& __x) : container(&__x) {}
00172 
00173   _Self& operator=(const _Self& __other) {
00174     container = __other.container;
00175     return *this;
00176   }
00177   _Self& operator=(const typename _Container::value_type& __val) {
00178     container->push_back(__val);
00179     return *this;
00180   }
00181   _Self& operator*() { return *this; }
00182   _Self& operator++() { return *this; }
00183   _Self  operator++(int) { return *this; }
00184 };
00185 
00186 template <class _Container>
00187 inline back_insert_iterator<_Container>  _STLP_CALL back_inserter(_Container& __x)
00188 { return back_insert_iterator<_Container>(__x); }
00189 
00190 template <class _Container>
00191 class front_insert_iterator
00192   : public iterator<output_iterator_tag, void, void, void, void> {
00193   typedef front_insert_iterator<_Container> _Self;
00194 protected:
00195   //c is a Standard name (24.4.2.3), do no make it STLport naming convention compliant.
00196   _Container *container;
00197 public:
00198   typedef _Container          container_type;
00199   typedef output_iterator_tag iterator_category;
00200   explicit front_insert_iterator(_Container& __x) : container(&__x) {}
00201 
00202   _Self& operator=(const _Self& __other) {
00203     container = __other.container;
00204     return *this;
00205   }
00206   _Self& operator=(const typename _Container::value_type& __val) {
00207     container->push_front(__val);
00208     return *this;
00209   }
00210   _Self& operator*() { return *this; }
00211   _Self& operator++() { return *this; }
00212   _Self  operator++(int) { return *this; }
00213 };
00214 
00215 template <class _Container>
00216 inline front_insert_iterator<_Container>  _STLP_CALL front_inserter(_Container& __x)
00217 { return front_insert_iterator<_Container>(__x); }
00218 
00219 template <class _Container>
00220 class insert_iterator
00221   : public iterator<output_iterator_tag, void, void, void, void> {
00222   typedef insert_iterator<_Container> _Self;
00223 protected:
00224   //container is a Standard name (24.4.2.5), do no make it STLport naming convention compliant.
00225   _Container *container;
00226   typename _Container::iterator _M_iter;
00227 public:
00228   typedef _Container          container_type;
00229   typedef output_iterator_tag iterator_category;
00230   insert_iterator(_Container& __x, typename _Container::iterator __i)
00231     : container(&__x), _M_iter(__i) {}
00232 
00233   _Self& operator=(_Self const& __other) {
00234     container = __other.container;
00235     _M_iter = __other._M_iter;
00236     return *this;
00237   }
00238   _Self& operator=(const typename _Container::value_type& __val) {
00239     _M_iter = container->insert(_M_iter, __val);
00240     ++_M_iter;
00241     return *this;
00242   }
00243   _Self& operator*() { return *this; }
00244   _Self& operator++() { return *this; }
00245   _Self& operator++(int) { return *this; }
00246 };
00247 
00248 template <class _Container, class _Iterator>
00249 inline insert_iterator<_Container>  _STLP_CALL
00250 inserter(_Container& __x, _Iterator __i) {
00251   typedef typename _Container::iterator __iter;
00252   return insert_iterator<_Container>(__x, __iter(__i));
00253 }
00254 
00255 _STLP_END_NAMESPACE
00256 
00257 #if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
00258 #  include <stl/_iterator_old.h>
00259 #endif
00260 
00261 #endif /* _STLP_INTERNAL_ITERATOR_H */
00262 
00263 // Local Variables:
00264 // mode:C++
00265 // End:

Generated on Sun May 27 2012 04:29:09 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.