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