home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _hash_map.h < prev    next >
C/C++ Source or Header  |  2002-02-02  |  19KB  |  513 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Copyright (c) 1996,1997
  7.  * Silicon Graphics Computer Systems, Inc.
  8.  *
  9.  * Copyright (c) 1997
  10.  * Moscow Center for SPARC Technology
  11.  *
  12.  * Copyright (c) 1999 
  13.  * Boris Fomitchev
  14.  *
  15.  * This material is provided "as is", with absolutely no warranty expressed
  16.  * or implied. Any use is at your own risk.
  17.  *
  18.  * Permission to use or copy this software for any purpose is hereby granted 
  19.  * without fee, provided the above notices are retained on all copies.
  20.  * Permission to modify the code and to distribute modified code is granted,
  21.  * provided the above notices are retained, and a notice that the code was
  22.  * modified is included with the above copyright notice.
  23.  *
  24.  */
  25.  
  26. /* NOTE: This is an internal header file, included by other STL headers.
  27.  *   You should not attempt to use it directly.
  28.  */
  29.  
  30. #ifndef _STLP_INTERNAL_HASH_MAP_H
  31. #define _STLP_INTERNAL_HASH_MAP_H
  32.  
  33. #ifndef _STLP_INTERNAL_HASHTABLE_H
  34. # include <stl/_hashtable.h>
  35. #endif
  36.  
  37. _STLP_BEGIN_NAMESPACE
  38.  
  39. # define  hash_map      __WORKAROUND_RENAME(hash_map)
  40. # define  hash_multimap __WORKAROUND_RENAME(hash_multimap)
  41.  
  42. #  define _STLP_KEY_PAIR pair< const _Key, _Tp >
  43. #  define _STLP_HASHTABLE hashtable \
  44.       < pair < const _Key, _Tp >, _Key, _HashFcn, \
  45.       _STLP_SELECT1ST( _STLP_KEY_PAIR,  _Key ), _EqualKey, _Alloc >
  46.  
  47. template <class _Key, class _Tp, __DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
  48.           __DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
  49.           _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
  50. class hash_map
  51. {
  52. private:
  53.   typedef _STLP_HASHTABLE _Ht;
  54.   typedef hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
  55. public:
  56.   typedef typename _Ht::key_type key_type;
  57.   typedef _Tp data_type;
  58.   typedef _Tp mapped_type;
  59.   typedef typename _Ht::value_type _value_type;
  60.   typedef typename _Ht::value_type value_type;
  61.   typedef typename _Ht::hasher hasher;
  62.   typedef typename _Ht::key_equal key_equal;
  63.   
  64.   typedef typename _Ht::size_type size_type;
  65.   typedef typename _Ht::difference_type difference_type;
  66.   typedef typename _Ht::pointer pointer;
  67.   typedef typename _Ht::const_pointer const_pointer;
  68.   typedef typename _Ht::reference reference;
  69.   typedef typename _Ht::const_reference const_reference;
  70.  
  71.   typedef typename _Ht::iterator iterator;
  72.   typedef typename _Ht::const_iterator const_iterator;
  73.  
  74.   typedef typename _Ht::allocator_type allocator_type;
  75.  
  76.   hasher hash_funct() const { return _M_ht.hash_funct(); }
  77.   key_equal key_eq() const { return _M_ht.key_eq(); }
  78.   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  79.  
  80. private:
  81.   _Ht _M_ht;
  82. public:
  83.   hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
  84.   explicit hash_map(size_type __n)
  85.     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  86.   hash_map(size_type __n, const hasher& __hf)
  87.     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  88.   hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
  89.            const allocator_type& __a = allocator_type())
  90.     : _M_ht(__n, __hf, __eql, __a) {}
  91.  
  92. #ifdef _STLP_MEMBER_TEMPLATES
  93.   template <class _InputIterator>
  94.   hash_map(_InputIterator __f, _InputIterator __l)
  95.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  96.     { _M_ht.insert_unique(__f, __l); }
  97.   template <class _InputIterator>
  98.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
  99.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  100.     { _M_ht.insert_unique(__f, __l); }
  101.   template <class _InputIterator>
  102.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  103.            const hasher& __hf)
  104.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  105.     { _M_ht.insert_unique(__f, __l); }
  106. # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  107.   template <class _InputIterator>
  108.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  109.            const hasher& __hf, const key_equal& __eql)
  110.     : _M_ht(__n, __hf, __eql, allocator_type())
  111.     { _M_ht.insert_unique(__f, __l); }
  112. # endif
  113.   template <class _InputIterator>
  114.   hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  115.            const hasher& __hf, const key_equal& __eql,
  116.            const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
  117.     : _M_ht(__n, __hf, __eql, __a)
  118.     { _M_ht.insert_unique(__f, __l); }
  119.  
  120. #else
  121.   hash_map(const value_type* __f, const value_type* __l)
  122.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  123.     { _M_ht.insert_unique(__f, __l); }
  124.   hash_map(const value_type* __f, const value_type* __l, size_type __n)
  125.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  126.     { _M_ht.insert_unique(__f, __l); }
  127.   hash_map(const value_type* __f, const value_type* __l, size_type __n,
  128.            const hasher& __hf)
  129.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  130.     { _M_ht.insert_unique(__f, __l); }
  131.   hash_map(const value_type* __f, const value_type* __l, size_type __n,
  132.            const hasher& __hf, const key_equal& __eql,
  133.            const allocator_type& __a = allocator_type())
  134.     : _M_ht(__n, __hf, __eql, __a)
  135.     { _M_ht.insert_unique(__f, __l); }
  136.  
  137.   hash_map(const_iterator __f, const_iterator __l)
  138.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  139.     { _M_ht.insert_unique(__f, __l); }
  140.   hash_map(const_iterator __f, const_iterator __l, size_type __n)
  141.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  142.     { _M_ht.insert_unique(__f, __l); }
  143.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  144.            const hasher& __hf)
  145.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  146.     { _M_ht.insert_unique(__f, __l); }
  147.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  148.            const hasher& __hf, const key_equal& __eql,
  149.            const allocator_type& __a = allocator_type())
  150.     : _M_ht(__n, __hf, __eql, __a)
  151.     { _M_ht.insert_unique(__f, __l); }
  152. #endif /*_STLP_MEMBER_TEMPLATES */
  153.  
  154. public:
  155.   size_type size() const { return _M_ht.size(); }
  156.   size_type max_size() const { return _M_ht.max_size(); }
  157.   bool empty() const { return _M_ht.empty(); }
  158.   void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
  159.   iterator begin() { return _M_ht.begin(); }
  160.   iterator end() { return _M_ht.end(); }
  161.   const_iterator begin() const { return _M_ht.begin(); }
  162.   const_iterator end() const { return _M_ht.end(); }
  163.  
  164. public:
  165.   pair<iterator,bool> insert(const value_type& __obj)
  166.     { return _M_ht.insert_unique(__obj); }
  167. #ifdef _STLP_MEMBER_TEMPLATES
  168.   template <class _InputIterator>
  169.   void insert(_InputIterator __f, _InputIterator __l)
  170.     { _M_ht.insert_unique(__f,__l); }
  171. #else
  172.   void insert(const value_type* __f, const value_type* __l) {
  173.     _M_ht.insert_unique(__f,__l);
  174.   }
  175.   void insert(const_iterator __f, const_iterator __l)
  176.     { _M_ht.insert_unique(__f, __l); }
  177. #endif /*_STLP_MEMBER_TEMPLATES */
  178.   pair<iterator,bool> insert_noresize(const value_type& __obj)
  179.     { return _M_ht.insert_unique_noresize(__obj); }    
  180.  
  181.   iterator find(const key_type& __key) { return _M_ht.find(__key); }
  182.   const_iterator find(const key_type& __key) const { return _M_ht.find(__key); }
  183.  
  184.   _Tp& operator[](const key_type& __key) {
  185.     iterator __it = _M_ht.find(__key);
  186.     return (__it == _M_ht.end() ? 
  187.         _M_ht._M_insert(_value_type(__key, _Tp())).second : 
  188.         (*__it).second );
  189.   }
  190.  
  191.   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
  192.   
  193.   pair<iterator, iterator> equal_range(const key_type& __key)
  194.     { return _M_ht.equal_range(__key); }
  195.   pair<const_iterator, const_iterator>
  196.   equal_range(const key_type& __key) const
  197.     { return _M_ht.equal_range(__key); }
  198.  
  199.   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
  200.   void erase(iterator __it) { _M_ht.erase(__it); }
  201.   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  202.   void clear() { _M_ht.clear(); }
  203.  
  204.   void resize(size_type __hint) { _M_ht.resize(__hint); }
  205.   size_type bucket_count() const { return _M_ht.bucket_count(); }
  206.   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  207.   size_type elems_in_bucket(size_type __n) const
  208.     { return _M_ht.elems_in_bucket(__n); }
  209.   static bool _STLP_CALL _M_equal (const _Self& __x, const _Self& __y) {
  210.     return _Ht::_M_equal(__x._M_ht,__y._M_ht);
  211.   }
  212. };
  213.  
  214.  
  215. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  216. inline bool _STLP_CALL 
  217. operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  218.            const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  219. {
  220.   return hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>::_M_equal(__hm1, __hm2);
  221. }
  222. #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
  223.  
  224. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  225. inline bool _STLP_CALL 
  226. operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  227.            const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
  228.   return !(__hm1 == __hm2);
  229. }
  230.  
  231. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  232. inline void _STLP_CALL 
  233. swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  234.      hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  235. {
  236.   __hm1.swap(__hm2);
  237. }
  238.  
  239. #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
  240.  
  241. template <class _Key, class _Tp, __DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
  242.           __DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
  243.           _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(const _Key, _Tp) >
  244. class hash_multimap
  245. {
  246. private:
  247.   typedef _STLP_HASHTABLE _Ht;
  248.   typedef hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
  249. public:
  250.   typedef typename _Ht::key_type key_type;
  251.   typedef _Tp data_type;
  252.   typedef _Tp mapped_type;
  253.   typedef typename _Ht::value_type _value_type;
  254.   typedef _value_type value_type;
  255.   typedef typename _Ht::hasher hasher;
  256.   typedef typename _Ht::key_equal key_equal;
  257.  
  258.   typedef typename _Ht::size_type size_type;
  259.   typedef typename _Ht::difference_type difference_type;
  260.   typedef typename _Ht::pointer pointer;
  261.   typedef typename _Ht::const_pointer const_pointer;
  262.   typedef typename _Ht::reference reference;
  263.   typedef typename _Ht::const_reference const_reference;
  264.  
  265.   typedef typename _Ht::iterator iterator;
  266.   typedef typename _Ht::const_iterator const_iterator;
  267.  
  268.   typedef typename _Ht::allocator_type allocator_type;
  269.  
  270.   hasher hash_funct() const { return _M_ht.hash_funct(); }
  271.   key_equal key_eq() const { return _M_ht.key_eq(); }
  272.   allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  273.  
  274. private:
  275.   _Ht _M_ht;
  276. public:
  277.   hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
  278.   explicit hash_multimap(size_type __n)
  279.     : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  280.   hash_multimap(size_type __n, const hasher& __hf)
  281.     : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  282.   hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
  283.                 const allocator_type& __a = allocator_type())
  284.     : _M_ht(__n, __hf, __eql, __a) {}
  285.  
  286. #ifdef _STLP_MEMBER_TEMPLATES
  287.   template <class _InputIterator>
  288.   hash_multimap(_InputIterator __f, _InputIterator __l)
  289.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  290.     { _M_ht.insert_equal(__f, __l); }
  291.   template <class _InputIterator>
  292.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
  293.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  294.     { _M_ht.insert_equal(__f, __l); }
  295.   template <class _InputIterator>
  296.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  297.                 const hasher& __hf)
  298.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  299.     { _M_ht.insert_equal(__f, __l); }
  300. # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  301.   template <class _InputIterator>
  302.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  303.                 const hasher& __hf, const key_equal& __eql)
  304.     : _M_ht(__n, __hf, __eql, allocator_type())
  305.     { _M_ht.insert_equal(__f, __l); }
  306. #  endif
  307.   template <class _InputIterator>
  308.   hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  309.                 const hasher& __hf, const key_equal& __eql,
  310.                 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
  311.     : _M_ht(__n, __hf, __eql, __a)
  312.     { _M_ht.insert_equal(__f, __l); }
  313.  
  314. #else
  315.   hash_multimap(const value_type* __f, const value_type* __l)
  316.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  317.     { _M_ht.insert_equal(__f, __l); }
  318.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
  319.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  320.     { _M_ht.insert_equal(__f, __l); }
  321.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  322.                 const hasher& __hf)
  323.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  324.     { _M_ht.insert_equal(__f, __l); }
  325.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  326.                 const hasher& __hf, const key_equal& __eql,
  327.                 const allocator_type& __a = allocator_type())
  328.     : _M_ht(__n, __hf, __eql, __a)
  329.     { _M_ht.insert_equal(__f, __l); }
  330.  
  331.   hash_multimap(const_iterator __f, const_iterator __l)
  332.     : _M_ht(100, hasher(), key_equal(), allocator_type())
  333.     { _M_ht.insert_equal(__f, __l); }
  334.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
  335.     : _M_ht(__n, hasher(), key_equal(), allocator_type())
  336.     { _M_ht.insert_equal(__f, __l); }
  337.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  338.                 const hasher& __hf)
  339.     : _M_ht(__n, __hf, key_equal(), allocator_type())
  340.     { _M_ht.insert_equal(__f, __l); }
  341.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  342.                 const hasher& __hf, const key_equal& __eql,
  343.                 const allocator_type& __a = allocator_type())
  344.     : _M_ht(__n, __hf, __eql, __a)
  345.     { _M_ht.insert_equal(__f, __l); }
  346. #endif /*_STLP_MEMBER_TEMPLATES */
  347.  
  348. public:
  349.   size_type size() const { return _M_ht.size(); }
  350.   size_type max_size() const { return _M_ht.max_size(); }
  351.   bool empty() const { return _M_ht.empty(); }
  352.   void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
  353.  
  354.   iterator begin() { return _M_ht.begin(); }
  355.   iterator end() { return _M_ht.end(); }
  356.   const_iterator begin() const { return _M_ht.begin(); }
  357.   const_iterator end() const { return _M_ht.end(); }
  358.  
  359. public:
  360.   iterator insert(const value_type& __obj) 
  361.     { return _M_ht.insert_equal(__obj); }
  362. #ifdef _STLP_MEMBER_TEMPLATES
  363.   template <class _InputIterator>
  364.   void insert(_InputIterator __f, _InputIterator __l) 
  365.     { _M_ht.insert_equal(__f,__l); }
  366. #else
  367.   void insert(const value_type* __f, const value_type* __l) {
  368.     _M_ht.insert_equal(__f,__l);
  369.   }
  370.   void insert(const_iterator __f, const_iterator __l) 
  371.     { _M_ht.insert_equal(__f, __l); }
  372. #endif /*_STLP_MEMBER_TEMPLATES */
  373.   iterator insert_noresize(const value_type& __obj)
  374.     { return _M_ht.insert_equal_noresize(__obj); }    
  375.  
  376.   iterator find(const key_type& __key) { return _M_ht.find(__key); }
  377.   const_iterator find(const key_type& __key) const 
  378.     { return _M_ht.find(__key); }
  379.  
  380.   size_type count(const key_type& __key) const { return _M_ht.count(__key); }
  381.   
  382.   pair<iterator, iterator> equal_range(const key_type& __key)
  383.     { return _M_ht.equal_range(__key); }
  384.   pair<const_iterator, const_iterator>
  385.   equal_range(const key_type& __key) const
  386.     { return _M_ht.equal_range(__key); }
  387.  
  388.   size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
  389.   void erase(iterator __it) { _M_ht.erase(__it); }
  390.   void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  391.   void clear() { _M_ht.clear(); }
  392.  
  393. public:
  394.   void resize(size_type __hint) { _M_ht.resize(__hint); }
  395.   size_type bucket_count() const { return _M_ht.bucket_count(); }
  396.   size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  397.   size_type elems_in_bucket(size_type __n) const
  398.     { return _M_ht.elems_in_bucket(__n); }
  399.   static bool _STLP_CALL _M_equal (const _Self& __x, const _Self& __y) {
  400.     return _Ht::_M_equal(__x._M_ht,__y._M_ht);
  401.   }
  402. };
  403.  
  404.  
  405. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  406. inline bool _STLP_CALL 
  407. operator==(const hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  408.            const hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  409. {
  410.   return hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>::_M_equal(__hm1, __hm2);
  411. }
  412.  
  413. #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
  414.  
  415. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  416. inline bool _STLP_CALL 
  417. operator!=(const hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  418.            const hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
  419.   return !(__hm1 == __hm2);
  420. }
  421.  
  422. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  423. inline void _STLP_CALL 
  424. swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
  425.      hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
  426. {
  427.   __hm1.swap(__hm2);
  428. }
  429.  
  430. #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
  431.  
  432.  
  433. // Specialization of insert_iterator so that it will work for hash_map
  434. // and hash_multimap.
  435.  
  436. #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
  437.  
  438. template <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
  439. class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  440. protected:
  441.   typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  442.   _Container* container;
  443. public:
  444.   typedef _Container          container_type;
  445.   typedef output_iterator_tag iterator_category;
  446.   typedef void                value_type;
  447.   typedef void                difference_type;
  448.   typedef void                pointer;
  449.   typedef void                reference;
  450.  
  451.   insert_iterator(_Container& __x) : container(&__x) {}
  452.   insert_iterator(_Container& __x, typename _Container::iterator)
  453.     : container(&__x) {}
  454.   insert_iterator<_Container>&
  455.   operator=(const typename _Container::value_type& __val) { 
  456.     container->insert(__val);
  457.     return *this;
  458.   }
  459.   insert_iterator<_Container>& operator*() { return *this; }
  460.   insert_iterator<_Container>& operator++() { return *this; }
  461.   insert_iterator<_Container>& operator++(int) { return *this; }
  462. };
  463.  
  464. template <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
  465. class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  466. protected:
  467.   typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  468.   _Container* container;
  469.   typename _Container::iterator iter;
  470. public:
  471.   typedef _Container          container_type;
  472.   typedef output_iterator_tag iterator_category;
  473.   typedef void                value_type;
  474.   typedef void                difference_type;
  475.   typedef void                pointer;
  476.   typedef void                reference;
  477.  
  478.   insert_iterator(_Container& __x) : container(&__x) {}
  479.   insert_iterator(_Container& __x, typename _Container::iterator)
  480.     : container(&__x) {}
  481.   insert_iterator<_Container>&
  482.   operator=(const typename _Container::value_type& __val) { 
  483.     container->insert(__val);
  484.     return *this;
  485.   }
  486.   insert_iterator<_Container>& operator*() { return *this; }
  487.   insert_iterator<_Container>& operator++() { return *this; }
  488.   insert_iterator<_Container>& operator++(int) { return *this; }
  489. };
  490.  
  491. #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
  492.  
  493. // do a cleanup
  494. # undef hash_map
  495. # undef hash_multimap
  496.  
  497. # define __hash_map__ __FULL_NAME(hash_map)
  498. # define __hash_multimap__ __FULL_NAME(hash_multimap)
  499.  
  500.  
  501. _STLP_END_NAMESPACE
  502.  
  503. # if defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM) 
  504. #  include <stl/wrappers/_hash_map.h>
  505. # endif /*  WRAPPER */
  506.  
  507. #endif /* _STLP_INTERNAL_HASH_MAP_H */
  508.  
  509. // Local Variables:
  510. // mode:C++
  511. // End:
  512.  
  513.