epoc32/include/stdapis/stlport/stl/_iterator.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_iterator.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_iterator.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,269 @@
     1.4 -_iterator.h
     1.5 +/*
     1.6 + *
     1.7 + * Copyright (c) 1994
     1.8 + * Hewlett-Packard Company
     1.9 + *
    1.10 + * Copyright (c) 1996-1998
    1.11 + * Silicon Graphics Computer Systems, Inc.
    1.12 + *
    1.13 + * Copyright (c) 1997
    1.14 + * Moscow Center for SPARC Technology
    1.15 + *
    1.16 + * Copyright (c) 1999 
    1.17 + * Boris Fomitchev
    1.18 + *
    1.19 + * This material is provided "as is", with absolutely no warranty expressed
    1.20 + * or implied. Any use is at your own risk.
    1.21 + *
    1.22 + * Permission to use or copy this software for any purpose is hereby granted 
    1.23 + * without fee, provided the above notices are retained on all copies.
    1.24 + * Permission to modify the code and to distribute modified code is granted,
    1.25 + * provided the above notices are retained, and a notice that the code was
    1.26 + * modified is included with the above copyright notice.
    1.27 + *
    1.28 + */
    1.29 +
    1.30 +/* NOTE: This is an internal header file, included by other STL headers.
    1.31 + *   You should not attempt to use it directly.
    1.32 + */
    1.33 +
    1.34 +#ifndef _STLP_INTERNAL_ITERATOR_H
    1.35 +#define _STLP_INTERNAL_ITERATOR_H
    1.36 +
    1.37 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
    1.38 +# include <stl/_iterator_base.h>
    1.39 +#endif
    1.40 +
    1.41 +_STLP_BEGIN_NAMESPACE
    1.42 +
    1.43 +#if defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
    1.44 +// This is the new version of reverse_iterator, as defined in the
    1.45 +//  draft C++ standard.  It relies on the iterator_traits template,
    1.46 +//  which in turn relies on partial specialization.  The class
    1.47 +//  reverse_bidirectional_iterator is no longer part of the draft
    1.48 +//  standard, but it is retained for backward compatibility.
    1.49 +
    1.50 +template <class _Iterator>
    1.51 +class reverse_iterator : 
    1.52 +  public iterator<typename iterator_traits<_Iterator>::iterator_category,
    1.53 +                  typename iterator_traits<_Iterator>::value_type,
    1.54 +                  typename iterator_traits<_Iterator>::difference_type,
    1.55 +                  typename iterator_traits<_Iterator>::pointer,
    1.56 +                  typename iterator_traits<_Iterator>::reference>
    1.57 +{
    1.58 +protected:
    1.59 +  _Iterator current;
    1.60 +  typedef reverse_iterator<_Iterator> _Self;
    1.61 +public:
    1.62 +  typedef typename iterator_traits<_Iterator>::iterator_category  iterator_category;
    1.63 +  typedef typename iterator_traits<_Iterator>::value_type value_type;
    1.64 +  typedef typename iterator_traits<_Iterator>::difference_type difference_type;
    1.65 +  typedef typename iterator_traits<_Iterator>::pointer pointer;
    1.66 +  typedef typename iterator_traits<_Iterator>::reference reference;
    1.67 +  typedef _Iterator iterator_type;
    1.68 +public:
    1.69 +  reverse_iterator() {}
    1.70 +  explicit reverse_iterator(iterator_type __x) : current(__x) {}
    1.71 +  reverse_iterator(const _Self& __x) : current(__x.current) {}
    1.72 +  _Self& operator = (const _Self& __x) { current = __x.base(); return *this; } 
    1.73 +#ifdef _STLP_MEMBER_TEMPLATES
    1.74 +  template <class _Iter>
    1.75 +  reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {}
    1.76 +  template <class _Iter>
    1.77 +  _Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; } 
    1.78 +#endif /* _STLP_MEMBER_TEMPLATES */
    1.79 +    
    1.80 +  iterator_type base() const { return current; }
    1.81 +  reference operator*() const {
    1.82 +    _Iterator __tmp = current;
    1.83 +    return *--__tmp;
    1.84 +  }
    1.85 +  _STLP_DEFINE_ARROW_OPERATOR
    1.86 +  _Self& operator++() {
    1.87 +    --current;
    1.88 +    return *this;
    1.89 +  }
    1.90 +  _Self operator++(int) {
    1.91 +    _Self __tmp = *this;
    1.92 +    --current;
    1.93 +    return __tmp;
    1.94 +  }
    1.95 +  _Self& operator--() {
    1.96 +    ++current;
    1.97 +    return *this;
    1.98 +  }
    1.99 +  _Self operator--(int) {
   1.100 +    _Self __tmp = *this;
   1.101 +    ++current;
   1.102 +    return __tmp;
   1.103 +  }
   1.104 +
   1.105 +  _Self operator+(difference_type __n) const {
   1.106 +    return _Self(current - __n);
   1.107 +  }
   1.108 +  _Self& operator+=(difference_type __n) {
   1.109 +    current -= __n;
   1.110 +    return *this;
   1.111 +  }
   1.112 +  _Self operator-(difference_type __n) const {
   1.113 +    return _Self(current + __n);
   1.114 +  }
   1.115 +  _Self& operator-=(difference_type __n) {
   1.116 +    current += __n;
   1.117 +    return *this;
   1.118 +  }
   1.119 +  reference operator[](difference_type __n) const { return *(*this + __n); }  
   1.120 +}; 
   1.121 + 
   1.122 +template <class _Iterator>
   1.123 +inline bool  _STLP_CALL operator==(const reverse_iterator<_Iterator>& __x, 
   1.124 +                       const reverse_iterator<_Iterator>& __y) {
   1.125 +  return __x.base() == __y.base();
   1.126 +}
   1.127 +
   1.128 +template <class _Iterator>
   1.129 +inline bool _STLP_CALL operator<(const reverse_iterator<_Iterator>& __x, 
   1.130 +                      const reverse_iterator<_Iterator>& __y) {
   1.131 +  return __y.base() < __x.base();
   1.132 +}
   1.133 +
   1.134 +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   1.135 +
   1.136 +template <class _Iterator>
   1.137 +inline bool _STLP_CALL operator!=(const reverse_iterator<_Iterator>& __x, 
   1.138 +                       const reverse_iterator<_Iterator>& __y) {
   1.139 +  return !(__x == __y);
   1.140 +}
   1.141 +
   1.142 +template <class _Iterator>
   1.143 +inline bool _STLP_CALL operator>(const reverse_iterator<_Iterator>& __x, 
   1.144 +                      const reverse_iterator<_Iterator>& __y) {
   1.145 +  return __y < __x;
   1.146 +}
   1.147 +
   1.148 +template <class _Iterator>
   1.149 +inline bool _STLP_CALL operator<=(const reverse_iterator<_Iterator>& __x, 
   1.150 +                       const reverse_iterator<_Iterator>& __y) {
   1.151 +  return !(__y < __x);
   1.152 +}
   1.153 +
   1.154 +template <class _Iterator>
   1.155 +inline bool _STLP_CALL operator>=(const reverse_iterator<_Iterator>& __x, 
   1.156 +                      const reverse_iterator<_Iterator>& __y) {
   1.157 +  return !(__x < __y);
   1.158 +}
   1.159 +
   1.160 +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   1.161 +
   1.162 +template <class _Iterator>
   1.163 +# ifdef __SUNPRO_CC
   1.164 +inline ptrdiff_t _STLP_CALL
   1.165 +# else
   1.166 +inline typename reverse_iterator<_Iterator>::difference_type _STLP_CALL
   1.167 +# endif
   1.168 +operator-(const reverse_iterator<_Iterator>& __x, 
   1.169 +          const reverse_iterator<_Iterator>& __y) {
   1.170 +  return __y.base() - __x.base();
   1.171 +}
   1.172 +
   1.173 +template <class _Iterator, class _DifferenceType>
   1.174 +inline reverse_iterator<_Iterator>  _STLP_CALL
   1.175 +operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x) {
   1.176 +  return x.operator+(n);
   1.177 +}
   1.178 +
   1.179 +# endif
   1.180 +
   1.181 +template <class _Container>
   1.182 +class back_insert_iterator 
   1.183 +  : public iterator<output_iterator_tag,void,void,void,void>
   1.184 +{
   1.185 +protected:
   1.186 +  _Container* container;
   1.187 +public:
   1.188 +  typedef _Container          container_type;
   1.189 +  typedef output_iterator_tag iterator_category;
   1.190 +
   1.191 +  explicit back_insert_iterator(_Container& __x) : container(&__x) {}
   1.192 +  back_insert_iterator<_Container>&
   1.193 +  operator=(const typename _Container::value_type& __val) { 
   1.194 +    container->push_back(__val);
   1.195 +    return *this;
   1.196 +  }
   1.197 +  back_insert_iterator<_Container>& operator*() { return *this; }
   1.198 +  back_insert_iterator<_Container>& operator++() { return *this; }
   1.199 +  back_insert_iterator<_Container>  operator++(int) { return *this; }
   1.200 +};
   1.201 +
   1.202 +template <class _Container>
   1.203 +inline back_insert_iterator<_Container>  _STLP_CALL back_inserter(_Container& __x) {
   1.204 +  return back_insert_iterator<_Container>(__x);
   1.205 +}
   1.206 +
   1.207 +template <class _Container>
   1.208 +class front_insert_iterator 
   1.209 +  : public iterator<output_iterator_tag,void,void,void,void>
   1.210 +{
   1.211 +protected:
   1.212 +  _Container* container;
   1.213 +public:
   1.214 +  typedef _Container          container_type;
   1.215 +  typedef output_iterator_tag iterator_category;
   1.216 +  explicit front_insert_iterator(_Container& __x) : container(&__x) {}
   1.217 +  front_insert_iterator<_Container>&
   1.218 +  operator=(const typename _Container::value_type& __val) { 
   1.219 +    container->push_front(__val);
   1.220 +    return *this;
   1.221 +  }
   1.222 +  front_insert_iterator<_Container>& operator*() { return *this; }
   1.223 +  front_insert_iterator<_Container>& operator++() { return *this; }
   1.224 +  front_insert_iterator<_Container>& operator++(int) { return *this; }
   1.225 +};
   1.226 +
   1.227 +template <class _Container>
   1.228 +inline front_insert_iterator<_Container>  _STLP_CALL front_inserter(_Container& __x) {
   1.229 +  return front_insert_iterator<_Container>(__x);
   1.230 +}
   1.231 +
   1.232 +template <class _Container>
   1.233 +class insert_iterator 
   1.234 +  : public iterator<output_iterator_tag,void,void,void,void>
   1.235 +{
   1.236 +protected:
   1.237 +  _Container* container;
   1.238 +  typename _Container::iterator iter;
   1.239 +public:
   1.240 +  typedef _Container          container_type;
   1.241 +  typedef output_iterator_tag iterator_category;
   1.242 +  insert_iterator(_Container& __x, typename _Container::iterator __i) 
   1.243 +    : container(&__x), iter(__i) {}
   1.244 +  insert_iterator<_Container>&
   1.245 +  operator=(const typename _Container::value_type& __val) { 
   1.246 +    iter = container->insert(iter, __val);
   1.247 +    ++iter;
   1.248 +    return *this;
   1.249 +  }
   1.250 +  insert_iterator<_Container>& operator*() { return *this; }
   1.251 +  insert_iterator<_Container>& operator++() { return *this; }
   1.252 +  insert_iterator<_Container>& operator++(int) { return *this; }
   1.253 +};
   1.254 +
   1.255 +template <class _Container, class _Iterator>
   1.256 +inline insert_iterator<_Container>  _STLP_CALL
   1.257 +inserter(_Container& __x, _Iterator __i)
   1.258 +{
   1.259 +  typedef typename _Container::iterator __iter;
   1.260 +  return insert_iterator<_Container>(__x, __iter(__i));
   1.261 +}
   1.262 +
   1.263 +_STLP_END_NAMESPACE
   1.264 +
   1.265 +#if ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
   1.266 +# include <stl/_iterator_old.h>
   1.267 +#endif /* __NO_PARTIAL_SPEC || ANACHRONISMS */
   1.268 +
   1.269 +#endif /* _STLP_INTERNAL_ITERATOR_H */
   1.270 +
   1.271 +// Local Variables:
   1.272 +// mode:C++
   1.273 +// End: