epoc32/include/tools/stlport/stl/debug/_tree.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/_tree.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,316 @@
     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_TREE_H
    1.34 +#define _STLP_INTERNAL_DBG_TREE_H
    1.35 +
    1.36 +#ifndef _STLP_DBG_ITERATOR_H
    1.37 +#  include <stl/debug/_iterator.h>
    1.38 +#endif
    1.39 +
    1.40 +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
    1.41 +#  include <stl/_function_base.h>
    1.42 +#endif
    1.43 +
    1.44 +#ifndef _STLP_INTERNAL_ALLOC_H
    1.45 +#  include <stl/_alloc.h>
    1.46 +#endif
    1.47 +
    1.48 +_STLP_BEGIN_NAMESPACE
    1.49 +
    1.50 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.51 +
    1.52 +template <class _Key, class _Compare>
    1.53 +class _DbgCompare {
    1.54 +public:
    1.55 +  _DbgCompare() {}
    1.56 +  _DbgCompare(const _Compare& __cmp) : _M_non_dbg_cmp(__cmp) {}
    1.57 +  _DbgCompare(const _DbgCompare& __cmp) : _M_non_dbg_cmp(__cmp._M_non_dbg_cmp) {}
    1.58 +
    1.59 +#if !defined (_STLP_USE_CONTAINERS_EXTENSION)
    1.60 +  bool operator () (const _Key& __lhs, const _Key& __rhs) const {
    1.61 +#else
    1.62 +  template <class _Kp1, class _Kp2>
    1.63 +  bool operator () (const _Kp1& __lhs, const _Kp2& __rhs) const {
    1.64 +#endif
    1.65 +    if (_M_non_dbg_cmp(__lhs, __rhs)) {
    1.66 +      _STLP_VERBOSE_ASSERT(!_M_non_dbg_cmp(__rhs, __lhs), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
    1.67 +      return true;
    1.68 +    }
    1.69 +    return false;
    1.70 +  }
    1.71 +
    1.72 +  _Compare non_dbg_key_comp() const { return _M_non_dbg_cmp; }
    1.73 +private:
    1.74 +  _Compare _M_non_dbg_cmp;
    1.75 +};
    1.76 +
    1.77 +#define _STLP_NON_DBG_TREE _STLP_PRIV _STLP_NON_DBG_NAME(Rb_tree) <_Key, _STLP_PRIV _DbgCompare<_Key, _Compare>, _Value, _KeyOfValue, _Traits, _Alloc>
    1.78 +
    1.79 +#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
    1.80 +_STLP_MOVE_TO_STD_NAMESPACE
    1.81 +template <class _Key, class _Compare,
    1.82 +          class _Value, class _KeyOfValue, class _Traits, class _Alloc >
    1.83 +inline _Value*
    1.84 +value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&)
    1.85 +{ return (_Value*)0; }
    1.86 +template <class _Key, class _Compare,
    1.87 +          class _Value, class _KeyOfValue, class _Traits, class _Alloc >
    1.88 +inline bidirectional_iterator_tag
    1.89 +iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&)
    1.90 +{ return bidirectional_iterator_tag(); }
    1.91 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.92 +#endif
    1.93 +
    1.94 +template <class _Key, class _Compare,
    1.95 +          class _Value, class _KeyOfValue, class _Traits,
    1.96 +          _STLP_DBG_ALLOCATOR_SELECT(_Value) >
    1.97 +class _Rb_tree {
    1.98 +  typedef _STLP_NON_DBG_TREE _Base;
    1.99 +  typedef _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> _Self;
   1.100 +  _Base _M_non_dbg_impl;
   1.101 +  _STLP_PRIV __owned_list _M_iter_list;
   1.102 +
   1.103 +public:
   1.104 +  __IMPORT_CONTAINER_TYPEDEFS(_Base)
   1.105 +  typedef typename _Base::key_type key_type;
   1.106 +
   1.107 +  typedef typename _Traits::_NonConstTraits _NonConstIteTraits;
   1.108 +  typedef typename _Traits::_ConstTraits    _ConstIteTraits;
   1.109 +  typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_NonConstIteTraits> > iterator;
   1.110 +  typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_ConstIteTraits> >    const_iterator;
   1.111 +
   1.112 +  _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
   1.113 +
   1.114 +private:
   1.115 +  _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
   1.116 +  void _Invalidate_iterator(const iterator& __it)
   1.117 +  { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); }
   1.118 +  void _Invalidate_iterators(const iterator& __first, const iterator& __last)
   1.119 +  { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
   1.120 +
   1.121 +  typedef typename _Base::iterator _Base_iterator;
   1.122 +  typedef typename _Base::const_iterator _Base_const_iterator;
   1.123 +
   1.124 +public:
   1.125 +  _Rb_tree()
   1.126 +    : _M_non_dbg_impl(), _M_iter_list(&_M_non_dbg_impl) {}
   1.127 +  _Rb_tree(const _Compare& __comp)
   1.128 +    : _M_non_dbg_impl(__comp), _M_iter_list(&_M_non_dbg_impl) {}
   1.129 +  _Rb_tree(const _Compare& __comp, const allocator_type& __a)
   1.130 +    : _M_non_dbg_impl(__comp, __a), _M_iter_list(&_M_non_dbg_impl) {}
   1.131 +  _Rb_tree(const _Self& __x)
   1.132 +    : _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
   1.133 +
   1.134 +  _Rb_tree(__move_source<_Self> src):
   1.135 +    _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
   1.136 +    _M_iter_list(&_M_non_dbg_impl) {
   1.137 +#if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
   1.138 +    src.get()._M_iter_list._Invalidate_all();
   1.139 +#else
   1.140 +    src.get()._M_iter_list._Set_owner(_M_iter_list);
   1.141 +#endif
   1.142 +  }
   1.143 +
   1.144 +  ~_Rb_tree() {}
   1.145 +
   1.146 +  _Self& operator=(const _Self& __x) {
   1.147 +    if (this != &__x) {
   1.148 +      //Should not invalidate end iterator:
   1.149 +      _Invalidate_iterators(begin(), end());
   1.150 +      _M_non_dbg_impl = __x._M_non_dbg_impl;
   1.151 +    }
   1.152 +    return *this;
   1.153 +  }
   1.154 +
   1.155 +  allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
   1.156 +  _Compare key_comp() const { return _M_non_dbg_impl.key_comp().non_dbg_key_comp(); }
   1.157 +
   1.158 +  iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
   1.159 +  const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
   1.160 +  iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
   1.161 +  const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
   1.162 +
   1.163 +  reverse_iterator rbegin() { return reverse_iterator(end()); }
   1.164 +  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
   1.165 +  reverse_iterator rend() { return reverse_iterator(begin()); }
   1.166 +  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
   1.167 +
   1.168 +  bool empty() const { return _M_non_dbg_impl.empty(); }
   1.169 +  size_type size() const { return _M_non_dbg_impl.size(); }
   1.170 +  size_type max_size() const { return _M_non_dbg_impl.max_size(); }
   1.171 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.172 +  size_type count(const _KT& __x) const { return _M_non_dbg_impl.count(__x); }
   1.173 +
   1.174 +  void swap(_Self& __t) {
   1.175 +    _M_non_dbg_impl.swap(__t._M_non_dbg_impl);
   1.176 +    _M_iter_list._Swap_owners(__t._M_iter_list);
   1.177 +  }
   1.178 +
   1.179 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.180 +  iterator find(const _KT& __k)
   1.181 +  { return iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); }
   1.182 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.183 +  const_iterator find(const _KT& __k) const
   1.184 +  { return const_iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); }
   1.185 +
   1.186 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.187 +  iterator lower_bound(const _KT& __x)
   1.188 +  { return iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); }
   1.189 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.190 +  const_iterator lower_bound(const _KT& __x) const
   1.191 +  { return const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); }
   1.192 +
   1.193 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.194 +  iterator upper_bound(const _KT& __x)
   1.195 +  { return iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); }
   1.196 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.197 +  const_iterator upper_bound(const _KT& __x) const
   1.198 +  { return const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); }
   1.199 +
   1.200 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.201 +  pair<iterator,iterator> equal_range(const _KT& __x) {
   1.202 +    return pair<iterator, iterator>(iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)),
   1.203 +                                    iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)));
   1.204 +  }
   1.205 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.206 +  pair<const_iterator, const_iterator> equal_range(const _KT& __x) const {
   1.207 +    return pair<const_iterator,const_iterator>(const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)),
   1.208 +                                               const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)));
   1.209 +  }
   1.210 +
   1.211 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.212 +  pair<iterator,iterator> equal_range_unique(const _KT& __x) {
   1.213 +    _STLP_STD::pair<_Base_iterator, _Base_iterator> __p;
   1.214 +    __p = _M_non_dbg_impl.equal_range_unique(__x);
   1.215 +    return pair<iterator, iterator>(iterator(&_M_iter_list, __p.first), iterator(&_M_iter_list, __p.second));
   1.216 +  }
   1.217 +  _STLP_TEMPLATE_FOR_CONT_EXT
   1.218 +  pair<const_iterator, const_iterator> equal_range_unique(const _KT& __x) const {
   1.219 +    _STLP_STD::pair<_Base_const_iterator, _Base_const_iterator> __p;
   1.220 +    __p = _M_non_dbg_impl.equal_range_unique(__x);
   1.221 +    return pair<const_iterator, const_iterator>(const_iterator(&_M_iter_list, __p.first),
   1.222 +                                                const_iterator(&_M_iter_list, __p.second));
   1.223 +  }
   1.224 +
   1.225 +  pair<iterator,bool> insert_unique(const value_type& __x) {
   1.226 +    _STLP_STD::pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique(__x);
   1.227 +    return pair<iterator, bool>(iterator(&_M_iter_list, __res.first), __res.second);
   1.228 +  }
   1.229 +  iterator insert_equal(const value_type& __x)
   1.230 +  { return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__x)); }
   1.231 +
   1.232 +  iterator insert_unique(iterator __pos, const value_type& __x) {
   1.233 +    _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
   1.234 +    return iterator(&_M_iter_list, _M_non_dbg_impl.insert_unique(__pos._M_iterator, __x));
   1.235 +  }
   1.236 +  iterator insert_equal(iterator __pos, const value_type& __x) {
   1.237 +    _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos))
   1.238 +    return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__pos._M_iterator, __x));
   1.239 +  }
   1.240 +
   1.241 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.242 +  template<class _InputIterator>
   1.243 +  void insert_equal(_InputIterator __first, _InputIterator __last) {
   1.244 +    _STLP_DEBUG_CHECK(__check_range(__first,__last))
   1.245 +    _M_non_dbg_impl.insert_equal(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   1.246 +  }
   1.247 +  template<class _InputIterator>
   1.248 +  void insert_unique(_InputIterator __first, _InputIterator __last) {
   1.249 +    _STLP_DEBUG_CHECK(__check_range(__first,__last))
   1.250 +    _M_non_dbg_impl.insert_unique(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
   1.251 +  }
   1.252 +#else
   1.253 +  void insert_unique(const_iterator __first, const_iterator __last) {
   1.254 +    _STLP_DEBUG_CHECK(__check_range(__first,__last))
   1.255 +    _M_non_dbg_impl.insert_unique(__first._M_iterator, __last._M_iterator);
   1.256 +  }
   1.257 +  void insert_unique(const value_type* __first, const value_type* __last) {
   1.258 +    _STLP_DEBUG_CHECK(__check_ptr_range(__first,__last))
   1.259 +    _M_non_dbg_impl.insert_unique(__first, __last);
   1.260 +  }
   1.261 +  void insert_equal(const_iterator __first, const_iterator __last) {
   1.262 +    _STLP_DEBUG_CHECK(__check_range(__first,__last))
   1.263 +    _M_non_dbg_impl.insert_equal(__first._M_iterator, __last._M_iterator);
   1.264 +  }
   1.265 +  void insert_equal(const value_type* __first, const value_type* __last) {
   1.266 +    _STLP_DEBUG_CHECK(__check_ptr_range(__first,__last))
   1.267 +    _M_non_dbg_impl.insert_equal(__first, __last);
   1.268 +  }
   1.269 +#endif
   1.270 +
   1.271 +  void erase(iterator __pos) {
   1.272 +    _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
   1.273 +    _STLP_DEBUG_CHECK(_Dereferenceable(__pos))
   1.274 +    _Invalidate_iterator(__pos);
   1.275 +    _M_non_dbg_impl.erase(__pos._M_iterator);
   1.276 +  }
   1.277 +  size_type erase(const key_type& __x) {
   1.278 +    pair<_Base_iterator,_Base_iterator> __p = _M_non_dbg_impl.equal_range(__x);
   1.279 +    size_type __n = distance(__p.first, __p.second);
   1.280 +    _Invalidate_iterators(iterator(&_M_iter_list, __p.first), iterator(&_M_iter_list, __p.second));
   1.281 +    _M_non_dbg_impl.erase(__p.first, __p.second);
   1.282 +    return __n;
   1.283 +  }
   1.284 +  size_type erase_unique(const key_type& __x) {
   1.285 +    _Base_iterator __i = _M_non_dbg_impl.find(__x);
   1.286 +    if (__i != _M_non_dbg_impl.end()) {
   1.287 +      _Invalidate_iterator(iterator(&_M_iter_list, __i));
   1.288 +      _M_non_dbg_impl.erase(__i);
   1.289 +      return 1;
   1.290 +    }
   1.291 +    return 0;
   1.292 +  }
   1.293 +
   1.294 +  void erase(iterator __first, iterator __last) {
   1.295 +    _STLP_DEBUG_CHECK(__check_range(__first, __last, begin(), end()))
   1.296 +    _Invalidate_iterators(__first, __last);
   1.297 +    _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator);
   1.298 +  }
   1.299 +  void erase(const key_type* __first, const key_type* __last) {
   1.300 +    while (__first != __last) erase(*__first++);
   1.301 +  }
   1.302 +
   1.303 +  void clear() {
   1.304 +    //should not invalidate end:
   1.305 +    _Invalidate_iterators(begin(), end());
   1.306 +    _M_non_dbg_impl.clear();
   1.307 +  }
   1.308 +};
   1.309 +
   1.310 +_STLP_MOVE_TO_STD_NAMESPACE
   1.311 +_STLP_END_NAMESPACE
   1.312 +
   1.313 +#undef _STLP_NON_DBG_TREE
   1.314 +
   1.315 +#endif /* _STLP_INTERNAL_DBG_TREE_H */
   1.316 +
   1.317 +// Local Variables:
   1.318 +// mode:C++
   1.319 +// End: