epoc32/include/stdapis/stlport/stl/debug/_hashtable.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/debug/_hashtable.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/debug/_hashtable.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,261 @@
     1.4 -_hashtable.h
     1.5 +/*
     1.6 + *
     1.7 + * Copyright (c) 1994
     1.8 + * Hewlett-Packard Company
     1.9 + *
    1.10 + * Copyright (c) 1996,1997
    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_DBG_HASHTABLE_H
    1.35 +#define _STLP_INTERNAL_DBG_HASHTABLE_H
    1.36 +
    1.37 +// Hashtable class, used to implement the hashed associative containers
    1.38 +// hash_set, hash_map, hash_multiset, and hash_multimap.
    1.39 +
    1.40 +# include <stl/debug/_iterator.h>
    1.41 +
    1.42 +#  undef  hashtable
    1.43 +#  undef  _DBG_hashtable
    1.44 +#  define _DBG_hashtable  hashtable
    1.45 +
    1.46 +#  define _STLP_DBG_HT_SUPER \
    1.47 +__WORKAROUND_DBG_RENAME(hashtable) <_Val, _Key, _HF, _ExK, _EqK, _All>
    1.48 +
    1.49 +_STLP_BEGIN_NAMESPACE
    1.50 +
    1.51 +# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
    1.52 +template <class _Val, class _Key, class _HF,
    1.53 +          class _ExK, class _EqK, class _All>
    1.54 +inline _Val*
    1.55 +value_type(const  _DBG_iter_base< _STLP_DBG_HT_SUPER >&) {
    1.56 +  return (_Val*)0;
    1.57 +}
    1.58 +
    1.59 +template <class _Val, class _Key, class _HF,
    1.60 +          class _ExK, class _EqK, class _All>
    1.61 +inline forward_iterator_tag
    1.62 +iterator_category(const  _DBG_iter_base< _STLP_DBG_HT_SUPER >&) {
    1.63 +  return forward_iterator_tag();
    1.64 +}
    1.65 +# endif
    1.66 +
    1.67 +template <class _Val, class _Key, class _HF,
    1.68 +          class _ExK, class _EqK, class _All>
    1.69 +class _DBG_hashtable : public _STLP_DBG_HT_SUPER {
    1.70 +  typedef _DBG_hashtable<_Val, _Key, _HF, _ExK, _EqK, _All> _Self;
    1.71 +  typedef _STLP_DBG_HT_SUPER _Base;
    1.72 +
    1.73 +public:
    1.74 +  typedef _Key key_type;
    1.75 +  typedef _HF hasher;
    1.76 +  typedef _EqK key_equal;
    1.77 +
    1.78 +  __IMPORT_CONTAINER_TYPEDEFS(_Base)
    1.79 +
    1.80 +public:
    1.81 +  typedef _DBG_iter<_Base, _Nonconst_traits<value_type> >  iterator;
    1.82 +  typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
    1.83 +  typedef typename _Base::iterator _Base_iterator;
    1.84 +  typedef typename _Base::const_iterator _Base_const_iterator;
    1.85 +
    1.86 +protected:
    1.87 +  void _Invalidate_all() {_M_iter_list._Invalidate_all();}
    1.88 +
    1.89 +  void _Invalidate_iterator(const const_iterator& __it) { 
    1.90 +    __invalidate_iterator(&_M_iter_list,__it); 
    1.91 +  }
    1.92 +  void _Invalidate_iterators(const const_iterator& __first, const const_iterator& __last) {
    1.93 +    const_iterator __cur = __first;
    1.94 +    while (__cur != __last) __invalidate_iterator(&_M_iter_list, __cur++); 
    1.95 +  }
    1.96 +
    1.97 +  const _Base* _Get_base() const { return (const _Base*)this; }
    1.98 +  _Base* _Get_base() { return (_Base*)this; }
    1.99 +
   1.100 +public:
   1.101 +  _DBG_hashtable(size_type __n,
   1.102 +		 const _HF&  __hf,
   1.103 +		 const _EqK& __eql,
   1.104 +		 const _ExK& __ext,
   1.105 +		 const allocator_type& __a = allocator_type()):
   1.106 +    _STLP_DBG_HT_SUPER(__n, __hf, __eql, __ext, __a),
   1.107 +    _M_iter_list(_Get_base()) {}
   1.108 +  
   1.109 +  _DBG_hashtable(size_type __n,
   1.110 +		 const _HF&    __hf,
   1.111 +		 const _EqK&   __eql,
   1.112 +		 const allocator_type& __a = allocator_type()):
   1.113 +    
   1.114 +    _STLP_DBG_HT_SUPER(__n, __hf, __eql, __a),
   1.115 +    _M_iter_list(_Get_base()) {}
   1.116 +  
   1.117 +  _DBG_hashtable(const _Self& __ht):
   1.118 +    _STLP_DBG_HT_SUPER(__ht),
   1.119 +    _M_iter_list(_Get_base()) {}
   1.120 +  
   1.121 +  _Self& operator= (const _Self& __ht) {
   1.122 +    _Invalidate_all();
   1.123 +    _Base::operator=(__ht);
   1.124 +    return *this;
   1.125 +  }
   1.126 +  
   1.127 +  void swap(_Self& __ht)
   1.128 +  {
   1.129 +   _M_iter_list._Swap_owners(__ht._M_iter_list);
   1.130 +   _Base::swap(__ht);
   1.131 +  }
   1.132 +
   1.133 +  iterator begin() { return iterator(&_M_iter_list, _Base::begin()); }
   1.134 +  iterator end()   { return iterator(&_M_iter_list, _Base::end()); }
   1.135 +
   1.136 +  const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); }
   1.137 +  const_iterator end() const { return const_iterator(&_M_iter_list, _Base::end()); }
   1.138 +
   1.139 +  pair<iterator, bool> insert_unique(const value_type& __obj)
   1.140 +  {
   1.141 +    pair < _Base_iterator, bool> __res =
   1.142 +      _Base::insert_unique(__obj);
   1.143 +    return pair<iterator, bool> ( iterator(&_M_iter_list, __res.first), __res.second);
   1.144 +  }
   1.145 +
   1.146 +  iterator insert_equal(const value_type& __obj) {
   1.147 +    return iterator(&_M_iter_list, _Base::insert_equal(__obj));
   1.148 +  }
   1.149 +  
   1.150 +  pair<iterator, bool> insert_unique_noresize(const value_type& __obj) {
   1.151 +    pair < _Base_iterator, bool> __res =
   1.152 +      _Base::insert_unique_noresize(__obj);
   1.153 +    return pair<iterator, bool> ( iterator(&_M_iter_list, __res.first), __res.second);
   1.154 +  }
   1.155 +  
   1.156 +  iterator insert_equal_noresize(const value_type& __obj) {
   1.157 +    return iterator(&_M_iter_list, _Base::insert_equal_noresize(__obj));
   1.158 +  }
   1.159 +  
   1.160 +#ifdef _STLP_MEMBER_TEMPLATES
   1.161 +  template <class _InputIterator>
   1.162 +  void insert_unique(_InputIterator __f, _InputIterator __l) {
   1.163 +    _Base::insert_unique(__f, __l);
   1.164 +  }
   1.165 +
   1.166 +  template <class _InputIterator>
   1.167 +  void insert_equal(_InputIterator __f, _InputIterator __l){
   1.168 +    _Base::insert_equal(__f, __l);
   1.169 +  }
   1.170 +
   1.171 +#else /* _STLP_MEMBER_TEMPLATES */
   1.172 +
   1.173 +  void insert_unique(const value_type* __f, const value_type* __l) {
   1.174 +    _Base::insert_unique(__f, __l);
   1.175 +  }
   1.176 +  
   1.177 +  void insert_equal(const value_type* __f, const value_type* __l) {
   1.178 +    _Base::insert_equal(__f, __l);
   1.179 +  }
   1.180 +  
   1.181 +  void insert_unique(const_iterator __f, const_iterator __l) {
   1.182 +    _Base::insert_unique(__f._M_iterator, __l._M_iterator);
   1.183 +  }
   1.184 +  
   1.185 +  void insert_equal(const_iterator __f, const_iterator __l) {
   1.186 +    _Base::insert_equal(__f._M_iterator, __l._M_iterator);
   1.187 +  }
   1.188 +#endif /*_STLP_MEMBER_TEMPLATES */
   1.189 +  
   1.190 +  iterator find(const key_type& __key) {
   1.191 +    return iterator(&_M_iter_list, _Base::find(__key));
   1.192 +  } 
   1.193 +
   1.194 +  const_iterator find(const key_type& __key) const {
   1.195 +    return const_iterator(&_M_iter_list, _Base::find(__key));
   1.196 +  } 
   1.197 +
   1.198 +  pair<iterator, iterator> 
   1.199 +  equal_range(const key_type& __key) {
   1.200 +    pair < _Base_iterator, _Base_iterator > __res =
   1.201 +      _Base::equal_range(__key);
   1.202 +    return pair<iterator,iterator> (iterator(&_M_iter_list,__res.first),
   1.203 +				    iterator(&_M_iter_list,__res.second));
   1.204 +  }
   1.205 +
   1.206 +  pair<const_iterator, const_iterator> 
   1.207 +  equal_range(const key_type& __key) const {
   1.208 +    pair <  _Base_const_iterator, _Base_const_iterator > __res =
   1.209 +      _Base::equal_range(__key);
   1.210 +    return pair<const_iterator,const_iterator> (const_iterator(&_M_iter_list,__res.first),
   1.211 +				    const_iterator(&_M_iter_list,__res.second));
   1.212 +  }
   1.213 +
   1.214 +  size_type erase(const key_type& __key) {
   1.215 +    pair<const_iterator, const_iterator> __p = equal_range(__key);
   1.216 +    size_type __n = distance(__p.first, __p.second);
   1.217 +    _Invalidate_iterators(__p.first, __p.second);
   1.218 +    _Base::erase(__p.first._M_iterator, __p.second._M_iterator);
   1.219 +    return __n;
   1.220 +  }
   1.221 +
   1.222 +  void erase(const const_iterator& __it) {
   1.223 +    _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __it))
   1.224 +    _STLP_DEBUG_CHECK(_Dereferenceable(__it))
   1.225 +    _Invalidate_iterator(__it);
   1.226 +    _Base::erase(__it._M_iterator);
   1.227 +  }
   1.228 +  void erase(const_iterator __first, const_iterator __last) {
   1.229 +    _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __first)&&
   1.230 +                      __check_if_owner(&_M_iter_list, __last))
   1.231 +    _Invalidate_iterators(__first, __last);
   1.232 +    _Base::erase(__first._M_iterator, __last._M_iterator);
   1.233 +  }
   1.234 +  void resize(size_type __num_elements_hint) {
   1.235 +    _Base::resize(__num_elements_hint);
   1.236 +  }
   1.237 +  
   1.238 +  void clear() {
   1.239 +    _Invalidate_all();
   1.240 +    _Base::clear();
   1.241 +  }
   1.242 +
   1.243 +private:
   1.244 +  __owned_list _M_iter_list;
   1.245 +
   1.246 +};
   1.247 +
   1.248 +#define _STLP_TEMPLATE_HEADER template <class _Val, class _Key, class _HF, class _ExK, class _EqK, class _All>
   1.249 +#define _STLP_TEMPLATE_CONTAINER _DBG_hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>
   1.250 +#define _STLP_TEMPLATE_CONTAINER_BASE hashtable<_Val,_Key,_HF,_ExK,_EqK,_All>
   1.251 +#include <stl/debug/_relops_hash_cont.h>
   1.252 +#undef _STLP_TEMPLATE_CONTAINER_BASE
   1.253 +#undef _STLP_TEMPLATE_CONTAINER
   1.254 +#undef _STLP_TEMPLATE_HEADER
   1.255 +
   1.256 +_STLP_END_NAMESPACE
   1.257 +#  undef  hashtable
   1.258 +
   1.259 +#endif /* _STLP_INTERNAL_HASHTABLE_H */
   1.260 +
   1.261 +// Local Variables:
   1.262 +// mode:C++
   1.263 +// End:
   1.264 +
   1.265 +