_hash_set.h 19 KB

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