epoc32/include/tools/stlport/stl/debug/_deque.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/debug/_deque.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,401 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 1994
     1.7 + * Hewlett-Packard Company
     1.8 + *
     1.9 + * Copyright (c) 1996,1997
    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_DBG_DEQUE_H
    1.34 +#define _STLP_INTERNAL_DBG_DEQUE_H
    1.35 +
    1.36 +#ifndef _STLP_DBG_ITERATOR_H
    1.37 +#  include <stl/debug/_iterator.h>
    1.38 +#endif
    1.39 +
    1.40 +#define _STLP_NON_DBG_DEQUE _STLP_PRIV _STLP_NON_DBG_NAME(deque) <_Tp,_Alloc>
    1.41 +
    1.42 +_STLP_BEGIN_NAMESPACE
    1.43 +
    1.44 +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
    1.45 +template <class _Tp, class _Alloc>
    1.46 +inline _Tp* value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
    1.47 +{ return (_Tp*)0; }
    1.48 +template <class _Tp, class _Alloc>
    1.49 +inline random_access_iterator_tag iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
    1.50 +{ return random_access_iterator_tag(); }
    1.51 +#endif
    1.52 +
    1.53 +template <class _Tp, _STLP_DBG_ALLOCATOR_SELECT(_Tp) >
    1.54 +class deque :
    1.55 +#if !defined (__DMC__)
    1.56 +             private
    1.57 +#endif
    1.58 +                     _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE >
    1.59 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
    1.60 +            , public __stlport_class<deque<_Tp, _Alloc> >
    1.61 +#endif
    1.62 +{
    1.63 +  typedef deque<_Tp,_Alloc> _Self;
    1.64 +  typedef _STLP_NON_DBG_DEQUE _Base;
    1.65 +  typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > _ConstructCheck;
    1.66 +
    1.67 +public:
    1.68 +  // Basic types
    1.69 +  __IMPORT_CONTAINER_TYPEDEFS(_Base)
    1.70 +
    1.71 +  // Iterators
    1.72 +  typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
    1.73 +  typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > >    const_iterator;
    1.74 +
    1.75 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
    1.76 +
    1.77 +protected:
    1.78 +  _Base _M_non_dbg_impl;
    1.79 +  _STLP_PRIV __owned_list _M_iter_list;
    1.80 +
    1.81 +  void _Invalidate_iterator(const iterator& __it)
    1.82 +  { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); }
    1.83 +  void _Invalidate_all()
    1.84 +  { _M_iter_list._Invalidate_all(); }
    1.85 +
    1.86 +public:
    1.87 +  // Basic accessors
    1.88 +  allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
    1.89 +
    1.90 +  iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
    1.91 +  iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
    1.92 +  const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
    1.93 +  const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
    1.94 +
    1.95 +  reverse_iterator rbegin() { return reverse_iterator(end()); }
    1.96 +  reverse_iterator rend() { return reverse_iterator(begin()); }
    1.97 +  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
    1.98 +  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
    1.99 +
   1.100 +  reference operator[](size_type __n) {
   1.101 +    _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
   1.102 +    return _M_non_dbg_impl[__n];
   1.103 +  }
   1.104 +  const_reference operator[](size_type __n) const {
   1.105 +    _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
   1.106 +    return _M_non_dbg_impl[__n];
   1.107 +  }
   1.108 +
   1.109 +  reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
   1.110 +  const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
   1.111 +
   1.112 +  reference front() {
   1.113 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.114 +    return *begin();
   1.115 +  }
   1.116 +  const_reference front() const {
   1.117 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.118 +    return *begin();
   1.119 +  }
   1.120 +  reference back() {
   1.121 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.122 +    return *(--end());
   1.123 +  }
   1.124 +  const_reference back() const {
   1.125 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.126 +    return *(--end());
   1.127 +  }
   1.128 +
   1.129 +  // Constructor, destructor.
   1.130 +  explicit deque(const allocator_type& __a = allocator_type()) :
   1.131 +    _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
   1.132 +  deque(const _Self& __x) :
   1.133 +    _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl),
   1.134 +    _M_iter_list(&_M_non_dbg_impl) {}
   1.135 +
   1.136 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
   1.137 +  explicit deque(size_type __n, const value_type& __x = _Tp(),
   1.138 +#else
   1.139 +  deque(size_type __n, param_type __x,
   1.140 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.141 +            const allocator_type& __a = allocator_type()) :
   1.142 +    _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
   1.143 +#if defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.144 +  explicit deque(size_type __n) :
   1.145 +    _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
   1.146 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.147 +
   1.148 +  deque(__move_source<_Self> src)
   1.149 +    : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
   1.150 +      _M_iter_list(&_M_non_dbg_impl) {
   1.151 +#if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
   1.152 +    src.get()._M_iter_list._Invalidate_all();
   1.153 +#else
   1.154 +    src.get()._M_iter_list._Set_owner(_M_iter_list);
   1.155 +#endif
   1.156 +  }
   1.157 +
   1.158 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.159 +  template <class _InputIterator>
   1.160 +  deque(_InputIterator __first, _InputIterator __last,
   1.161 +        const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
   1.162 +    : _ConstructCheck(__first, __last),
   1.163 +      _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
   1.164 +      _M_iter_list(&_M_non_dbg_impl) {
   1.165 +    }
   1.166 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.167 +  template <class _InputIterator>
   1.168 +  deque(_InputIterator __first, _InputIterator __last)
   1.169 +    : _ConstructCheck(__first, __last),
   1.170 +      _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
   1.171 +      _M_iter_list(&_M_non_dbg_impl) {
   1.172 +    }
   1.173 +#  endif
   1.174 +#else
   1.175 +  deque(const value_type* __first, const value_type* __last,
   1.176 +        const allocator_type& __a = allocator_type())
   1.177 +    : _ConstructCheck(__first, __last),
   1.178 +      _M_non_dbg_impl(__first, __last, __a),
   1.179 +      _M_iter_list(&_M_non_dbg_impl) {
   1.180 +    }
   1.181 +
   1.182 +  deque(const_iterator __first, const_iterator __last,
   1.183 +        const allocator_type& __a = allocator_type())
   1.184 +    : _ConstructCheck(__first, __last),
   1.185 +      _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
   1.186 +      _M_iter_list(&_M_non_dbg_impl) {
   1.187 +    }
   1.188 +#endif
   1.189 +
   1.190 +  _Self& operator=(const _Self& __x) {
   1.191 +    if (this != &__x) {
   1.192 +      _Invalidate_all();
   1.193 +      _M_non_dbg_impl = __x._M_non_dbg_impl;
   1.194 +    }
   1.195 +    return *this;
   1.196 +  }
   1.197 +
   1.198 +  bool empty() const { return _M_non_dbg_impl.empty(); }
   1.199 +  size_type size() const { return _M_non_dbg_impl.size(); }
   1.200 +  size_type max_size() const { return _M_non_dbg_impl.max_size(); }
   1.201 +
   1.202 +  void swap(_Self& __x) {
   1.203 +    _M_iter_list._Swap_owners(__x._M_iter_list);
   1.204 +    _M_non_dbg_impl.swap(__x._M_non_dbg_impl);
   1.205 +  }
   1.206 +
   1.207 +public:
   1.208 +  void assign(size_type __n, const _Tp& __val) {
   1.209 +    _Invalidate_all();
   1.210 +    _M_non_dbg_impl.assign(__n, __val);
   1.211 +  }
   1.212 +
   1.213 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.214 +  template <class _InputIterator>
   1.215 +  void assign(_InputIterator __first, _InputIterator __last) {
   1.216 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.217 +    _Invalidate_all();
   1.218 +    _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   1.219 +  }
   1.220 +#else
   1.221 +  void assign(const_iterator __first, const_iterator __last) {
   1.222 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.223 +    _Invalidate_all();
   1.224 +    _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
   1.225 +  }
   1.226 +  void assign(const value_type *__first, const value_type *__last) {
   1.227 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
   1.228 +    _Invalidate_all();
   1.229 +    _M_non_dbg_impl.assign(__first, __last);
   1.230 +  }
   1.231 +#endif
   1.232 +
   1.233 +public:                         // push_* and pop_*
   1.234 +
   1.235 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.236 +  void push_back(const value_type& __t = _Tp()) {
   1.237 +#else
   1.238 +  void push_back(const value_type& __t) {
   1.239 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.240 +    _Invalidate_all();
   1.241 +    _M_non_dbg_impl.push_back(__t);
   1.242 +  }
   1.243 +
   1.244 +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.245 +  void push_back() {
   1.246 +    _Invalidate_all();
   1.247 +    _M_non_dbg_impl.push_back();
   1.248 +  }
   1.249 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.250 +
   1.251 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.252 +  void push_front(const value_type& __t = _Tp()) {
   1.253 +#else
   1.254 +  void push_front(const value_type& __t) {
   1.255 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.256 +    _Invalidate_all();
   1.257 +    _M_non_dbg_impl.push_front(__t);
   1.258 +  }
   1.259 +
   1.260 +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.261 +  void push_front() {
   1.262 +    _Invalidate_all();
   1.263 +    _M_non_dbg_impl.push_front();
   1.264 +  }
   1.265 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.266 +
   1.267 +  void pop_back() {
   1.268 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.269 +    _Invalidate_iterator(end());
   1.270 +    _M_non_dbg_impl.pop_back();
   1.271 +  }
   1.272 +
   1.273 +  void pop_front() {
   1.274 +    _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
   1.275 +    _Invalidate_iterator(begin());
   1.276 +    _M_non_dbg_impl.pop_front();
   1.277 +  }
   1.278 +
   1.279 +public:                         // Insert
   1.280 +
   1.281 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.282 +  iterator insert(iterator __pos, const value_type& __x = _Tp()) {
   1.283 +#else
   1.284 +  iterator insert(iterator __pos, const value_type& __x) {
   1.285 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.286 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.287 +    _Invalidate_all();
   1.288 +    return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
   1.289 +  }
   1.290 +
   1.291 +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.292 +  iterator insert(iterator __pos) {
   1.293 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.294 +    _Invalidate_all();
   1.295 +    return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator));
   1.296 +  }
   1.297 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.298 +
   1.299 +  void insert(iterator __pos, size_type __n, const value_type& __x) {
   1.300 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.301 +    if (__n != 0) _Invalidate_all();
   1.302 +    _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
   1.303 +  }
   1.304 +
   1.305 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.306 +  template <class _InputIterator>
   1.307 +  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
   1.308 +    typedef typename _AreSameUnCVTypes<_InputIterator, iterator>::_Ret _IsNonConstIterator;
   1.309 +    typedef typename _AreSameUnCVTypes<_InputIterator, const_iterator>::_Ret _IsConstIterator;
   1.310 +    typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _DoCheck;
   1.311 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.312 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.313 +    //Sequence requirements 23.1.1 Table 67:
   1.314 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first, _DoCheck()));
   1.315 +    _M_non_dbg_impl.insert(__pos._M_iterator,
   1.316 +                           _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   1.317 +    //dums: because of self insertion iterators must be invalidated after insertion.
   1.318 +    if (__first != __last) _Invalidate_all();
   1.319 +  }
   1.320 +#else
   1.321 +  void insert(iterator __pos,
   1.322 +              const value_type* __first, const value_type* __last) {
   1.323 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.324 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
   1.325 +    _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
   1.326 +    //dums: because of self insertion iterators must be invalidated after insertion.
   1.327 +    if (__first != __last) _Invalidate_all();
   1.328 +  }
   1.329 +  void insert(iterator __pos,
   1.330 +              const_iterator __first, const_iterator __last) {
   1.331 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.332 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
   1.333 +    //Sequence requirements 23.1.1 Table 67:
   1.334 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first, __true_type()));
   1.335 +    _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
   1.336 +    //dums: because of self insertion iterators must be invalidated after insertion.
   1.337 +    if (__first != __last) _Invalidate_all();
   1.338 +  }
   1.339 +#endif
   1.340 +
   1.341 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.342 +  void resize(size_type __new_size, const value_type& __x = _Tp()) {
   1.343 +#else
   1.344 +  void resize(size_type __new_size, const value_type& __x) {
   1.345 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.346 +    if (__new_size != size()) {
   1.347 +      if ((__new_size > size()) || (__new_size < size() - 1))
   1.348 +        _Invalidate_all();
   1.349 +      else
   1.350 +        _Invalidate_iterator(end());
   1.351 +    }
   1.352 +    _M_non_dbg_impl.resize(__new_size, __x);
   1.353 +  }
   1.354 +
   1.355 +#if defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.356 +  void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   1.357 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.358 +
   1.359 +  // Erase
   1.360 +  iterator erase(iterator __pos) {
   1.361 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
   1.362 +    _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
   1.363 +    if (__pos == begin())
   1.364 +      _Invalidate_iterator(__pos);
   1.365 +    else {
   1.366 +      iterator __tmp = --(end());
   1.367 +      if (__pos == __tmp)
   1.368 +        _Invalidate_iterator(__pos);
   1.369 +      else
   1.370 +        _Invalidate_all();
   1.371 +    }
   1.372 +    return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
   1.373 +  }
   1.374 +
   1.375 +  iterator erase(iterator __first, iterator __last) {
   1.376 +    _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
   1.377 +    if (!empty()) {
   1.378 +      if (__last == (++(begin())))
   1.379 +        _Invalidate_iterator(__last);
   1.380 +      else {
   1.381 +        if (__first == (--(end())))
   1.382 +          _Invalidate_iterator(__first);
   1.383 +        else
   1.384 +          _Invalidate_all();
   1.385 +      }
   1.386 +    }
   1.387 +    return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
   1.388 +  }
   1.389 +
   1.390 +  void clear() {
   1.391 +    _Invalidate_all();
   1.392 +    _M_non_dbg_impl.clear();
   1.393 +  }
   1.394 +};
   1.395 +
   1.396 +_STLP_END_NAMESPACE
   1.397 +
   1.398 +#undef _STLP_NON_DBG_DEQUE
   1.399 +
   1.400 +#endif /* _STLP_INTERNAL_DEQUE_H */
   1.401 +
   1.402 +// Local Variables:
   1.403 +// mode:C++
   1.404 +// End: