unordered_set.hpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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. explicit unordered_set ( const bucket_traits &b_traits
  405. , const hasher & hash_func = hasher()
  406. , const key_equal &equal_func = key_equal()
  407. , const value_traits &v_traits = value_traits())
  408. : Base(b_traits, hash_func, equal_func, v_traits)
  409. {}
  410. template<class Iterator>
  411. BOOST_INTRUSIVE_FORCEINLINE unordered_set
  412. ( Iterator b, Iterator e
  413. , const bucket_traits &b_traits
  414. , const hasher & hash_func = hasher()
  415. , const key_equal &equal_func = key_equal()
  416. , const value_traits &v_traits = value_traits())
  417. : Base(b, e, b_traits, hash_func, equal_func, v_traits)
  418. {}
  419. BOOST_INTRUSIVE_FORCEINLINE unordered_set(BOOST_RV_REF(unordered_set) x)
  420. : Base(BOOST_MOVE_BASE(Base, x))
  421. {}
  422. BOOST_INTRUSIVE_FORCEINLINE unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
  423. { return static_cast<unordered_set&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  424. template <class Cloner, class Disposer>
  425. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const unordered_set &src, Cloner cloner, Disposer disposer)
  426. { Base::clone_from(src, cloner, disposer); }
  427. template <class Cloner, class Disposer>
  428. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_set) src, Cloner cloner, Disposer disposer)
  429. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  430. };
  431. #endif
  432. //! The class template unordered_multiset is an intrusive container, that mimics most of
  433. //! the interface of std::tr1::unordered_multiset as described in the C++ TR1.
  434. //!
  435. //! unordered_multiset is a semi-intrusive container: each object to be stored in the
  436. //! container must contain a proper hook, but the container also needs
  437. //! additional auxiliary memory to work: unordered_multiset needs a pointer to an array
  438. //! of type `bucket_type` to be passed in the constructor. This bucket array must
  439. //! have at least the same lifetime as the container. This makes the use of
  440. //! unordered_multiset more complicated than purely intrusive containers.
  441. //! `bucket_type` is default-constructible, copyable and assignable
  442. //!
  443. //! The template parameter \c T is the type to be managed by the container.
  444. //! The user can specify additional options and if no options are provided
  445. //! default options are used.
  446. //!
  447. //! The container supports the following options:
  448. //! \c base_hook<>/member_hook<>/value_traits<>,
  449. //! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
  450. //! \c bucket_traits<>, \c power_2_buckets<> and \c cache_begin<>.
  451. //!
  452. //! unordered_multiset only provides forward iterators but it provides 4 iterator types:
  453. //! iterator and const_iterator to navigate through the whole container and
  454. //! local_iterator and const_local_iterator to navigate through the values
  455. //! stored in a single bucket. Local iterators are faster and smaller.
  456. //!
  457. //! It's not recommended to use non constant-time size unordered_multisets because several
  458. //! key functions, like "empty()", become non-constant time functions. Non
  459. //! constant-time size unordered_multisets are mainly provided to support auto-unlink hooks.
  460. //!
  461. //! unordered_multiset, unlike std::unordered_set, does not make automatic rehashings nor
  462. //! offers functions related to a load factor. Rehashing can be explicitly requested
  463. //! and the user must provide a new bucket array that will be used from that moment.
  464. //!
  465. //! Since no automatic rehashing is done, iterators are never invalidated when
  466. //! inserting or erasing elements. Iterators are only invalidated when rehasing.
  467. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  468. template<class T, class ...Options>
  469. #else
  470. template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyHash, class VoidOrKeyEqual, class SizeType, class BucketTraits, std::size_t BoolFlags>
  471. #endif
  472. class unordered_multiset_impl
  473. : public hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags>
  474. {
  475. /// @cond
  476. private:
  477. typedef hashtable_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyHash, VoidOrKeyEqual, BucketTraits, SizeType, BoolFlags> table_type;
  478. /// @endcond
  479. //Movable
  480. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset_impl)
  481. typedef table_type implementation_defined;
  482. public:
  483. typedef typename implementation_defined::value_type value_type;
  484. typedef typename implementation_defined::key_type key_type;
  485. typedef typename implementation_defined::value_traits value_traits;
  486. typedef typename implementation_defined::bucket_traits bucket_traits;
  487. typedef typename implementation_defined::pointer pointer;
  488. typedef typename implementation_defined::const_pointer const_pointer;
  489. typedef typename implementation_defined::reference reference;
  490. typedef typename implementation_defined::const_reference const_reference;
  491. typedef typename implementation_defined::difference_type difference_type;
  492. typedef typename implementation_defined::size_type size_type;
  493. typedef typename implementation_defined::key_equal key_equal;
  494. typedef typename implementation_defined::hasher hasher;
  495. typedef typename implementation_defined::bucket_type bucket_type;
  496. typedef typename implementation_defined::bucket_ptr bucket_ptr;
  497. typedef typename implementation_defined::iterator iterator;
  498. typedef typename implementation_defined::const_iterator const_iterator;
  499. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  500. typedef typename implementation_defined::local_iterator local_iterator;
  501. typedef typename implementation_defined::const_local_iterator const_local_iterator;
  502. typedef typename implementation_defined::node_traits node_traits;
  503. typedef typename implementation_defined::node node;
  504. typedef typename implementation_defined::node_ptr node_ptr;
  505. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  506. typedef typename implementation_defined::node_algorithms node_algorithms;
  507. public:
  508. //! @copydoc ::boost::intrusive::hashtable::hashtable(const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  509. BOOST_INTRUSIVE_FORCEINLINE explicit unordered_multiset_impl ( const bucket_traits &b_traits
  510. , const hasher & hash_func = hasher()
  511. , const key_equal &equal_func = key_equal()
  512. , const value_traits &v_traits = value_traits())
  513. : table_type(b_traits, hash_func, equal_func, v_traits)
  514. {}
  515. //! @copydoc ::boost::intrusive::hashtable::hashtable(bool,Iterator,Iterator,const bucket_traits &,const hasher &,const key_equal &,const value_traits &)
  516. template<class Iterator>
  517. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl ( Iterator b
  518. , Iterator e
  519. , const bucket_traits &b_traits
  520. , const hasher & hash_func = hasher()
  521. , const key_equal &equal_func = key_equal()
  522. , const value_traits &v_traits = value_traits())
  523. : table_type(false, b, e, b_traits, hash_func, equal_func, v_traits)
  524. {}
  525. //! <b>Effects</b>: to-do
  526. //!
  527. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl(BOOST_RV_REF(unordered_multiset_impl) x)
  528. : table_type(BOOST_MOVE_BASE(table_type, x))
  529. {}
  530. //! <b>Effects</b>: to-do
  531. //!
  532. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset_impl& operator=(BOOST_RV_REF(unordered_multiset_impl) x)
  533. { return static_cast<unordered_multiset_impl&>(table_type::operator=(BOOST_MOVE_BASE(table_type, x))); }
  534. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  535. //! @copydoc ::boost::intrusive::hashtable::~hashtable()
  536. ~unordered_multiset_impl();
  537. //! @copydoc ::boost::intrusive::hashtable::begin()
  538. iterator begin();
  539. //! @copydoc ::boost::intrusive::hashtable::begin()const
  540. const_iterator begin() const;
  541. //! @copydoc ::boost::intrusive::hashtable::cbegin()const
  542. const_iterator cbegin() const;
  543. //! @copydoc ::boost::intrusive::hashtable::end()
  544. iterator end();
  545. //! @copydoc ::boost::intrusive::hashtable::end()const
  546. const_iterator end() const;
  547. //! @copydoc ::boost::intrusive::hashtable::cend()const
  548. const_iterator cend() const;
  549. //! @copydoc ::boost::intrusive::hashtable::hash_function()const
  550. hasher hash_function() const;
  551. //! @copydoc ::boost::intrusive::hashtable::key_eq()const
  552. key_equal key_eq() const;
  553. //! @copydoc ::boost::intrusive::hashtable::empty()const
  554. bool empty() const;
  555. //! @copydoc ::boost::intrusive::hashtable::size()const
  556. size_type size() const;
  557. //! @copydoc ::boost::intrusive::hashtable::hashtable
  558. void swap(unordered_multiset_impl& other);
  559. //! @copydoc ::boost::intrusive::hashtable::clone_from(const hashtable&,Cloner,Disposer)
  560. template <class Cloner, class Disposer>
  561. void clone_from(const unordered_multiset_impl &src, Cloner cloner, Disposer disposer);
  562. #else
  563. using table_type::clone_from;
  564. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  565. //! @copydoc ::boost::intrusive::hashtable::clone_from(hashtable&&,Cloner,Disposer)
  566. template <class Cloner, class Disposer>
  567. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_multiset_impl) src, Cloner cloner, Disposer disposer)
  568. { table_type::clone_from(BOOST_MOVE_BASE(table_type, src), cloner, disposer); }
  569. //! @copydoc ::boost::intrusive::hashtable::insert_equal(reference)
  570. BOOST_INTRUSIVE_FORCEINLINE iterator insert(reference value)
  571. { return table_type::insert_equal(value); }
  572. //! @copydoc ::boost::intrusive::hashtable::insert_equal(Iterator,Iterator)
  573. template<class Iterator>
  574. BOOST_INTRUSIVE_FORCEINLINE void insert(Iterator b, Iterator e)
  575. { table_type::insert_equal(b, e); }
  576. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  577. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator)
  578. void erase(const_iterator i);
  579. //! @copydoc ::boost::intrusive::hashtable::erase(const_iterator,const_iterator)
  580. void erase(const_iterator b, const_iterator e);
  581. //! @copydoc ::boost::intrusive::hashtable::erase(const key_type &)
  582. size_type erase(const key_type &key);
  583. //! @copydoc ::boost::intrusive::hashtable::erase(const KeyType&,KeyHasher,KeyEqual)
  584. template<class KeyType, class KeyHasher, class KeyEqual>
  585. size_type erase(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  586. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,Disposer)
  587. template<class Disposer>
  588. BOOST_INTRUSIVE_DOC1ST(void
  589. , typename detail::disable_if_convertible<Disposer BOOST_INTRUSIVE_I const_iterator>::type)
  590. erase_and_dispose(const_iterator i, Disposer disposer);
  591. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const_iterator,const_iterator,Disposer)
  592. template<class Disposer>
  593. void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  594. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const key_type &,Disposer)
  595. template<class Disposer>
  596. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  597. //! @copydoc ::boost::intrusive::hashtable::erase_and_dispose(const KeyType&,KeyHasher,KeyEqual,Disposer)
  598. template<class KeyType, class KeyHasher, class KeyEqual, class Disposer>
  599. size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func, Disposer disposer);
  600. //! @copydoc ::boost::intrusive::hashtable::clear
  601. void clear();
  602. //! @copydoc ::boost::intrusive::hashtable::clear_and_dispose
  603. template<class Disposer>
  604. void clear_and_dispose(Disposer disposer);
  605. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  606. size_type count(const key_type &key) const;
  607. //! @copydoc ::boost::intrusive::hashtable::count(const KeyType&,KeyHasher,KeyEqual)const
  608. template<class KeyType, class KeyHasher, class KeyEqual>
  609. size_type count(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  610. //! @copydoc ::boost::intrusive::hashtable::find(const key_type &)
  611. iterator find(const key_type &key);
  612. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)
  613. template<class KeyType, class KeyHasher, class KeyEqual>
  614. iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  615. //! @copydoc ::boost::intrusive::hashtable::count(const key_type &)const
  616. const_iterator find(const key_type &key) const;
  617. //! @copydoc ::boost::intrusive::hashtable::find(const KeyType &,KeyHasher,KeyEqual)const
  618. template<class KeyType, class KeyHasher, class KeyEqual>
  619. const_iterator find(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  620. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)
  621. std::pair<iterator,iterator> equal_range(const key_type &key);
  622. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)
  623. template<class KeyType, class KeyHasher, class KeyEqual>
  624. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func);
  625. //! @copydoc ::boost::intrusive::hashtable::equal_range(const key_type&)const
  626. std::pair<const_iterator, const_iterator>
  627. equal_range(const key_type &key) const;
  628. //! @copydoc ::boost::intrusive::hashtable::equal_range(const KeyType &,KeyHasher,KeyEqual)const
  629. template<class KeyType, class KeyHasher, class KeyEqual>
  630. std::pair<const_iterator, const_iterator>
  631. equal_range(const KeyType& key, KeyHasher hash_func, KeyEqual equal_func) const;
  632. //! @copydoc ::boost::intrusive::hashtable::iterator_to(reference)
  633. iterator iterator_to(reference value);
  634. //! @copydoc ::boost::intrusive::hashtable::iterator_to(const_reference)const
  635. const_iterator iterator_to(const_reference value) const;
  636. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(reference)
  637. static local_iterator s_local_iterator_to(reference value);
  638. //! @copydoc ::boost::intrusive::hashtable::s_local_iterator_to(const_reference)
  639. static const_local_iterator s_local_iterator_to(const_reference value);
  640. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(reference)
  641. local_iterator local_iterator_to(reference value);
  642. //! @copydoc ::boost::intrusive::hashtable::local_iterator_to(const_reference)
  643. const_local_iterator local_iterator_to(const_reference value) const;
  644. //! @copydoc ::boost::intrusive::hashtable::bucket_count
  645. size_type bucket_count() const;
  646. //! @copydoc ::boost::intrusive::hashtable::bucket_size
  647. size_type bucket_size(size_type n) const;
  648. //! @copydoc ::boost::intrusive::hashtable::bucket(const key_type&)const
  649. size_type bucket(const key_type& k) const;
  650. //! @copydoc ::boost::intrusive::hashtable::bucket(const KeyType&,KeyHasher)const
  651. template<class KeyType, class KeyHasher>
  652. size_type bucket(const KeyType& k, KeyHasher hash_func) const;
  653. //! @copydoc ::boost::intrusive::hashtable::bucket_pointer
  654. bucket_ptr bucket_pointer() const;
  655. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)
  656. local_iterator begin(size_type n);
  657. //! @copydoc ::boost::intrusive::hashtable::begin(size_type)const
  658. const_local_iterator begin(size_type n) const;
  659. //! @copydoc ::boost::intrusive::hashtable::cbegin(size_type)const
  660. const_local_iterator cbegin(size_type n) const;
  661. //! @copydoc ::boost::intrusive::hashtable::end(size_type)
  662. local_iterator end(size_type n);
  663. //! @copydoc ::boost::intrusive::hashtable::end(size_type)const
  664. const_local_iterator end(size_type n) const;
  665. //! @copydoc ::boost::intrusive::hashtable::cend(size_type)const
  666. const_local_iterator cend(size_type n) const;
  667. //! @copydoc ::boost::intrusive::hashtable::rehash(const bucket_traits &)
  668. void rehash(const bucket_traits &new_bucket_traits);
  669. //! @copydoc ::boost::intrusive::hashtable::full_rehash
  670. void full_rehash();
  671. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(bool)
  672. bool incremental_rehash(bool grow = true);
  673. //! @copydoc ::boost::intrusive::hashtable::incremental_rehash(const bucket_traits &)
  674. bool incremental_rehash(const bucket_traits &new_bucket_traits);
  675. //! @copydoc ::boost::intrusive::hashtable::split_count
  676. size_type split_count() const;
  677. //! @copydoc ::boost::intrusive::hashtable::suggested_upper_bucket_count
  678. static size_type suggested_upper_bucket_count(size_type n);
  679. //! @copydoc ::boost::intrusive::hashtable::suggested_lower_bucket_count
  680. static size_type suggested_lower_bucket_count(size_type n);
  681. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  682. };
  683. //! Helper metafunction to define an \c unordered_multiset that yields to the same type when the
  684. //! same options (either explicitly or implicitly) are used.
  685. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  686. template<class T, class ...Options>
  687. #else
  688. template<class T, class O1 = void, class O2 = void
  689. , class O3 = void, class O4 = void
  690. , class O5 = void, class O6 = void
  691. , class O7 = void, class O8 = void
  692. , class O9 = void, class O10= void
  693. >
  694. #endif
  695. struct make_unordered_multiset
  696. {
  697. /// @cond
  698. typedef typename pack_options
  699. < hashtable_defaults,
  700. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  701. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  702. #else
  703. Options...
  704. #endif
  705. >::type packed_options;
  706. typedef typename detail::get_value_traits
  707. <T, typename packed_options::proto_value_traits>::type value_traits;
  708. typedef typename make_bucket_traits
  709. <T, true, packed_options>::type bucket_traits;
  710. typedef unordered_multiset_impl
  711. < value_traits
  712. , typename packed_options::key_of_value
  713. , typename packed_options::hash
  714. , typename packed_options::equal
  715. , typename packed_options::size_type
  716. , bucket_traits
  717. , (std::size_t(false)*hash_bool_flags::unique_keys_pos)
  718. | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
  719. | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
  720. | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
  721. | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
  722. | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
  723. > implementation_defined;
  724. /// @endcond
  725. typedef implementation_defined type;
  726. };
  727. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  728. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  729. template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
  730. #else
  731. template<class T, class ...Options>
  732. #endif
  733. class unordered_multiset
  734. : public make_unordered_multiset<T,
  735. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  736. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  737. #else
  738. Options...
  739. #endif
  740. >::type
  741. {
  742. typedef typename make_unordered_multiset
  743. <T,
  744. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  745. O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
  746. #else
  747. Options...
  748. #endif
  749. >::type Base;
  750. //Assert if passed value traits are compatible with the type
  751. BOOST_STATIC_ASSERT((detail::is_same<typename Base::value_traits::value_type, T>::value));
  752. BOOST_MOVABLE_BUT_NOT_COPYABLE(unordered_multiset)
  753. public:
  754. typedef typename Base::value_traits value_traits;
  755. typedef typename Base::bucket_traits bucket_traits;
  756. typedef typename Base::iterator iterator;
  757. typedef typename Base::const_iterator const_iterator;
  758. typedef typename Base::bucket_ptr bucket_ptr;
  759. typedef typename Base::size_type size_type;
  760. typedef typename Base::hasher hasher;
  761. typedef typename Base::key_equal key_equal;
  762. explicit unordered_multiset( const bucket_traits &b_traits
  763. , const hasher & hash_func = hasher()
  764. , const key_equal &equal_func = key_equal()
  765. , const value_traits &v_traits = value_traits())
  766. : Base(b_traits, hash_func, equal_func, v_traits)
  767. {}
  768. template<class Iterator> BOOST_INTRUSIVE_FORCEINLINE
  769. unordered_multiset( Iterator b
  770. , Iterator e
  771. , const bucket_traits &b_traits
  772. , const hasher & hash_func = hasher()
  773. , const key_equal &equal_func = key_equal()
  774. , const value_traits &v_traits = value_traits())
  775. : Base(b, e, b_traits, hash_func, equal_func, v_traits)
  776. {}
  777. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset(BOOST_RV_REF(unordered_multiset) x)
  778. : Base(BOOST_MOVE_BASE(Base, x))
  779. {}
  780. BOOST_INTRUSIVE_FORCEINLINE unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
  781. { return static_cast<unordered_multiset&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  782. template <class Cloner, class Disposer>
  783. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const unordered_multiset &src, Cloner cloner, Disposer disposer)
  784. { Base::clone_from(src, cloner, disposer); }
  785. template <class Cloner, class Disposer>
  786. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(unordered_multiset) src, Cloner cloner, Disposer disposer)
  787. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  788. };
  789. #endif
  790. } //namespace intrusive
  791. } //namespace boost
  792. #include <boost/intrusive/detail/config_end.hpp>
  793. #endif //BOOST_INTRUSIVE_UNORDERED_SET_HPP