_hash_map.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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. /* NOTE: This is an internal header file, included by other STL headers.
  26. * You should not attempt to use it directly.
  27. */
  28. #ifndef _STLP_INTERNAL_HASH_MAP_H
  29. #define _STLP_INTERNAL_HASH_MAP_H
  30. #ifndef _STLP_INTERNAL_HASHTABLE_H
  31. # include <stl/_hashtable.h>
  32. #endif
  33. _STLP_BEGIN_NAMESPACE
  34. //Specific iterator traits creation
  35. _STLP_CREATE_HASH_ITERATOR_TRAITS(HashMapTraitsT, traits)
  36. template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
  37. _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
  38. _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
  39. class hash_map
  40. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
  41. : public __stlport_class<hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
  42. #endif
  43. {
  44. private:
  45. typedef hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
  46. public:
  47. typedef _Key key_type;
  48. typedef _Tp data_type;
  49. typedef _Tp mapped_type;
  50. typedef pair<_STLP_CONST key_type, data_type> value_type;
  51. private:
  52. //Specific iterator traits creation
  53. typedef _STLP_PRIV _HashMapTraitsT<value_type> _HashMapTraits;
  54. public:
  55. typedef hashtable<value_type, key_type, _HashFcn, _HashMapTraits,
  56. _STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
  57. typedef typename _Ht::hasher hasher;
  58. typedef typename _Ht::key_equal key_equal;
  59. typedef typename _Ht::size_type size_type;
  60. typedef typename _Ht::difference_type difference_type;
  61. typedef typename _Ht::pointer pointer;
  62. typedef typename _Ht::const_pointer const_pointer;
  63. typedef typename _Ht::reference reference;
  64. typedef typename _Ht::const_reference const_reference;
  65. typedef typename _Ht::iterator iterator;
  66. typedef typename _Ht::const_iterator const_iterator;
  67. typedef typename _Ht::allocator_type allocator_type;
  68. hasher hash_funct() const { return _M_ht.hash_funct(); }
  69. key_equal key_eq() const { return _M_ht.key_eq(); }
  70. allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  71. private:
  72. _Ht _M_ht;
  73. _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
  74. public:
  75. hash_map() : _M_ht(0, hasher(), key_equal(), allocator_type()) {}
  76. explicit hash_map(size_type __n)
  77. : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  78. hash_map(size_type __n, const hasher& __hf)
  79. : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  80. hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
  81. const allocator_type& __a = allocator_type())
  82. : _M_ht(__n, __hf, __eql, __a) {}
  83. #if !defined (_STLP_NO_MOVE_SEMANTIC)
  84. hash_map(__move_source<_Self> src)
  85. : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {
  86. }
  87. #endif
  88. #ifdef _STLP_MEMBER_TEMPLATES
  89. template <class _InputIterator>
  90. hash_map(_InputIterator __f, _InputIterator __l)
  91. : _M_ht(0, hasher(), key_equal(), allocator_type())
  92. { _M_ht.insert_unique(__f, __l); }
  93. template <class _InputIterator>
  94. hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
  95. : _M_ht(__n, 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. const hasher& __hf)
  100. : _M_ht(__n, __hf, key_equal(), allocator_type())
  101. { _M_ht.insert_unique(__f, __l); }
  102. # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  103. template <class _InputIterator>
  104. hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  105. const hasher& __hf, const key_equal& __eql)
  106. : _M_ht(__n, __hf, __eql, allocator_type())
  107. { _M_ht.insert_unique(__f, __l); }
  108. # endif
  109. template <class _InputIterator>
  110. hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
  111. const hasher& __hf, const key_equal& __eql,
  112. const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
  113. : _M_ht(__n, __hf, __eql, __a)
  114. { _M_ht.insert_unique(__f, __l); }
  115. #else
  116. hash_map(const value_type* __f, const value_type* __l)
  117. : _M_ht(0, hasher(), key_equal(), allocator_type())
  118. { _M_ht.insert_unique(__f, __l); }
  119. hash_map(const value_type* __f, const value_type* __l, size_type __n)
  120. : _M_ht(__n, hasher(), key_equal(), allocator_type())
  121. { _M_ht.insert_unique(__f, __l); }
  122. hash_map(const value_type* __f, const value_type* __l, size_type __n,
  123. const hasher& __hf)
  124. : _M_ht(__n, __hf, key_equal(), allocator_type())
  125. { _M_ht.insert_unique(__f, __l); }
  126. hash_map(const value_type* __f, const value_type* __l, size_type __n,
  127. const hasher& __hf, const key_equal& __eql,
  128. const allocator_type& __a = allocator_type())
  129. : _M_ht(__n, __hf, __eql, __a)
  130. { _M_ht.insert_unique(__f, __l); }
  131. hash_map(const_iterator __f, const_iterator __l)
  132. : _M_ht(0, hasher(), key_equal(), allocator_type())
  133. { _M_ht.insert_unique(__f, __l); }
  134. hash_map(const_iterator __f, const_iterator __l, size_type __n)
  135. : _M_ht(__n, hasher(), key_equal(), allocator_type())
  136. { _M_ht.insert_unique(__f, __l); }
  137. hash_map(const_iterator __f, const_iterator __l, size_type __n,
  138. const hasher& __hf)
  139. : _M_ht(__n, __hf, key_equal(), allocator_type())
  140. { _M_ht.insert_unique(__f, __l); }
  141. hash_map(const_iterator __f, const_iterator __l, size_type __n,
  142. const hasher& __hf, const key_equal& __eql,
  143. const allocator_type& __a = allocator_type())
  144. : _M_ht(__n, __hf, __eql, __a)
  145. { _M_ht.insert_unique(__f, __l); }
  146. #endif /*_STLP_MEMBER_TEMPLATES */
  147. public:
  148. size_type size() const { return _M_ht.size(); }
  149. size_type max_size() const { return _M_ht.max_size(); }
  150. bool empty() const { return _M_ht.empty(); }
  151. void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
  152. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
  153. void _M_swap_workaround(_Self& __x) { swap(__x); }
  154. #endif
  155. iterator begin() { return _M_ht.begin(); }
  156. iterator end() { return _M_ht.end(); }
  157. const_iterator begin() const { return _M_ht.begin(); }
  158. const_iterator end() const { return _M_ht.end(); }
  159. public:
  160. pair<iterator,bool> insert(const value_type& __obj)
  161. { return _M_ht.insert_unique(__obj); }
  162. #ifdef _STLP_MEMBER_TEMPLATES
  163. template <class _InputIterator>
  164. void insert(_InputIterator __f, _InputIterator __l)
  165. { _M_ht.insert_unique(__f,__l); }
  166. #else
  167. void insert(const value_type* __f, const value_type* __l)
  168. { _M_ht.insert_unique(__f,__l); }
  169. void insert(const_iterator __f, const_iterator __l)
  170. { _M_ht.insert_unique(__f, __l); }
  171. #endif /*_STLP_MEMBER_TEMPLATES */
  172. pair<iterator,bool> insert_noresize(const value_type& __obj)
  173. { return _M_ht.insert_unique_noresize(__obj); }
  174. _STLP_TEMPLATE_FOR_CONT_EXT
  175. iterator find(const _KT& __key) { return _M_ht.find(__key); }
  176. _STLP_TEMPLATE_FOR_CONT_EXT
  177. const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
  178. _STLP_TEMPLATE_FOR_CONT_EXT
  179. _Tp& operator[](const _KT& __key) {
  180. iterator __it = _M_ht.find(__key);
  181. return (__it == _M_ht.end() ?
  182. _M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second :
  183. (*__it).second );
  184. }
  185. _STLP_TEMPLATE_FOR_CONT_EXT
  186. size_type count(const _KT& __key) const { return _M_ht.count(__key); }
  187. _STLP_TEMPLATE_FOR_CONT_EXT
  188. pair<iterator, iterator> equal_range(const _KT& __key)
  189. { return _M_ht.equal_range(__key); }
  190. _STLP_TEMPLATE_FOR_CONT_EXT
  191. pair<const_iterator, const_iterator> equal_range(const _KT& __key) const
  192. { return _M_ht.equal_range(__key); }
  193. _STLP_TEMPLATE_FOR_CONT_EXT
  194. size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
  195. void erase(iterator __it) { _M_ht.erase(__it); }
  196. void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  197. void clear() { _M_ht.clear(); }
  198. void resize(size_type __hint) { _M_ht.resize(__hint); }
  199. size_type bucket_count() const { return _M_ht.bucket_count(); }
  200. size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  201. size_type elems_in_bucket(size_type __n) const
  202. { return _M_ht.elems_in_bucket(__n); }
  203. };
  204. //Specific iterator traits creation
  205. _STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultimapTraitsT, traits)
  206. template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>),
  207. _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),
  208. _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) >
  209. class hash_multimap
  210. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
  211. : public __stlport_class<hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> >
  212. #endif
  213. {
  214. private:
  215. typedef hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self;
  216. public:
  217. typedef _Key key_type;
  218. typedef _Tp data_type;
  219. typedef _Tp mapped_type;
  220. typedef pair<_STLP_CONST key_type, data_type> value_type;
  221. private:
  222. //Specific iterator traits creation
  223. typedef _STLP_PRIV _HashMultimapTraitsT<value_type> _HashMultimapTraits;
  224. public:
  225. typedef hashtable<value_type, key_type, _HashFcn, _HashMultimapTraits,
  226. _STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;
  227. typedef typename _Ht::hasher hasher;
  228. typedef typename _Ht::key_equal key_equal;
  229. typedef typename _Ht::size_type size_type;
  230. typedef typename _Ht::difference_type difference_type;
  231. typedef typename _Ht::pointer pointer;
  232. typedef typename _Ht::const_pointer const_pointer;
  233. typedef typename _Ht::reference reference;
  234. typedef typename _Ht::const_reference const_reference;
  235. typedef typename _Ht::iterator iterator;
  236. typedef typename _Ht::const_iterator const_iterator;
  237. typedef typename _Ht::allocator_type allocator_type;
  238. hasher hash_funct() const { return _M_ht.hash_funct(); }
  239. key_equal key_eq() const { return _M_ht.key_eq(); }
  240. allocator_type get_allocator() const { return _M_ht.get_allocator(); }
  241. private:
  242. _Ht _M_ht;
  243. _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
  244. public:
  245. hash_multimap() : _M_ht(0, hasher(), key_equal(), allocator_type()) {}
  246. explicit hash_multimap(size_type __n)
  247. : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
  248. hash_multimap(size_type __n, const hasher& __hf)
  249. : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
  250. hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
  251. const allocator_type& __a = allocator_type())
  252. : _M_ht(__n, __hf, __eql, __a) {}
  253. #if !defined (_STLP_NO_MOVE_SEMANTIC)
  254. hash_multimap(__move_source<_Self> src)
  255. : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {
  256. }
  257. #endif
  258. #ifdef _STLP_MEMBER_TEMPLATES
  259. template <class _InputIterator>
  260. hash_multimap(_InputIterator __f, _InputIterator __l)
  261. : _M_ht(0, hasher(), key_equal(), allocator_type())
  262. { _M_ht.insert_equal(__f, __l); }
  263. template <class _InputIterator>
  264. hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
  265. : _M_ht(__n, hasher(), key_equal(), allocator_type())
  266. { _M_ht.insert_equal(__f, __l); }
  267. template <class _InputIterator>
  268. hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  269. const hasher& __hf)
  270. : _M_ht(__n, __hf, key_equal(), allocator_type())
  271. { _M_ht.insert_equal(__f, __l); }
  272. # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
  273. template <class _InputIterator>
  274. hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  275. const hasher& __hf, const key_equal& __eql)
  276. : _M_ht(__n, __hf, __eql, allocator_type())
  277. { _M_ht.insert_equal(__f, __l); }
  278. # endif
  279. template <class _InputIterator>
  280. hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
  281. const hasher& __hf, const key_equal& __eql,
  282. const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
  283. : _M_ht(__n, __hf, __eql, __a)
  284. { _M_ht.insert_equal(__f, __l); }
  285. #else
  286. hash_multimap(const value_type* __f, const value_type* __l)
  287. : _M_ht(0, hasher(), key_equal(), allocator_type())
  288. { _M_ht.insert_equal(__f, __l); }
  289. hash_multimap(const value_type* __f, const value_type* __l, size_type __n)
  290. : _M_ht(__n, hasher(), key_equal(), allocator_type())
  291. { _M_ht.insert_equal(__f, __l); }
  292. hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  293. const hasher& __hf)
  294. : _M_ht(__n, __hf, key_equal(), allocator_type())
  295. { _M_ht.insert_equal(__f, __l); }
  296. hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  297. const hasher& __hf, const key_equal& __eql,
  298. const allocator_type& __a = allocator_type())
  299. : _M_ht(__n, __hf, __eql, __a)
  300. { _M_ht.insert_equal(__f, __l); }
  301. hash_multimap(const_iterator __f, const_iterator __l)
  302. : _M_ht(0, hasher(), key_equal(), allocator_type())
  303. { _M_ht.insert_equal(__f, __l); }
  304. hash_multimap(const_iterator __f, const_iterator __l, size_type __n)
  305. : _M_ht(__n, hasher(), key_equal(), allocator_type())
  306. { _M_ht.insert_equal(__f, __l); }
  307. hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  308. const hasher& __hf)
  309. : _M_ht(__n, __hf, key_equal(), allocator_type())
  310. { _M_ht.insert_equal(__f, __l); }
  311. hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  312. const hasher& __hf, const key_equal& __eql,
  313. const allocator_type& __a = allocator_type())
  314. : _M_ht(__n, __hf, __eql, __a)
  315. { _M_ht.insert_equal(__f, __l); }
  316. #endif /*_STLP_MEMBER_TEMPLATES */
  317. public:
  318. size_type size() const { return _M_ht.size(); }
  319. size_type max_size() const { return _M_ht.max_size(); }
  320. bool empty() const { return _M_ht.empty(); }
  321. void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }
  322. #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
  323. void _M_swap_workaround(_Self& __x) { swap(__x); }
  324. #endif
  325. iterator begin() { return _M_ht.begin(); }
  326. iterator end() { return _M_ht.end(); }
  327. const_iterator begin() const { return _M_ht.begin(); }
  328. const_iterator end() const { return _M_ht.end(); }
  329. public:
  330. iterator insert(const value_type& __obj)
  331. { return _M_ht.insert_equal(__obj); }
  332. #ifdef _STLP_MEMBER_TEMPLATES
  333. template <class _InputIterator>
  334. void insert(_InputIterator __f, _InputIterator __l)
  335. { _M_ht.insert_equal(__f,__l); }
  336. #else
  337. void insert(const value_type* __f, const value_type* __l) {
  338. _M_ht.insert_equal(__f,__l);
  339. }
  340. void insert(const_iterator __f, const_iterator __l)
  341. { _M_ht.insert_equal(__f, __l); }
  342. #endif /*_STLP_MEMBER_TEMPLATES */
  343. iterator insert_noresize(const value_type& __obj)
  344. { return _M_ht.insert_equal_noresize(__obj); }
  345. _STLP_TEMPLATE_FOR_CONT_EXT
  346. iterator find(const _KT& __key) { return _M_ht.find(__key); }
  347. _STLP_TEMPLATE_FOR_CONT_EXT
  348. const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }
  349. _STLP_TEMPLATE_FOR_CONT_EXT
  350. size_type count(const _KT& __key) const { return _M_ht.count(__key); }
  351. _STLP_TEMPLATE_FOR_CONT_EXT
  352. pair<iterator, iterator>
  353. equal_range(const _KT& __key) { return _M_ht.equal_range(__key); }
  354. _STLP_TEMPLATE_FOR_CONT_EXT
  355. pair<const_iterator, const_iterator>
  356. equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); }
  357. _STLP_TEMPLATE_FOR_CONT_EXT
  358. size_type erase(const _KT& __key) {return _M_ht.erase(__key); }
  359. void erase(iterator __it) { _M_ht.erase(__it); }
  360. void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
  361. void clear() { _M_ht.clear(); }
  362. public:
  363. void resize(size_type __hint) { _M_ht.resize(__hint); }
  364. size_type bucket_count() const { return _M_ht.bucket_count(); }
  365. size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
  366. size_type elems_in_bucket(size_type __n) const
  367. { return _M_ht.elems_in_bucket(__n); }
  368. };
  369. #define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
  370. #define _STLP_TEMPLATE_CONTAINER hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
  371. #include <stl/_relops_hash_cont.h>
  372. #undef _STLP_TEMPLATE_CONTAINER
  373. #define _STLP_TEMPLATE_CONTAINER hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>
  374. #include <stl/_relops_hash_cont.h>
  375. #undef _STLP_TEMPLATE_CONTAINER
  376. #undef _STLP_TEMPLATE_HEADER
  377. #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
  378. # if !defined (_STLP_NO_MOVE_SEMANTIC)
  379. template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
  380. struct __move_traits<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
  381. _STLP_PRIV __move_traits_help<typename hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
  382. {};
  383. template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
  384. struct __move_traits<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > :
  385. _STLP_PRIV __move_traits_help<typename hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht>
  386. {};
  387. # endif
  388. // Specialization of insert_iterator so that it will work for hash_map
  389. // and hash_multimap.
  390. template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
  391. class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  392. protected:
  393. typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  394. _Container* container;
  395. public:
  396. typedef _Container container_type;
  397. typedef output_iterator_tag iterator_category;
  398. typedef void value_type;
  399. typedef void difference_type;
  400. typedef void pointer;
  401. typedef void reference;
  402. insert_iterator(_Container& __x) : container(&__x) {}
  403. insert_iterator(_Container& __x, typename _Container::iterator)
  404. : container(&__x) {}
  405. insert_iterator<_Container>&
  406. operator=(const typename _Container::value_type& __val) {
  407. container->insert(__val);
  408. return *this;
  409. }
  410. insert_iterator<_Container>& operator*() { return *this; }
  411. insert_iterator<_Container>& operator++() { return *this; }
  412. insert_iterator<_Container>& operator++(int) { return *this; }
  413. };
  414. template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
  415. class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
  416. protected:
  417. typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
  418. _Container* container;
  419. typename _Container::iterator iter;
  420. public:
  421. typedef _Container container_type;
  422. typedef output_iterator_tag iterator_category;
  423. typedef void value_type;
  424. typedef void difference_type;
  425. typedef void pointer;
  426. typedef void reference;
  427. insert_iterator(_Container& __x) : container(&__x) {}
  428. insert_iterator(_Container& __x, typename _Container::iterator)
  429. : container(&__x) {}
  430. insert_iterator<_Container>&
  431. operator=(const typename _Container::value_type& __val) {
  432. container->insert(__val);
  433. return *this;
  434. }
  435. insert_iterator<_Container>& operator*() { return *this; }
  436. insert_iterator<_Container>& operator++() { return *this; }
  437. insert_iterator<_Container>& operator++(int) { return *this; }
  438. };
  439. #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
  440. _STLP_END_NAMESPACE
  441. #endif /* _STLP_INTERNAL_HASH_MAP_H */
  442. // Local Variables:
  443. // mode:C++
  444. // End: