unordered_set.hpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Olaf Krzikalla 2004-2006.
  4. // (C) Copyright Ion Gaztanaga 2006-2014
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/intrusive for documentation.
  11. //
  12. /////////////////////////////////////////////////////////////////////////////
  13. #ifndef BOOST_INTRUSIVE_UNORDERED_SET_HPP
  14. #define BOOST_INTRUSIVE_UNORDERED_SET_HPP
  15. #include <boost/intrusive/detail/config_begin.hpp>
  16. #include <boost/intrusive/intrusive_fwd.hpp>
  17. #include <boost/intrusive/hashtable.hpp>
  18. #include <boost/move/utility_core.hpp>
  19. #include <boost/static_assert.hpp>
  20. #if defined(BOOST_HAS_PRAGMA_ONCE)
  21. # pragma once
  22. #endif
  23. namespace boost {
  24. namespace intrusive {
  25. //! The class template unordered_set is an intrusive container, that mimics most of
  26. //! the interface of std::tr1::unordered_set as described in the C++ TR1.
  27. //!
  28. //! unordered_set is a semi-intrusive container: each object to be stored in the
  29. //! container must contain a proper hook, but the container also needs
  30. //! additional auxiliary memory to work: unordered_set needs a pointer to an array
  31. //! of type `bucket_type` to be passed in the constructor. This bucket array must
  32. //! have at least the same lifetime as the container. This makes the use of
  33. //! unordered_set more complicated than purely intrusive containers.
  34. //! `bucket_type` is default-constructible, copyable and assignable
  35. //!
  36. //! The template parameter \c T is the type to be managed by the container.
  37. //! The user can specify additional options and if no options are provided
  38. //! default options are used.
  39. //!
  40. //! The container supports the following options:
  41. //! \c base_hook<>/member_hook<>/value_traits<>,
  42. //! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
  43. //! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>.
  44. //!
  45. //! unordered_set only provides forward iterators but it provides 4 iterator types:
  46. //! iterator and const_iterator to navigate through the whole container and
  47. //! local_iterator and const_local_iterator to navigate through the values
  48. //! stored in a single bucket. Local iterators are faster and smaller.
  49. //!
  50. //! It's not recommended to use non constant-time size unordered_sets because several
  51. //! key functions, like "empty()", become non-constant time functions. Non
  52. //! constant-time size unordered_sets are mainly provided to support auto-unlink hooks.
  53. //!
  54. //! unordered_set, unlike std::unordered_set, does not make automatic rehashings nor
  55. //! offers functions related to a load factor. Rehashing can be explicitly requested
  56. //! and the user must provide a new bucket array that will be used from that moment.
  57. //!
  58. //! Since no automatic rehashing is done, iterators are never invalidated when
  59. //! inserting or erasing elements. Iterators are only invalidated when rehasing.
  60. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  61. template<class T, class ...Options>
  62. #else
  63. template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyHash, class VoidOrKeyEqual, class SizeType, class BucketTraits, std::size_t BoolFlags>
  64. #endif
  65. class unordered_set_impl
  66. : public hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags|hash_bool_flags::unique_keys_pos>
  67. {
  68. /// @cond
  69. private:
  70. typedef hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags|hash_bool_flags::unique_keys_pos> table_type;
  71. template<class Iterator, class MaybeConstThis, class KeyType, class KeyHasher, class KeyEqual>
  72. static std::pair<Iterator,Iterator> priv_equal_range(MaybeConstThis &c, const KeyType& key, KeyHasher hash_func, KeyEqual equal_func)
  73. {
  74. Iterator const it = c.find(key, hash_func, equal_func);
  75. std::pair<Iterator,Iterator> ret(it, it);
  76. if(it != c.end())
  77. ++ret.second;
  78. return ret;
  79. }
  80. //! This class is
  81. //! movable
  82. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set_impl)
  83. typedef table_type implementation_defined;
  84. /// @endcond
  85. public:
  86. typedef typename implementation_defined::value_type value_type;
  87. typedef typename implementation_defined::key_type key_type;
  88. typedef typename implementation_defined::key_of_value key_of_value;
  89. typedef typename implementation_defined::value_traits value_traits;
  90. typedef typename implementation_defined::bucket_traits bucket_traits;
  91. typedef typename implementation_defined::pointer pointer;
  92. typedef typename implementation_defined::const_pointer const_pointer;
  93. typedef typename implementation_defined::reference reference;
  94. typedef typename implementation_defined::const_reference const_reference;
  95. typedef typename implementation_defined::difference_type difference_type;
  96. typedef typename implementation_defined::size_type size_type;
  97. typedef typename implementation_defined::key_equal key_equal;
  98. typedef typename implementation_defined::hasher hasher;
  99. typedef typename implementation_defined::bucket_type bucket_type;
  100. typedef typename implementation_defined::bucket_ptr bucket_ptr;
  101. typedef typename implementation_defined::iterator iterator;
  102. typedef typename implementation_defined::const_iterator const_iterator;
  103. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  104. typedef typename implementation_defined::local_iterator local_iterator;
  105. typedef typename implementation_defined::const_local_iterator const_local_iterator;
  106. typedef typename implementation_defined::node_traits node_traits;
  107. typedef typename implementation_defined::node node;
  108. typedef typename implementation_defined::node_ptr node_ptr;
  109. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  110. typedef typename implementation_defined::node_algorithms node_algorithms;
  111. public:
  112. //! @copydoc ::boost::intrusive::hashtable::hashtable(const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  113. BOOST_INTRUSIVE_FORCEINLINE explicit unordered_set_impl( const bucket_traits &b_traits
  114. , const hasher & hash_func = hasher()
  115. , const key_equal &equal_func = key_equal()
  116. , const value_traits &v_traits = value_traits())
  117. : table_type(b_traits, hash_func, equal_func, v_traits)
  118. {}
  119. //! @copydoc ::boost::intrusive::hashtable::hashtable(bool,Iterator,Iterator,const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  120. template<class Iterator>
  121. BOOST_INTRUSIVE_FORCEINLINE unordered_set_impl( Iterator b
  122. , Iterator e
  123. , const bucket_traits &b_traits
  124. , const hasher & hash_func = hasher()
  125. , const key_equal &equal_func = key_equal()
  126. , const value_traits &v_traits = value_traits())
  127. : table_type(true, b, e, b_traits, hash_func, equal_func, v_traits)
  128. {}
  129. //! @copydoc ::boost::intrusive::hashtable::hashtable(hashtable&&)
  130. BOOST_INTRUSIVE_FORCEINLINE unordered_set_impl(BOOST_RV_REF(unordered_set_impl) x)
  131. : table_type(BOOST_MOVE_BASE(table_type, x))
  132. {}
  133. //! @copydoc ::boost::intrusive::hashtable::operator=(hashtable&&)
  134. BOOST_INTRUSIVE_FORCEINLINE unordered_set_impl& operator=(BOOST_RV_REF(unordered_set_impl) x)
  135. { return static_cast<unordered_set_impl&>(table_type::operator=(BOOST_MOVE_BASE(table_type, x))); }
  136. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  137. //! @copydoc ::boost::intrusive::hashtable::~hashtable()
  138. ~unordered_set_impl();
  139. //! @copydoc ::boost::intrusive::hashtable::begin()
  140. iterator begin();
  141. //! @copydoc ::boost::intrusive::hashtable::begin()const
  142. const_iterator begin() const;
  143. //! @copydoc ::boost::intrusive::hashtable::cbegin()const
  144. const_iterator cbegin() const;
  145. //! @copydoc ::boost::intrusive::hashtable::end()
  146. iterator end();
  147. //! @copydoc ::boost::intrusive::hashtable::end()const
  148. const_iterator end() const;
  149. //! @copydoc ::boost::intrusive::hashtable::cend()const
  150. const_iterator cend() const;
  151. //! @copydoc ::boost::intrusive::hashtable::hash_function()const
  152. hasher hash_function() const;
  153. //! @copydoc ::boost::intrusive::hashtable::key_eq()const
  154. key_equal key_eq() const;
  155. //! @copydoc ::boost::intrusive::hashtable::empty()const
  156. bool empty() const;
  157. //! @copydoc ::boost::intrusive::hashtable::size()const
  158. size_type size() const;
  159. //! @copydoc ::boost::intrusive::hashtable::hashtable
  160. void swap(unordered_set_impl& other);
  161. //! @copydoc ::boost::intrusive::hashtable::clone_from(const hashtable&,Cloner,Disposer)
  162. template <class Cloner, class Disposer>
  163. void clone_from(const unordered_set_impl &src, Cloner cloner, Disposer disposer);
  164. #else
  165. using table_type::clone_from;
  166. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  167. //! @copydoc ::boost::intrusive::hashtable::clone_from(hashtable&&,Cloner,Disposer)
  168. template <class Cloner, class Disposer>
  169. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_set_impl) src, Cloner cloner, Disposer disposer)
  170. { table_type::clone_from(BOOST_MOVE_BASE(table_type, src), cloner, disposer); }
  171. //! @copydoc ::boost::intrusive::hashtable::insert_unique(reference)
  172. BOOST_INTRUSIVE_FORCEINLINE std::pair<iterator, bool> insert(reference value)
  173. { return table_type::insert_unique(value); }
  174. //! @copydoc ::boost::intrusive::hashtable::insert_unique(Iterator,Iterator)
  175. template<class Iterator>
  176. BOOST_INTRUSIVE_FORCEINLINE void insert(Iterator b, Iterator e)
  177. { table_type::insert_unique(b, e); }
  178. //! @copydoc ::boost::intrusive::hashtable::insert_unique_check(const key_type&,insert_commit_data&)
  179. BOOST_INTRUSIVE_FORCEINLINE std::pair<iterator, bool> insert_check(const key_type &key, insert_commit_data &commit_data)
  180. { return table_type::insert_unique_check(key, commit_data); }
  181. //! @copydoc ::boost::intrusive::hashtable::insert_unique_check(const KeyType&,KeyHasher,KeyEqual,insert_commit_data&)
  182. template<class KeyType, class KeyHasher, class KeyEqual>
  183. BOOST_INTRUSIVE_FORCEINLINE std::pair<iterator, bool> insert_check
  184. (const KeyType &key, KeyHasher hasher, KeyEqual key_value_equal, insert_commit_data &commit_data)
  185. { return table_type::insert_unique_check(key, hasher, key_value_equal, commit_data); }
  186. //! @copydoc ::boost::intrusive::hashtable::insert_unique_commit
  187. BOOST_INTRUSIVE_FORCEINLINE iterator insert_commit(reference value, const insert_commit_data &commit_data)
  188. { return table_type::insert_unique_commit(value, commit_data); }
  189. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  190. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator)
  191. void erase(const_iterator i);
  192. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator,const_iterator)
  193. void erase(const_iterator b, const_iterator e);
  194. //! @copydoc ::boost::intrusive::hashtable::erase(const key_type &)
  195. size_type erase(const key_type &key);
  196. //! @copydoc ::boost::intrusive::hashtable::erase(const KeyType&,KeyHasher,KeyEqual)
  197. template<class KeyType, class KeyHasher, class KeyEqual>
  198. size_type erase(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  199. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,Disposer)
  200. template<class Disposer>
  201. BOOST_INTRUSIVE_DOC1ST(void
  202. , typename detail::disable_if_convertible<Disposer BOOST_INTRUSIVE_I const_iterator>::type)
  203. erase_and_dispose(const_iterator i, Disposer disposer);
  204. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,const_iterator,Disposer)
  205. template<class Disposer>
  206. void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  207. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const key_type &,Disposer)
  208. template<class Disposer>
  209. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  210. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const KeyType&,KeyHasher,KeyEqual,Disposer)
  211. template<class KeyType, class KeyHasher, class KeyEqual, class Disposer>
  212. size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func, Disposer disposer);
  213. //! @copydoc ::boost::intrusive::hashtable::clear
  214. void clear();
  215. //! @copydoc ::boost::intrusive::hashtable::clear_and_dispose
  216. template<class Disposer>
  217. void clear_and_dispose(Disposer disposer);
  218. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  219. size_type count(const key_type &key) const;
  220. //! @copydoc ::boost::intrusive::hashtable::count(const KeyType&,KeyHasher,KeyEqual)const
  221. template<class KeyType, class KeyHasher, class KeyEqual>
  222. size_type count(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  223. //! @copydoc ::boost::intrusive::hashtable::find(const key_type &)
  224. iterator find(const key_type &key);
  225. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)
  226. template<class KeyType, class KeyHasher, class KeyEqual>
  227. iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  228. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  229. const_iterator find(const key_type &key) const;
  230. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)const
  231. template<class KeyType, class KeyHasher, class KeyEqual>
  232. const_iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  233. #endif
  234. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)
  235. std::pair<iterator,iterator> equal_range(const key_type &key)
  236. { return this->equal_range(key, this->hash_function(), this->key_eq()); }
  237. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)
  238. template<class KeyType, class KeyHasher, class KeyEqual>
  239. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func)
  240. { return this->priv_equal_range<iterator>(*this, key, hash_func, equal_func); }
  241. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)const
  242. std::pair<const_iterator, const_iterator>
  243. equal_range(const key_type &key) const
  244. { return this->equal_range(key, this->hash_function(), this->key_eq()); }
  245. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)const
  246. template<class KeyType, class KeyHasher, class KeyEqual>
  247. std::pair<const_iterator, const_iterator>
  248. equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const
  249. { return this->priv_equal_range<const_iterator>(*this, key, hash_func, equal_func); }
  250. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  251. //! @copydoc ::boost::intrusive::hashtable::iterator_to(reference)
  252. iterator iterator_to(reference value);
  253. //! @copydoc ::boost::intrusive::hashtable::iterator_to(const_reference)const
  254. const_iterator iterator_to(const_reference value) const;
  255. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(reference)
  256. static local_iterator s_local_iterator_to(reference value);
  257. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(const_reference)
  258. static const_local_iterator s_local_iterator_to(const_reference value);
  259. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(reference)
  260. local_iterator local_iterator_to(reference value);
  261. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(const_reference)
  262. const_local_iterator local_iterator_to(const_reference value) const;
  263. //! @copydoc ::boost::intrusive::hashtable::bucket_count
  264. size_type bucket_count() const;
  265. //! @copydoc ::boost::intrusive::hashtable::bucket_size
  266. size_type bucket_size(size_type n) const;
  267. //! @copydoc ::boost::intrusive::hashtable::bucket(const key_type&)const
  268. size_type bucket(const key_type& k) const;
  269. //! @copydoc ::boost::intrusive::hashtable::bucket(const KeyType&,KeyHasher)const
  270. template<class KeyType, class KeyHasher>
  271. size_type bucket(const KeyType& k, KeyHasher hash_func) const;
  272. //! @copydoc ::boost::intrusive::hashtable::bucket_pointer
  273. bucket_ptr bucket_pointer() const;
  274. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)
  275. local_iterator begin(size_type n);
  276. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)const
  277. const_local_iterator begin(size_type n) const;
  278. //! @copydoc ::boost::intrusive::hashtable::cbegin(size_type)const
  279. const_local_iterator cbegin(size_type n) const;
  280. //! @copydoc ::boost::intrusive::hashtable::end(size_type)
  281. local_iterator end(size_type n);
  282. //! @copydoc ::boost::intrusive::hashtable::end(size_type)const
  283. const_local_iterator end(size_type n) const;
  284. //! @copydoc ::boost::intrusive::hashtable::cend(size_type)const
  285. const_local_iterator cend(size_type n) const;
  286. //! @copydoc ::boost::intrusive::hashtable::rehash(const bucket_traits &)
  287. void rehash(const bucket_traits &new_bucket_traits);
  288. //! @copydoc ::boost::intrusive::hashtable::full_rehash
  289. void full_rehash();
  290. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(bool)
  291. bool incremental_rehash(bool grow = true);
  292. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(const bucket_traits &)
  293. bool incremental_rehash(const bucket_traits &new_bucket_traits);
  294. //! @copydoc ::boost::intrusive::hashtable::split_count
  295. size_type split_count() const;
  296. //! @copydoc ::boost::intrusive::hashtable::suggested_upper_bucket_count
  297. static size_type suggested_upper_bucket_count(size_type n);
  298. //! @copydoc ::boost::intrusive::hashtable::suggested_lower_bucket_count
  299. static size_type suggested_lower_bucket_count(size_type n);
  300. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  301. friend bool operator==(const unordered_set_impl &x, const unordered_set_impl &y)
  302. {
  303. if(table_type::constant_time_size && x.size() != y.size()){
  304. return false;
  305. }
  306. //Find each element of x in y
  307. for (const_iterator ix = x.cbegin(), ex = x.cend(), ey = y.cend(); ix != ex; ++ix){
  308. const_iterator iy = y.find(key_of_value()(*ix));
  309. if (iy == ey || !(*ix == *iy))
  310. return false;
  311. }
  312. return true;
  313. }
  314. friend bool operator!=(const unordered_set_impl &x, const unordered_set_impl &y)
  315. { return !(x == y); }
  316. friend bool operator<(const unordered_set_impl &x, const unordered_set_impl &y)
  317. { return ::boost::intrusive::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
  318. friend bool operator>(const unordered_set_impl &x, const unordered_set_impl &y)
  319. { return y < x; }
  320. friend bool operator<=(const unordered_set_impl &x, const unordered_set_impl &y)
  321. { return !(y < x); }
  322. friend bool operator>=(const unordered_set_impl &x, const unordered_set_impl &y)
  323. { return !(x < y); }
  324. };
  325. //! Helper metafunction to define an \c unordered_set that yields to the same type when the
  326. //! same options (either explicitly or implicitly) are used.
  327. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  328. template<class T, class ...Options>
  329. #else
  330. template<class T, class O1 = void, class O2 = void
  331. , class O3 = void, class O4 = void
  332. , class O5 = void, class O6 = void
  333. , class O7 = void, class O8 = void
  334. , class O9 = void, class O10= void
  335. >
  336. #endif
  337. struct make_unordered_set
  338. {
  339. /// @cond
  340. typedef typename pack_options
  341. < hashtable_defaults,
  342. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  343. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  344. #else
  345. Options...
  346. #endif
  347. >::type packed_options;
  348. typedef typename detail::get_value_traits
  349. <T, typename packed_options::proto_value_traits>::type value_traits;
  350. typedef typename make_bucket_traits
  351. <T, true, packed_options>::type bucket_traits;
  352. typedef unordered_set_impl
  353. < value_traits
  354. , typename packed_options::key_of_value
  355. , typename packed_options::hash
  356. , typename packed_options::equal
  357. , typename packed_options::size_type
  358. , bucket_traits
  359. , (std::size_t(true)*hash_bool_flags::unique_keys_pos)
  360. | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
  361. | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
  362. | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
  363. | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
  364. | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
  365. > implementation_defined;
  366. /// @endcond
  367. typedef implementation_defined type;
  368. };
  369. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  370. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  371. template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
  372. #else
  373. template<class T, class ...Options>
  374. #endif
  375. class unordered_set
  376. : public make_unordered_set<T,
  377. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  378. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  379. #else
  380. Options...
  381. #endif
  382. >::type
  383. {
  384. typedef typename make_unordered_set
  385. <T,
  386. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  387. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  388. #else
  389. Options...
  390. #endif
  391. >::type Base;
  392. //Assert if passed value traits are compatible with the type
  393. BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
  394. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_set)
  395. public:
  396. typedef typename Base::value_traits value_traits;
  397. typedef typename Base::bucket_traits bucket_traits;
  398. typedef typename Base::iterator iterator;
  399. typedef typename Base::const_iterator const_iterator;
  400. typedef typename Base::bucket_ptr bucket_ptr;
  401. typedef typename Base::size_type size_type;
  402. typedef typename Base::hasher hasher;
  403. typedef typename Base::key_equal key_equal;
  404. BOOST_INTRUSIVE_FORCEINLINE
  405. explicit unordered_set ( const bucket_traits &b_traits
  406. , const hasher & hash_func = hasher()
  407. , const key_equal &equal_func = key_equal()
  408. , const value_traits &v_traits = value_traits())
  409. : Base(b_traits, hash_func, equal_func, v_traits)
  410. {}
  411. template<class Iterator>
  412. BOOST_INTRUSIVE_FORCEINLINE
  413. unordered_set
  414. ( Iterator b, Iterator e
  415. , const bucket_traits &b_traits
  416. , const hasher & hash_func = hasher()
  417. , const key_equal &equal_func = key_equal()
  418. , const value_traits &v_traits = value_traits())
  419. : Base(b, e, b_traits, hash_func, equal_func, v_traits)
  420. {}
  421. BOOST_INTRUSIVE_FORCEINLINE unordered_set(BOOST_RV_REF(unordered_set) x)
  422. : Base(BOOST_MOVE_BASE(Base, x))
  423. {}
  424. BOOST_INTRUSIVE_FORCEINLINE unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
  425. { return static_cast<unordered_set&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  426. template <class Cloner, class Disposer>
  427. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const unordered_set &src, Cloner cloner, Disposer disposer)
  428. { Base::clone_from(src, cloner, disposer); }
  429. template <class Cloner, class Disposer>
  430. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_set) src, Cloner cloner, Disposer disposer)
  431. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  432. };
  433. #endif
  434. //! The class template unordered_multiset is an intrusive container, that mimics most of
  435. //! the interface of std::tr1::unordered_multiset as described in the C++ TR1.
  436. //!
  437. //! unordered_multiset is a semi-intrusive container: each object to be stored in the
  438. //! container must contain a proper hook, but the container also needs
  439. //! additional auxiliary memory to work: unordered_multiset needs a pointer to an array
  440. //! of type `bucket_type` to be passed in the constructor. This bucket array must
  441. //! have at least the same lifetime as the container. This makes the use of
  442. //! unordered_multiset more complicated than purely intrusive containers.
  443. //! `bucket_type` is default-constructible, copyable and assignable
  444. //!
  445. //! The template parameter \c T is the type to be managed by the container.
  446. //! The user can specify additional options and if no options are provided
  447. //! default options are used.
  448. //!
  449. //! The container supports the following options:
  450. //! \c base_hook<>/member_hook<>/value_traits<>,
  451. //! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
  452. //! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>.
  453. //!
  454. //! unordered_multiset only provides forward iterators but it provides 4 iterator types:
  455. //! iterator and const_iterator to navigate through the whole container and
  456. //! local_iterator and const_local_iterator to navigate through the values
  457. //! stored in a single bucket. Local iterators are faster and smaller.
  458. //!
  459. //! It's not recommended to use non constant-time size unordered_multisets because several
  460. //! key functions, like "empty()", become non-constant time functions. Non
  461. //! constant-time size unordered_multisets are mainly provided to support auto-unlink hooks.
  462. //!
  463. //! unordered_multiset, unlike std::unordered_set, does not make automatic rehashings nor
  464. //! offers functions related to a load factor. Rehashing can be explicitly requested
  465. //! and the user must provide a new bucket array that will be used from that moment.
  466. //!
  467. //! Since no automatic rehashing is done, iterators are never invalidated when
  468. //! inserting or erasing elements. Iterators are only invalidated when rehasing.
  469. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  470. template<class T, class ...Options>
  471. #else
  472. template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyHash, class VoidOrKeyEqual, class SizeType, class BucketTraits, std::size_t BoolFlags>
  473. #endif
  474. class unordered_multiset_impl
  475. : public hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags>
  476. {
  477. /// @cond
  478. private:
  479. typedef hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags> table_type;
  480. /// @endcond
  481. //Movable
  482. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset_impl)
  483. typedef table_type implementation_defined;
  484. public:
  485. typedef typename implementation_defined::value_type value_type;
  486. typedef typename implementation_defined::key_type key_type;
  487. typedef typename implementation_defined::value_traits value_traits;
  488. typedef typename implementation_defined::bucket_traits bucket_traits;
  489. typedef typename implementation_defined::pointer pointer;
  490. typedef typename implementation_defined::const_pointer const_pointer;
  491. typedef typename implementation_defined::reference reference;
  492. typedef typename implementation_defined::const_reference const_reference;
  493. typedef typename implementation_defined::difference_type difference_type;
  494. typedef typename implementation_defined::size_type size_type;
  495. typedef typename implementation_defined::key_equal key_equal;
  496. typedef typename implementation_defined::hasher hasher;
  497. typedef typename implementation_defined::bucket_type bucket_type;
  498. typedef typename implementation_defined::bucket_ptr bucket_ptr;
  499. typedef typename implementation_defined::iterator iterator;
  500. typedef typename implementation_defined::const_iterator const_iterator;
  501. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  502. typedef typename implementation_defined::local_iterator local_iterator;
  503. typedef typename implementation_defined::const_local_iterator const_local_iterator;
  504. typedef typename implementation_defined::node_traits node_traits;
  505. typedef typename implementation_defined::node node;
  506. typedef typename implementation_defined::node_ptr node_ptr;
  507. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  508. typedef typename implementation_defined::node_algorithms node_algorithms;
  509. public:
  510. //! @copydoc ::boost::intrusive::hashtable::hashtable(const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  511. BOOST_INTRUSIVE_FORCEINLINE explicit unordered_multiset_impl ( const bucket_traits &b_traits
  512. , const hasher & hash_func = hasher()
  513. , const key_equal &equal_func = key_equal()
  514. , const value_traits &v_traits = value_traits())
  515. : table_type(b_traits, hash_func, equal_func, v_traits)
  516. {}
  517. //! @copydoc ::boost::intrusive::hashtable::hashtable(bool,Iterator,Iterator,const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  518. template<class Iterator>
  519. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl ( Iterator b
  520. , Iterator e
  521. , const bucket_traits &b_traits
  522. , const hasher & hash_func = hasher()
  523. , const key_equal &equal_func = key_equal()
  524. , const value_traits &v_traits = value_traits())
  525. : table_type(false, b, e, b_traits, hash_func, equal_func, v_traits)
  526. {}
  527. //! <b>Effects</b>: to-do
  528. //!
  529. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl(BOOST_RV_REF(unordered_multiset_impl) x)
  530. : table_type(BOOST_MOVE_BASE(table_type, x))
  531. {}
  532. //! <b>Effects</b>: to-do
  533. //!
  534. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl& operator=(BOOST_RV_REF(unordered_multiset_impl) x)
  535. { return static_cast<unordered_multiset_impl&>(table_type::operator=(BOOST_MOVE_BASE(table_type, x))); }
  536. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  537. //! @copydoc ::boost::intrusive::hashtable::~hashtable()
  538. ~unordered_multiset_impl();
  539. //! @copydoc ::boost::intrusive::hashtable::begin()
  540. iterator begin();
  541. //! @copydoc ::boost::intrusive::hashtable::begin()const
  542. const_iterator begin() const;
  543. //! @copydoc ::boost::intrusive::hashtable::cbegin()const
  544. const_iterator cbegin() const;
  545. //! @copydoc ::boost::intrusive::hashtable::end()
  546. iterator end();
  547. //! @copydoc ::boost::intrusive::hashtable::end()const
  548. const_iterator end() const;
  549. //! @copydoc ::boost::intrusive::hashtable::cend()const
  550. const_iterator cend() const;
  551. //! @copydoc ::boost::intrusive::hashtable::hash_function()const
  552. hasher hash_function() const;
  553. //! @copydoc ::boost::intrusive::hashtable::key_eq()const
  554. key_equal key_eq() const;
  555. //! @copydoc ::boost::intrusive::hashtable::empty()const
  556. bool empty() const;
  557. //! @copydoc ::boost::intrusive::hashtable::size()const
  558. size_type size() const;
  559. //! @copydoc ::boost::intrusive::hashtable::hashtable
  560. void swap(unordered_multiset_impl& other);
  561. //! @copydoc ::boost::intrusive::hashtable::clone_from(const hashtable&,Cloner,Disposer)
  562. template <class Cloner, class Disposer>
  563. void clone_from(const unordered_multiset_impl &src, Cloner cloner, Disposer disposer);
  564. #else
  565. using table_type::clone_from;
  566. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  567. //! @copydoc ::boost::intrusive::hashtable::clone_from(hashtable&&,Cloner,Disposer)
  568. template <class Cloner, class Disposer>
  569. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_multiset_impl) src, Cloner cloner, Disposer disposer)
  570. { table_type::clone_from(BOOST_MOVE_BASE(table_type, src), cloner, disposer); }
  571. //! @copydoc ::boost::intrusive::hashtable::insert_equal(reference)
  572. BOOST_INTRUSIVE_FORCEINLINE iterator insert(reference value)
  573. { return table_type::insert_equal(value); }
  574. //! @copydoc ::boost::intrusive::hashtable::insert_equal(Iterator,Iterator)
  575. template<class Iterator>
  576. BOOST_INTRUSIVE_FORCEINLINE void insert(Iterator b, Iterator e)
  577. { table_type::insert_equal(b, e); }
  578. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  579. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator)
  580. void erase(const_iterator i);
  581. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator,const_iterator)
  582. void erase(const_iterator b, const_iterator e);
  583. //! @copydoc ::boost::intrusive::hashtable::erase(const key_type &)
  584. size_type erase(const key_type &key);
  585. //! @copydoc ::boost::intrusive::hashtable::erase(const KeyType&,KeyHasher,KeyEqual)
  586. template<class KeyType, class KeyHasher, class KeyEqual>
  587. size_type erase(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  588. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,Disposer)
  589. template<class Disposer>
  590. BOOST_INTRUSIVE_DOC1ST(void
  591. , typename detail::disable_if_convertible<Disposer BOOST_INTRUSIVE_I const_iterator>::type)
  592. erase_and_dispose(const_iterator i, Disposer disposer);
  593. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,const_iterator,Disposer)
  594. template<class Disposer>
  595. void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  596. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const key_type &,Disposer)
  597. template<class Disposer>
  598. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  599. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const KeyType&,KeyHasher,KeyEqual,Disposer)
  600. template<class KeyType, class KeyHasher, class KeyEqual, class Disposer>
  601. size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func, Disposer disposer);
  602. //! @copydoc ::boost::intrusive::hashtable::clear
  603. void clear();
  604. //! @copydoc ::boost::intrusive::hashtable::clear_and_dispose
  605. template<class Disposer>
  606. void clear_and_dispose(Disposer disposer);
  607. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  608. size_type count(const key_type &key) const;
  609. //! @copydoc ::boost::intrusive::hashtable::count(const KeyType&,KeyHasher,KeyEqual)const
  610. template<class KeyType, class KeyHasher, class KeyEqual>
  611. size_type count(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  612. //! @copydoc ::boost::intrusive::hashtable::find(const key_type &)
  613. iterator find(const key_type &key);
  614. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)
  615. template<class KeyType, class KeyHasher, class KeyEqual>
  616. iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  617. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  618. const_iterator find(const key_type &key) const;
  619. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)const
  620. template<class KeyType, class KeyHasher, class KeyEqual>
  621. const_iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  622. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)
  623. std::pair<iterator,iterator> equal_range(const key_type &key);
  624. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)
  625. template<class KeyType, class KeyHasher, class KeyEqual>
  626. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  627. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)const
  628. std::pair<const_iterator, const_iterator>
  629. equal_range(const key_type &key) const;
  630. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)const
  631. template<class KeyType, class KeyHasher, class KeyEqual>
  632. std::pair<const_iterator, const_iterator>
  633. equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  634. //! @copydoc ::boost::intrusive::hashtable::iterator_to(reference)
  635. iterator iterator_to(reference value);
  636. //! @copydoc ::boost::intrusive::hashtable::iterator_to(const_reference)const
  637. const_iterator iterator_to(const_reference value) const;
  638. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(reference)
  639. static local_iterator s_local_iterator_to(reference value);
  640. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(const_reference)
  641. static const_local_iterator s_local_iterator_to(const_reference value);
  642. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(reference)
  643. local_iterator local_iterator_to(reference value);
  644. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(const_reference)
  645. const_local_iterator local_iterator_to(const_reference value) const;
  646. //! @copydoc ::boost::intrusive::hashtable::bucket_count
  647. size_type bucket_count() const;
  648. //! @copydoc ::boost::intrusive::hashtable::bucket_size
  649. size_type bucket_size(size_type n) const;
  650. //! @copydoc ::boost::intrusive::hashtable::bucket(const key_type&)const
  651. size_type bucket(const key_type& k) const;
  652. //! @copydoc ::boost::intrusive::hashtable::bucket(const KeyType&,KeyHasher)const
  653. template<class KeyType, class KeyHasher>
  654. size_type bucket(const KeyType& k, KeyHasher hash_func) const;
  655. //! @copydoc ::boost::intrusive::hashtable::bucket_pointer
  656. bucket_ptr bucket_pointer() const;
  657. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)
  658. local_iterator begin(size_type n);
  659. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)const
  660. const_local_iterator begin(size_type n) const;
  661. //! @copydoc ::boost::intrusive::hashtable::cbegin(size_type)const
  662. const_local_iterator cbegin(size_type n) const;
  663. //! @copydoc ::boost::intrusive::hashtable::end(size_type)
  664. local_iterator end(size_type n);
  665. //! @copydoc ::boost::intrusive::hashtable::end(size_type)const
  666. const_local_iterator end(size_type n) const;
  667. //! @copydoc ::boost::intrusive::hashtable::cend(size_type)const
  668. const_local_iterator cend(size_type n) const;
  669. //! @copydoc ::boost::intrusive::hashtable::rehash(const bucket_traits &)
  670. void rehash(const bucket_traits &new_bucket_traits);
  671. //! @copydoc ::boost::intrusive::hashtable::full_rehash
  672. void full_rehash();
  673. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(bool)
  674. bool incremental_rehash(bool grow = true);
  675. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(const bucket_traits &)
  676. bool incremental_rehash(const bucket_traits &new_bucket_traits);
  677. //! @copydoc ::boost::intrusive::hashtable::split_count
  678. size_type split_count() const;
  679. //! @copydoc ::boost::intrusive::hashtable::suggested_upper_bucket_count
  680. static size_type suggested_upper_bucket_count(size_type n);
  681. //! @copydoc ::boost::intrusive::hashtable::suggested_lower_bucket_count
  682. static size_type suggested_lower_bucket_count(size_type n);
  683. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  684. };
  685. //! Helper metafunction to define an \c unordered_multiset that yields to the same type when the
  686. //! same options (either explicitly or implicitly) are used.
  687. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  688. template<class T, class ...Options>
  689. #else
  690. template<class T, class O1 = void, class O2 = void
  691. , class O3 = void, class O4 = void
  692. , class O5 = void, class O6 = void
  693. , class O7 = void, class O8 = void
  694. , class O9 = void, class O10= void
  695. >
  696. #endif
  697. struct make_unordered_multiset
  698. {
  699. /// @cond
  700. typedef typename pack_options
  701. < hashtable_defaults,
  702. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  703. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  704. #else
  705. Options...
  706. #endif
  707. >::type packed_options;
  708. typedef typename detail::get_value_traits
  709. <T, typename packed_options::proto_value_traits>::type value_traits;
  710. typedef typename make_bucket_traits
  711. <T, true, packed_options>::type bucket_traits;
  712. typedef unordered_multiset_impl
  713. < value_traits
  714. , typename packed_options::key_of_value
  715. , typename packed_options::hash
  716. , typename packed_options::equal
  717. , typename packed_options::size_type
  718. , bucket_traits
  719. , (std::size_t(false)*hash_bool_flags::unique_keys_pos)
  720. | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
  721. | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
  722. | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
  723. | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
  724. | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
  725. > implementation_defined;
  726. /// @endcond
  727. typedef implementation_defined type;
  728. };
  729. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  730. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  731. template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
  732. #else
  733. template<class T, class ...Options>
  734. #endif
  735. class unordered_multiset
  736. : public make_unordered_multiset<T,
  737. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  738. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  739. #else
  740. Options...
  741. #endif
  742. >::type
  743. {
  744. typedef typename make_unordered_multiset
  745. <T,
  746. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  747. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  748. #else
  749. Options...
  750. #endif
  751. >::type Base;
  752. //Assert if passed value traits are compatible with the type
  753. BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
  754. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset)
  755. public:
  756. typedef typename Base::value_traits value_traits;
  757. typedef typename Base::bucket_traits bucket_traits;
  758. typedef typename Base::iterator iterator;
  759. typedef typename Base::const_iterator const_iterator;
  760. typedef typename Base::bucket_ptr bucket_ptr;
  761. typedef typename Base::size_type size_type;
  762. typedef typename Base::hasher hasher;
  763. typedef typename Base::key_equal key_equal;
  764. BOOST_INTRUSIVE_FORCEINLINE
  765. explicit unordered_multiset( const bucket_traits &b_traits
  766. , const hasher & hash_func = hasher()
  767. , const key_equal &equal_func = key_equal()
  768. , const value_traits &v_traits = value_traits())
  769. : Base(b_traits, hash_func, equal_func, v_traits)
  770. {}
  771. template<class Iterator>
  772. BOOST_INTRUSIVE_FORCEINLINE
  773. unordered_multiset( Iterator b
  774. , Iterator e
  775. , const bucket_traits &b_traits
  776. , const hasher & hash_func = hasher()
  777. , const key_equal &equal_func = key_equal()
  778. , const value_traits &v_traits = value_traits())
  779. : Base(b, e, b_traits, hash_func, equal_func, v_traits)
  780. {}
  781. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset(BOOST_RV_REF(unordered_multiset) x)
  782. : Base(BOOST_MOVE_BASE(Base, x))
  783. {}
  784. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
  785. { return static_cast<unordered_multiset&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  786. template <class Cloner, class Disposer>
  787. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const unordered_multiset &src, Cloner cloner, Disposer disposer)
  788. { Base::clone_from(src, cloner, disposer); }
  789. template <class Cloner, class Disposer>
  790. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_multiset) src, Cloner cloner, Disposer disposer)
  791. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  792. };
  793. #endif
  794. } //namespace intrusive
  795. } //namespace boost
  796. #include <boost/intrusive/detail/config_end.hpp>
  797. #endif //BOOST_INTRUSIVE_UNORDERED_SET_HPP