- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Configs/TI_DSP_BIOS/stl/stl_hash_map.h

    00001 /*
    00002  * Copyright (c) 1996
    00003  * Silicon Graphics Computer Systems, Inc.
    00004  *
    00005  * Permission to use, copy, modify, distribute and sell this software
    00006  * and its documentation for any purpose is hereby granted without fee,
    00007  * provided that the above copyright notice appear in all copies and
    00008  * that both that copyright notice and this permission notice appear
    00009  * in supporting documentation.  Silicon Graphics makes no
    00010  * representations about the suitability of this software for any
    00011  * purpose.  It is provided "as is" without express or implied warranty.
    00012  *
    00013  *
    00014  * Copyright (c) 1994
    00015  * Hewlett-Packard Company
    00016  *
    00017  * Permission to use, copy, modify, distribute and sell this software
    00018  * and its documentation for any purpose is hereby granted without fee,
    00019  * provided that the above copyright notice appear in all copies and
    00020  * that both that copyright notice and this permission notice appear
    00021  * in supporting documentation.  Hewlett-Packard Company makes no
    00022  * representations about the suitability of this software for any
    00023  * purpose.  It is provided "as is" without express or implied warranty.
    00024  *
    00025  */
    00026
    00027 /* NOTE: This is an internal header file, included by other STL headers.
    00028  *   You should not attempt to use it directly.
    00029  */
    00030
    00031 #ifndef __SGI_STL_INTERNAL_HASH_MAP_H
    00032 #define __SGI_STL_INTERNAL_HASH_MAP_H
    00033
    00034
    00035 __STL_BEGIN_NAMESPACE
    00036
    00037 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    00038 #pragma set woff 1174
    00039 #pragma set woff 1375
    00040 #endif
    00041
    00042 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
    00043 template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
    00044           class _EqualKey = equal_to<_Key>,
    00045           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00046 #else
    00047 template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
    00048           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00049 #endif
    00050 class hash_map
    00051 {
    00052 private:
    00053   typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
    00054                     _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
    00055   _Ht _M_ht;
    00056
    00057 public:
    00058   typedef typename _Ht::key_type key_type;
    00059   typedef _Tp data_type;
    00060   typedef _Tp mapped_type;
    00061   typedef typename _Ht::value_type value_type;
    00062   typedef typename _Ht::hasher hasher;
    00063   typedef typename _Ht::key_equal key_equal;
    00064
    00065   typedef typename _Ht::size_type size_type;
    00066   typedef typename _Ht::difference_type difference_type;
    00067   typedef typename _Ht::pointer pointer;
    00068   typedef typename _Ht::const_pointer const_pointer;
    00069   typedef typename _Ht::reference reference;
    00070   typedef typename _Ht::const_reference const_reference;
    00071
    00072   typedef typename _Ht::iterator iterator;
    00073   typedef typename _Ht::const_iterator const_iterator;
    00074
    00075   typedef typename _Ht::allocator_type allocator_type;
    00076
    00077   hasher hash_funct() const { return _M_ht.hash_funct(); }
    00078   key_equal key_eq() const { return _M_ht.key_eq(); }
    00079   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
    00080
    00081 public:
    00082   hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    00083   explicit hash_map(size_type __n)
    00084     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    00085   hash_map(size_type __n, const hasher& __hf)
    00086     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    00087   hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
    00088            const allocator_type& __a = allocator_type())
    00089     : _M_ht(__n, __hf, __eql, __a) {}
    00090
    00091 #ifdef __STL_MEMBER_TEMPLATES
    00092   template <class _InputIterator>
    00093   hash_map(_InputIterator __f, _InputIterator __l)
    00094     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00095     { _M_ht.insert_unique(__f, __l); }
    00096   template <class _InputIterator>
    00097   hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
    00098     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00099     { _M_ht.insert_unique(__f, __l); }
    00100   template <class _InputIterator>
    00101   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
    00102            const hasher& __hf)
    00103     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00104     { _M_ht.insert_unique(__f, __l); }
    00105   template <class _InputIterator>
    00106   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
    00107            const hasher& __hf, const key_equal& __eql,
    00108            const allocator_type& __a = allocator_type())
    00109     : _M_ht(__n, __hf, __eql, __a)
    00110     { _M_ht.insert_unique(__f, __l); }
    00111
    00112 #else
    00113   hash_map(const value_type* __f, const value_type* __l)
    00114     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00115     { _M_ht.insert_unique(__f, __l); }
    00116   hash_map(const value_type* __f, const value_type* __l, size_type __n)
    00117     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00118     { _M_ht.insert_unique(__f, __l); }
    00119   hash_map(const value_type* __f, const value_type* __l, size_type __n,
    00120            const hasher& __hf)
    00121     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00122     { _M_ht.insert_unique(__f, __l); }
    00123   hash_map(const value_type* __f, const value_type* __l, size_type __n,
    00124            const hasher& __hf, const key_equal& __eql,
    00125            const allocator_type& __a = allocator_type())
    00126     : _M_ht(__n, __hf, __eql, __a)
    00127     { _M_ht.insert_unique(__f, __l); }
    00128
    00129   hash_map(const_iterator __f, const_iterator __l)
    00130     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00131     { _M_ht.insert_unique(__f, __l); }
    00132   hash_map(const_iterator __f, const_iterator __l, size_type __n)
    00133     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00134     { _M_ht.insert_unique(__f, __l); }
    00135   hash_map(const_iterator __f, const_iterator __l, size_type __n,
    00136            const hasher& __hf)
    00137     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00138     { _M_ht.insert_unique(__f, __l); }
    00139   hash_map(const_iterator __f, const_iterator __l, size_type __n,
    00140            const hasher& __hf, const key_equal& __eql,
    00141            const allocator_type& __a = allocator_type())
    00142     : _M_ht(__n, __hf, __eql, __a)
    00143     { _M_ht.insert_unique(__f, __l); }
    00144 #endif /*__STL_MEMBER_TEMPLATES */
    00145
    00146 public:
    00147   size_type size() const { return _M_ht.size(); }
    00148   size_type max_size() const { return _M_ht.max_size(); }
    00149   bool empty() const { return _M_ht.empty(); }
    00150   void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
    00151   friend bool
    00152   operator== __STL_NULL_TMPL_ARGS (const hash_map&, const hash_map&);
    00153
    00154   iterator begin() { return _M_ht.begin(); }
    00155   iterator end() { return _M_ht.end(); }
    00156   const_iterator begin() const { return _M_ht.begin(); }
    00157   const_iterator end() const { return _M_ht.end(); }
    00158
    00159 public:
    00160   pair<iterator,bool> insert(const value_type& __obj)
    00161     { return _M_ht.insert_unique(__obj); }
    00162 #ifdef __STL_MEMBER_TEMPLATES
    00163   template <class _InputIterator>
    00164   void insert(_InputIterator __f, _InputIterator __l)
    00165     { _M_ht.insert_unique(__f,__l); }
    00166 #else
    00167   void insert(const value_type* __f, const value_type* __l) {
    00168     _M_ht.insert_unique(__f,__l);
    00169   }
    00170   void insert(const_iterator __f, const_iterator __l)
    00171     { _M_ht.insert_unique(__f, __l); }
    00172 #endif /*__STL_MEMBER_TEMPLATES */
    00173   pair<iterator,bool> insert_noresize(const value_type& __obj)
    00174     { return _M_ht.insert_unique_noresize(__obj); }
    00175
    00176   iterator find(const key_type& __key) { return _M_ht.find(__key); }
    00177   const_iterator find(const key_type& __key) const
    00178     { return _M_ht.find(__key); }
    00179
    00180   _Tp& operator[](const key_type& __key) {
    00181     return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
    00182   }
    00183
    00184   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
    00185
    00186   pair<iterator, iterator> equal_range(const key_type& __key)
    00187     { return _M_ht.equal_range(__key); }
    00188   pair<const_iterator, const_iterator>
    00189   equal_range(const key_type& __key) const
    00190     { return _M_ht.equal_range(__key); }
    00191
    00192   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    00193   void erase(iterator __it) { _M_ht.erase(__it); }
    00194   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    00195   void clear() { _M_ht.clear(); }
    00196
    00197   void resize(size_type __hint) { _M_ht.resize(__hint); }
    00198   size_type bucket_count() const { return _M_ht.bucket_count(); }
    00199   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    00200   size_type elems_in_bucket(size_type __n) const
    00201     { return _M_ht.elems_in_bucket(__n); }
    00202 };
    00203
    00204 template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    00205 inline bool
    00206 operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    00207            const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    00208 {
    00209   return __hm1._M_ht == __hm2._M_ht;
    00210 }
    00211
    00212 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    00213
    00214 template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    00215 inline void
    00216 swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    00217      hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    00218 {
    00219   __hm1.swap(__hm2);
    00220 }
    00221
    00222 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
    00223
    00224 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
    00225 template <class _Key, class _Tp, class _HashFcn = hash<_Key>,
    00226           class _EqualKey = equal_to<_Key>,
    00227           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00228 #else
    00229 template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
    00230           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00231 #endif
    00232 class hash_multimap
    00233 {
    00234 private:
    00235   typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
    00236                     _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
    00237           _Ht;
    00238   _Ht _M_ht;
    00239
    00240 public:
    00241   typedef typename _Ht::key_type key_type;
    00242   typedef _Tp data_type;
    00243   typedef _Tp mapped_type;
    00244   typedef typename _Ht::value_type value_type;
    00245   typedef typename _Ht::hasher hasher;
    00246   typedef typename _Ht::key_equal key_equal;
    00247
    00248   typedef typename _Ht::size_type size_type;
    00249   typedef typename _Ht::difference_type difference_type;
    00250   typedef typename _Ht::pointer pointer;
    00251   typedef typename _Ht::const_pointer const_pointer;
    00252   typedef typename _Ht::reference reference;
    00253   typedef typename _Ht::const_reference const_reference;
    00254
    00255   typedef typename _Ht::iterator iterator;
    00256   typedef typename _Ht::const_iterator const_iterator;
    00257
    00258   typedef typename _Ht::allocator_type allocator_type;
    00259
    00260   hasher hash_funct() const { return _M_ht.hash_funct(); }
    00261   key_equal key_eq() const { return _M_ht.key_eq(); }
    00262   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
    00263
    00264 public:
    00265   hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
    00266   explicit hash_multimap(size_type __n)
    00267     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
    00268   hash_multimap(size_type __n, const hasher& __hf)
    00269     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
    00270   hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
    00271                 const allocator_type& __a = allocator_type())
    00272     : _M_ht(__n, __hf, __eql, __a) {}
    00273
    00274 #ifdef __STL_MEMBER_TEMPLATES
    00275   template <class _InputIterator>
    00276   hash_multimap(_InputIterator __f, _InputIterator __l)
    00277     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00278     { _M_ht.insert_equal(__f, __l); }
    00279   template <class _InputIterator>
    00280   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
    00281     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00282     { _M_ht.insert_equal(__f, __l); }
    00283   template <class _InputIterator>
    00284   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
    00285                 const hasher& __hf)
    00286     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00287     { _M_ht.insert_equal(__f, __l); }
    00288   template <class _InputIterator>
    00289   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
    00290                 const hasher& __hf, const key_equal& __eql,
    00291                 const allocator_type& __a = allocator_type())
    00292     : _M_ht(__n, __hf, __eql, __a)
    00293     { _M_ht.insert_equal(__f, __l); }
    00294
    00295 #else
    00296   hash_multimap(const value_type* __f, const value_type* __l)
    00297     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00298     { _M_ht.insert_equal(__f, __l); }
    00299   hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
    00300     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00301     { _M_ht.insert_equal(__f, __l); }
    00302   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
    00303                 const hasher& __hf)
    00304     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00305     { _M_ht.insert_equal(__f, __l); }
    00306   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
    00307                 const hasher& __hf, const key_equal& __eql,
    00308                 const allocator_type& __a = allocator_type())
    00309     : _M_ht(__n, __hf, __eql, __a)
    00310     { _M_ht.insert_equal(__f, __l); }
    00311
    00312   hash_multimap(const_iterator __f, const_iterator __l)
    00313     : _M_ht(100, hasher(), key_equal(), allocator_type())
    00314     { _M_ht.insert_equal(__f, __l); }
    00315   hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
    00316     : _M_ht(__n, hasher(), key_equal(), allocator_type())
    00317     { _M_ht.insert_equal(__f, __l); }
    00318   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
    00319                 const hasher& __hf)
    00320     : _M_ht(__n, __hf, key_equal(), allocator_type())
    00321     { _M_ht.insert_equal(__f, __l); }
    00322   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
    00323                 const hasher& __hf, const key_equal& __eql,
    00324                 const allocator_type& __a = allocator_type())
    00325     : _M_ht(__n, __hf, __eql, __a)
    00326     { _M_ht.insert_equal(__f, __l); }
    00327 #endif /*__STL_MEMBER_TEMPLATES */
    00328
    00329 public:
    00330   size_type size() const { return _M_ht.size(); }
    00331   size_type max_size() const { return _M_ht.max_size(); }
    00332   bool empty() const { return _M_ht.empty(); }
    00333   void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
    00334   friend bool
    00335   operator== __STL_NULL_TMPL_ARGS (const hash_multimap&,
    00336                                    const hash_multimap&);
    00337
    00338   iterator begin() { return _M_ht.begin(); }
    00339   iterator end() { return _M_ht.end(); }
    00340   const_iterator begin() const { return _M_ht.begin(); }
    00341   const_iterator end() const { return _M_ht.end(); }
    00342
    00343 public:
    00344   iterator insert(const value_type& __obj)
    00345     { return _M_ht.insert_equal(__obj); }
    00346 #ifdef __STL_MEMBER_TEMPLATES
    00347   template <class _InputIterator>
    00348   void insert(_InputIterator __f, _InputIterator __l)
    00349     { _M_ht.insert_equal(__f,__l); }
    00350 #else
    00351   void insert(const value_type* __f, const value_type* __l) {
    00352     _M_ht.insert_equal(__f,__l);
    00353   }
    00354   void insert(const_iterator __f, const_iterator __l)
    00355     { _M_ht.insert_equal(__f, __l); }
    00356 #endif /*__STL_MEMBER_TEMPLATES */
    00357   iterator insert_noresize(const value_type& __obj)
    00358     { return _M_ht.insert_equal_noresize(__obj); }
    00359
    00360   iterator find(const key_type& __key) { return _M_ht.find(__key); }
    00361   const_iterator find(const key_type& __key) const
    00362     { return _M_ht.find(__key); }
    00363
    00364   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
    00365
    00366   pair<iterator, iterator> equal_range(const key_type& __key)
    00367     { return _M_ht.equal_range(__key); }
    00368   pair<const_iterator, const_iterator>
    00369   equal_range(const key_type& __key) const
    00370     { return _M_ht.equal_range(__key); }
    00371
    00372   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
    00373   void erase(iterator __it) { _M_ht.erase(__it); }
    00374   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
    00375   void clear() { _M_ht.clear(); }
    00376
    00377 public:
    00378   void resize(size_type __hint) { _M_ht.resize(__hint); }
    00379   size_type bucket_count() const { return _M_ht.bucket_count(); }
    00380   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
    00381   size_type elems_in_bucket(size_type __n) const
    00382     { return _M_ht.elems_in_bucket(__n); }
    00383 };
    00384
    00385 template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
    00386 inline bool
    00387 operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
    00388            const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
    00389 {
    00390   return __hm1._M_ht == __hm2._M_ht;
    00391 }
    00392
    00393 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    00394
    00395 template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
    00396 inline void
    00397 swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
    00398      hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
    00399 {
    00400   __hm1.swap(__hm2);
    00401 }
    00402
    00403 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
    00404
    00405 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    00406 #pragma reset woff 1174
    00407 #pragma reset woff 1375
    00408 #endif
    00409
    00410 __STL_END_NAMESPACE
    00411
    00412 #endif /* __SGI_STL_INTERNAL_HASH_MAP_H */
    00413
    00414 // Local Variables:
    00415 // mode:C++
    00416 // End: