bs_set.hpp 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2013-2014
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_INTRUSIVE_BS_SET_HPP
  13. #define BOOST_INTRUSIVE_BS_SET_HPP
  14. #include <boost/intrusive/detail/config_begin.hpp>
  15. #include <boost/intrusive/intrusive_fwd.hpp>
  16. #include <boost/intrusive/detail/mpl.hpp>
  17. #include <boost/intrusive/bstree.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. #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  24. template<class ValueTraits, class VoidOrKeyOfValue, class Compare, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
  25. class bs_multiset_impl;
  26. #endif
  27. namespace boost {
  28. namespace intrusive {
  29. //! The class template bs_set is an intrusive container, that mimics most of
  30. //! the interface of std::set as described in the C++ standard.
  31. //!
  32. //! The template parameter \c T is the type to be managed by the container.
  33. //! The user can specify additional options and if no options are provided
  34. //! default options are used.
  35. //!
  36. //! The container supports the following options:
  37. //! \c base_hook<>/member_hook<>/value_traits<>,
  38. //! \c constant_time_size<>, \c size_type<> and
  39. //! \c compare<>.
  40. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  41. template<class T, class ...Options>
  42. #else
  43. template<class ValueTraits, class VoidOrKeyOfValue, class Compare, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
  44. #endif
  45. class bs_set_impl
  46. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  47. : public bstree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder>
  48. #endif
  49. {
  50. /// @cond
  51. typedef bstree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder> tree_type;
  52. BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set_impl)
  53. typedef tree_type implementation_defined;
  54. /// @endcond
  55. public:
  56. typedef typename implementation_defined::value_type value_type;
  57. typedef typename implementation_defined::key_type key_type;
  58. typedef typename implementation_defined::value_traits value_traits;
  59. typedef typename implementation_defined::pointer pointer;
  60. typedef typename implementation_defined::const_pointer const_pointer;
  61. typedef typename implementation_defined::reference reference;
  62. typedef typename implementation_defined::const_reference const_reference;
  63. typedef typename implementation_defined::difference_type difference_type;
  64. typedef typename implementation_defined::size_type size_type;
  65. typedef typename implementation_defined::value_compare value_compare;
  66. typedef typename implementation_defined::key_compare key_compare;
  67. typedef typename implementation_defined::iterator iterator;
  68. typedef typename implementation_defined::const_iterator const_iterator;
  69. typedef typename implementation_defined::reverse_iterator reverse_iterator;
  70. typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
  71. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  72. typedef typename implementation_defined::node_traits node_traits;
  73. typedef typename implementation_defined::node node;
  74. typedef typename implementation_defined::node_ptr node_ptr;
  75. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  76. typedef typename implementation_defined::node_algorithms node_algorithms;
  77. static const bool constant_time_size = tree_type::constant_time_size;
  78. public:
  79. //! @copydoc ::boost::intrusive::bstree::bstree()
  80. bs_set_impl()
  81. : tree_type()
  82. {}
  83. //! @copydoc ::boost::intrusive::bstree::bstree(const key_compare &,const value_traits &)
  84. explicit bs_set_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
  85. : tree_type(cmp, v_traits)
  86. {}
  87. //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
  88. template<class Iterator>
  89. bs_set_impl( Iterator b, Iterator e
  90. , const key_compare &cmp = key_compare()
  91. , const value_traits &v_traits = value_traits())
  92. : tree_type(true, b, e, cmp, v_traits)
  93. {}
  94. //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
  95. bs_set_impl(BOOST_RV_REF(bs_set_impl) x)
  96. : tree_type(BOOST_MOVE_BASE(tree_type, x))
  97. {}
  98. //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
  99. bs_set_impl& operator=(BOOST_RV_REF(bs_set_impl) x)
  100. { return static_cast<bs_set_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
  101. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  102. //! @copydoc ::boost::intrusive::bstree::~bstree()
  103. ~bs_set_impl();
  104. //! @copydoc ::boost::intrusive::bstree::begin()
  105. iterator begin();
  106. //! @copydoc ::boost::intrusive::bstree::begin()const
  107. const_iterator begin() const;
  108. //! @copydoc ::boost::intrusive::bstree::cbegin()const
  109. const_iterator cbegin() const;
  110. //! @copydoc ::boost::intrusive::bstree::end()
  111. iterator end();
  112. //! @copydoc ::boost::intrusive::bstree::end()const
  113. const_iterator end() const;
  114. //! @copydoc ::boost::intrusive::bstree::cend()const
  115. const_iterator cend() const;
  116. //! @copydoc ::boost::intrusive::bstree::rbegin()
  117. reverse_iterator rbegin();
  118. //! @copydoc ::boost::intrusive::bstree::rbegin()const
  119. const_reverse_iterator rbegin() const;
  120. //! @copydoc ::boost::intrusive::bstree::crbegin()const
  121. const_reverse_iterator crbegin() const;
  122. //! @copydoc ::boost::intrusive::bstree::rend()
  123. reverse_iterator rend();
  124. //! @copydoc ::boost::intrusive::bstree::rend()const
  125. const_reverse_iterator rend() const;
  126. //! @copydoc ::boost::intrusive::bstree::crend()const
  127. const_reverse_iterator crend() const;
  128. //! @copydoc ::boost::intrusive::bstree::root()
  129. iterator root();
  130. //! @copydoc ::boost::intrusive::bstree::root()const
  131. const_iterator root() const;
  132. //! @copydoc ::boost::intrusive::bstree::croot()const
  133. const_iterator croot() const;
  134. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
  135. static bs_set_impl &container_from_end_iterator(iterator end_iterator);
  136. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
  137. static const bs_set_impl &container_from_end_iterator(const_iterator end_iterator);
  138. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
  139. static bs_set_impl &container_from_iterator(iterator it);
  140. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
  141. static const bs_set_impl &container_from_iterator(const_iterator it);
  142. //! @copydoc ::boost::intrusive::bstree::key_comp()const
  143. key_compare key_comp() const;
  144. //! @copydoc ::boost::intrusive::bstree::value_comp()const
  145. value_compare value_comp() const;
  146. //! @copydoc ::boost::intrusive::bstree::empty()const
  147. bool empty() const;
  148. //! @copydoc ::boost::intrusive::bstree::size()const
  149. size_type size() const;
  150. //! @copydoc ::boost::intrusive::bstree::swap
  151. void swap(bs_set_impl& other);
  152. //! @copydoc ::boost::intrusive::bstree::clone_from(const bstree&,Cloner,Disposer)
  153. template <class Cloner, class Disposer>
  154. void clone_from(const bs_set_impl &src, Cloner cloner, Disposer disposer);
  155. #else
  156. using tree_type::clone_from;
  157. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  158. //! @copydoc ::boost::intrusive::bstree::clone_from(bstree&&,Cloner,Disposer)
  159. template <class Cloner, class Disposer>
  160. void clone_from(BOOST_RV_REF(bs_set_impl) src, Cloner cloner, Disposer disposer)
  161. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  162. //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
  163. std::pair<iterator, bool> insert(reference value)
  164. { return tree_type::insert_unique(value); }
  165. //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
  166. iterator insert(const_iterator hint, reference value)
  167. { return tree_type::insert_unique(hint, value); }
  168. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const key_type&,insert_commit_data&)
  169. std::pair<iterator, bool> insert_check
  170. (const key_type &key, insert_commit_data &commit_data)
  171. { return tree_type::insert_unique_check(key, commit_data); }
  172. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const key_type&,insert_commit_data&)
  173. std::pair<iterator, bool> insert_check
  174. (const_iterator hint, const key_type &key
  175. ,insert_commit_data &commit_data)
  176. { return tree_type::insert_unique_check(hint, key, commit_data); }
  177. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  178. template<class KeyType, class KeyTypeKeyCompare>
  179. std::pair<iterator, bool> insert_check
  180. (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data)
  181. { return tree_type::insert_unique_check(key, comp, commit_data); }
  182. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  183. template<class KeyType, class KeyTypeKeyCompare>
  184. std::pair<iterator, bool> insert_check
  185. (const_iterator hint, const KeyType &key
  186. ,KeyTypeKeyCompare comp, insert_commit_data &commit_data)
  187. { return tree_type::insert_unique_check(hint, key, comp, commit_data); }
  188. //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
  189. template<class Iterator>
  190. void insert(Iterator b, Iterator e)
  191. { tree_type::insert_unique(b, e); }
  192. //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
  193. iterator insert_commit(reference value, const insert_commit_data &commit_data)
  194. { return tree_type::insert_unique_commit(value, commit_data); }
  195. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  196. //! @copydoc ::boost::intrusive::bstree::insert_before
  197. iterator insert_before(const_iterator pos, reference value);
  198. //! @copydoc ::boost::intrusive::bstree::push_back
  199. void push_back(reference value);
  200. //! @copydoc ::boost::intrusive::bstree::push_front
  201. void push_front(reference value);
  202. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
  203. iterator erase(const_iterator i);
  204. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
  205. iterator erase(const_iterator b, const_iterator e);
  206. //! @copydoc ::boost::intrusive::bstree::erase(const key_type &)
  207. size_type erase(const key_type &key);
  208. //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyTypeKeyCompare)
  209. template<class KeyType, class KeyTypeKeyCompare>
  210. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  211. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
  212. template<class Disposer>
  213. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  214. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  215. template<class Disposer>
  216. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  217. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const key_type &, Disposer)
  218. template<class Disposer>
  219. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  220. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  221. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  222. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  223. //! @copydoc ::boost::intrusive::bstree::clear
  224. void clear();
  225. //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
  226. template<class Disposer>
  227. void clear_and_dispose(Disposer disposer);
  228. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  229. //! @copydoc ::boost::intrusive::bstree::count(const key_type &)const
  230. size_type count(const key_type &key) const
  231. { return static_cast<size_type>(this->tree_type::find(key) != this->tree_type::cend()); }
  232. //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyTypeKeyCompare)const
  233. template<class KeyType, class KeyTypeKeyCompare>
  234. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const
  235. { return static_cast<size_type>(this->tree_type::find(key, comp) != this->tree_type::cend()); }
  236. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  237. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)
  238. iterator lower_bound(const key_type &);
  239. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  240. template<class KeyType, class KeyTypeKeyCompare>
  241. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  242. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)const
  243. const_iterator lower_bound(const key_type &key) const;
  244. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  245. template<class KeyType, class KeyTypeKeyCompare>
  246. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  247. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)
  248. iterator upper_bound(const key_type &key);
  249. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  250. template<class KeyType, class KeyTypeKeyCompare>
  251. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  252. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)const
  253. const_iterator upper_bound(const key_type &key) const;
  254. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  255. template<class KeyType, class KeyTypeKeyCompare>
  256. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  257. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)
  258. iterator find(const key_type &key);
  259. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)
  260. template<class KeyType, class KeyTypeKeyCompare>
  261. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  262. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)const
  263. const_iterator find(const key_type &key) const;
  264. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)const
  265. template<class KeyType, class KeyTypeKeyCompare>
  266. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  267. #endif // #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  268. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)
  269. std::pair<iterator,iterator> equal_range(const key_type &key)
  270. { return this->tree_type::lower_bound_range(key); }
  271. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)
  272. template<class KeyType, class KeyTypeKeyCompare>
  273. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp)
  274. { return this->tree_type::equal_range(key, comp); }
  275. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const
  276. std::pair<const_iterator, const_iterator>
  277. equal_range(const key_type &key) const
  278. { return this->tree_type::lower_bound_range(key); }
  279. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  280. template<class KeyType, class KeyTypeKeyCompare>
  281. std::pair<const_iterator, const_iterator>
  282. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const
  283. { return this->tree_type::equal_range(key, comp); }
  284. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  285. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type&,const key_type&,bool,bool)
  286. std::pair<iterator,iterator> bounded_range
  287. (const key_type& lower_key, const key_type& upper_key, bool left_closed, bool right_closed);
  288. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  289. template<class KeyType, class KeyTypeKeyCompare>
  290. std::pair<iterator,iterator> bounded_range
  291. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  292. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type&,const key_type&,bool,bool)const
  293. std::pair<const_iterator, const_iterator>
  294. bounded_range(const key_type& lower_key, const key_type& upper_key, bool left_closed, bool right_closed) const;
  295. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  296. template<class KeyType, class KeyTypeKeyCompare>
  297. std::pair<const_iterator, const_iterator> bounded_range
  298. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  299. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
  300. static iterator s_iterator_to(reference value);
  301. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
  302. static const_iterator s_iterator_to(const_reference value);
  303. //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
  304. iterator iterator_to(reference value);
  305. //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
  306. const_iterator iterator_to(const_reference value) const;
  307. //! @copydoc ::boost::intrusive::bstree::init_node(reference)
  308. static void init_node(reference value);
  309. //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
  310. pointer unlink_leftmost_without_rebalance();
  311. //! @copydoc ::boost::intrusive::bstree::replace_node
  312. void replace_node(iterator replace_this, reference with_this);
  313. //! @copydoc ::boost::intrusive::bstree::remove_node
  314. void remove_node(reference value);
  315. //! @copydoc ::boost::intrusive::bstree::merge_unique
  316. template<class ...Options2>
  317. void merge(bs_set<T, Options2...> &source);
  318. //! @copydoc ::boost::intrusive::bstree::merge_unique
  319. template<class ...Options2>
  320. void merge(bs_multiset<T, Options2...> &source);
  321. #else
  322. template<class Compare2>
  323. void merge(bs_set_impl<ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, HeaderHolder> &source)
  324. { return tree_type::merge_unique(source); }
  325. template<class Compare2>
  326. void merge(bs_multiset_impl<ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, HeaderHolder> &source)
  327. { return tree_type::merge_unique(source); }
  328. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  329. };
  330. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  331. template<class T, class ...Options>
  332. bool operator!= (const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
  333. template<class T, class ...Options>
  334. bool operator>(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
  335. template<class T, class ...Options>
  336. bool operator<=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
  337. template<class T, class ...Options>
  338. bool operator>=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
  339. template<class T, class ...Options>
  340. void swap(bs_set_impl<T, Options...> &x, bs_set_impl<T, Options...> &y);
  341. #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  342. //! Helper metafunction to define a \c bs_set that yields to the same type when the
  343. //! same options (either explicitly or implicitly) are used.
  344. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  345. template<class T, class ...Options>
  346. #else
  347. template<class T, class O1 = void, class O2 = void
  348. , class O3 = void, class O4 = void
  349. , class O5 = void, class O6 = void>
  350. #endif
  351. struct make_bs_set
  352. {
  353. /// @cond
  354. typedef typename pack_options
  355. < bstree_defaults,
  356. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  357. O1, O2, O3, O4, O5, O6
  358. #else
  359. Options...
  360. #endif
  361. >::type packed_options;
  362. typedef typename detail::get_value_traits
  363. <T, typename packed_options::proto_value_traits>::type value_traits;
  364. typedef bs_set_impl
  365. < value_traits
  366. , typename packed_options::key_of_value
  367. , typename packed_options::compare
  368. , typename packed_options::size_type
  369. , packed_options::constant_time_size
  370. , typename packed_options::header_holder_type
  371. > implementation_defined;
  372. /// @endcond
  373. typedef implementation_defined type;
  374. };
  375. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  376. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  377. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  378. #else
  379. template<class T, class ...Options>
  380. #endif
  381. class bs_set
  382. : public make_bs_set<T,
  383. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  384. O1, O2, O3, O4, O5, O6
  385. #else
  386. Options...
  387. #endif
  388. >::type
  389. {
  390. typedef typename make_bs_set
  391. <T,
  392. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  393. O1, O2, O3, O4, O5, O6
  394. #else
  395. Options...
  396. #endif
  397. >::type Base;
  398. BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set)
  399. public:
  400. typedef typename Base::value_traits value_traits;
  401. typedef typename Base::key_compare key_compare;
  402. typedef typename Base::iterator iterator;
  403. typedef typename Base::const_iterator const_iterator;
  404. //Assert if passed value traits are compatible with the type
  405. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  406. BOOST_INTRUSIVE_FORCEINLINE bs_set()
  407. : Base()
  408. {}
  409. BOOST_INTRUSIVE_FORCEINLINE explicit bs_set( const key_compare &cmp, const value_traits &v_traits = value_traits())
  410. : Base(cmp, v_traits)
  411. {}
  412. template<class Iterator>
  413. BOOST_INTRUSIVE_FORCEINLINE bs_set( Iterator b, Iterator e
  414. , const key_compare &cmp = key_compare()
  415. , const value_traits &v_traits = value_traits())
  416. : Base(b, e, cmp, v_traits)
  417. {}
  418. BOOST_INTRUSIVE_FORCEINLINE bs_set(BOOST_RV_REF(bs_set) x)
  419. : Base(BOOST_MOVE_BASE(Base, x))
  420. {}
  421. BOOST_INTRUSIVE_FORCEINLINE bs_set& operator=(BOOST_RV_REF(bs_set) x)
  422. { return static_cast<bs_set &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  423. template <class Cloner, class Disposer>
  424. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const bs_set &src, Cloner cloner, Disposer disposer)
  425. { Base::clone_from(src, cloner, disposer); }
  426. template <class Cloner, class Disposer>
  427. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(bs_set) src, Cloner cloner, Disposer disposer)
  428. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  429. BOOST_INTRUSIVE_FORCEINLINE static bs_set &container_from_end_iterator(iterator end_iterator)
  430. { return static_cast<bs_set &>(Base::container_from_end_iterator(end_iterator)); }
  431. BOOST_INTRUSIVE_FORCEINLINE static const bs_set &container_from_end_iterator(const_iterator end_iterator)
  432. { return static_cast<const bs_set &>(Base::container_from_end_iterator(end_iterator)); }
  433. BOOST_INTRUSIVE_FORCEINLINE static bs_set &container_from_iterator(iterator it)
  434. { return static_cast<bs_set &>(Base::container_from_iterator(it)); }
  435. BOOST_INTRUSIVE_FORCEINLINE static const bs_set &container_from_iterator(const_iterator it)
  436. { return static_cast<const bs_set &>(Base::container_from_iterator(it)); }
  437. };
  438. #endif
  439. //! The class template bs_multiset is an intrusive container, that mimics most of
  440. //! the interface of std::multiset as described in the C++ standard.
  441. //!
  442. //! The template parameter \c T is the type to be managed by the container.
  443. //! The user can specify additional options and if no options are provided
  444. //! default options are used.
  445. //!
  446. //! The container supports the following options:
  447. //! \c base_hook<>/member_hook<>/value_traits<>,
  448. //! \c constant_time_size<>, \c size_type<> and
  449. //! \c compare<>.
  450. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  451. template<class T, class ...Options>
  452. #else
  453. template<class ValueTraits, class VoidOrKeyOfValue, class Compare, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
  454. #endif
  455. class bs_multiset_impl
  456. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  457. : public bstree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder>
  458. #endif
  459. {
  460. /// @cond
  461. typedef bstree_impl<ValueTraits, VoidOrKeyOfValue, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder> tree_type;
  462. BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset_impl)
  463. typedef tree_type implementation_defined;
  464. /// @endcond
  465. public:
  466. typedef typename implementation_defined::value_type value_type;
  467. typedef typename implementation_defined::key_type key_type;
  468. typedef typename implementation_defined::value_traits value_traits;
  469. typedef typename implementation_defined::pointer pointer;
  470. typedef typename implementation_defined::const_pointer const_pointer;
  471. typedef typename implementation_defined::reference reference;
  472. typedef typename implementation_defined::const_reference const_reference;
  473. typedef typename implementation_defined::difference_type difference_type;
  474. typedef typename implementation_defined::size_type size_type;
  475. typedef typename implementation_defined::value_compare value_compare;
  476. typedef typename implementation_defined::key_compare key_compare;
  477. typedef typename implementation_defined::iterator iterator;
  478. typedef typename implementation_defined::const_iterator const_iterator;
  479. typedef typename implementation_defined::reverse_iterator reverse_iterator;
  480. typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
  481. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  482. typedef typename implementation_defined::node_traits node_traits;
  483. typedef typename implementation_defined::node node;
  484. typedef typename implementation_defined::node_ptr node_ptr;
  485. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  486. typedef typename implementation_defined::node_algorithms node_algorithms;
  487. static const bool constant_time_size = tree_type::constant_time_size;
  488. public:
  489. //! @copydoc ::boost::intrusive::bstree::bstree()
  490. bs_multiset_impl()
  491. : tree_type()
  492. {}
  493. //! @copydoc ::boost::intrusive::bstree::bstree(const key_compare &,const value_traits &)
  494. explicit bs_multiset_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
  495. : tree_type(cmp, v_traits)
  496. {}
  497. //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
  498. template<class Iterator>
  499. bs_multiset_impl( Iterator b, Iterator e
  500. , const key_compare &cmp = key_compare()
  501. , const value_traits &v_traits = value_traits())
  502. : tree_type(false, b, e, cmp, v_traits)
  503. {}
  504. //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
  505. bs_multiset_impl(BOOST_RV_REF(bs_multiset_impl) x)
  506. : tree_type(BOOST_MOVE_BASE(tree_type, x))
  507. {}
  508. //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
  509. bs_multiset_impl& operator=(BOOST_RV_REF(bs_multiset_impl) x)
  510. { return static_cast<bs_multiset_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
  511. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  512. //! @copydoc ::boost::intrusive::bstree::~bstree()
  513. ~bs_multiset_impl();
  514. //! @copydoc ::boost::intrusive::bstree::begin()
  515. iterator begin();
  516. //! @copydoc ::boost::intrusive::bstree::begin()const
  517. const_iterator begin() const;
  518. //! @copydoc ::boost::intrusive::bstree::cbegin()const
  519. const_iterator cbegin() const;
  520. //! @copydoc ::boost::intrusive::bstree::end()
  521. iterator end();
  522. //! @copydoc ::boost::intrusive::bstree::end()const
  523. const_iterator end() const;
  524. //! @copydoc ::boost::intrusive::bstree::cend()const
  525. const_iterator cend() const;
  526. //! @copydoc ::boost::intrusive::bstree::rbegin()
  527. reverse_iterator rbegin();
  528. //! @copydoc ::boost::intrusive::bstree::rbegin()const
  529. const_reverse_iterator rbegin() const;
  530. //! @copydoc ::boost::intrusive::bstree::crbegin()const
  531. const_reverse_iterator crbegin() const;
  532. //! @copydoc ::boost::intrusive::bstree::rend()
  533. reverse_iterator rend();
  534. //! @copydoc ::boost::intrusive::bstree::rend()const
  535. const_reverse_iterator rend() const;
  536. //! @copydoc ::boost::intrusive::bstree::crend()const
  537. const_reverse_iterator crend() const;
  538. //! @copydoc ::boost::intrusive::bstree::root()
  539. iterator root();
  540. //! @copydoc ::boost::intrusive::bstree::root()const
  541. const_iterator root() const;
  542. //! @copydoc ::boost::intrusive::bstree::croot()const
  543. const_iterator croot() const;
  544. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
  545. static bs_multiset_impl &container_from_end_iterator(iterator end_iterator);
  546. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
  547. static const bs_multiset_impl &container_from_end_iterator(const_iterator end_iterator);
  548. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
  549. static bs_multiset_impl &container_from_iterator(iterator it);
  550. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
  551. static const bs_multiset_impl &container_from_iterator(const_iterator it);
  552. //! @copydoc ::boost::intrusive::bstree::key_comp()const
  553. key_compare key_comp() const;
  554. //! @copydoc ::boost::intrusive::bstree::value_comp()const
  555. value_compare value_comp() const;
  556. //! @copydoc ::boost::intrusive::bstree::empty()const
  557. bool empty() const;
  558. //! @copydoc ::boost::intrusive::bstree::size()const
  559. size_type size() const;
  560. //! @copydoc ::boost::intrusive::bstree::swap
  561. void swap(bs_multiset_impl& other);
  562. //! @copydoc ::boost::intrusive::bstree::clone_from(const bstree&,Cloner,Disposer)
  563. template <class Cloner, class Disposer>
  564. void clone_from(const bs_multiset_impl &src, Cloner cloner, Disposer disposer);
  565. #else
  566. using tree_type::clone_from;
  567. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  568. //! @copydoc ::boost::intrusive::bstree::clone_from(bstree&&,Cloner,Disposer)
  569. template <class Cloner, class Disposer>
  570. void clone_from(BOOST_RV_REF(bs_multiset_impl) src, Cloner cloner, Disposer disposer)
  571. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  572. //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
  573. iterator insert(reference value)
  574. { return tree_type::insert_equal(value); }
  575. //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
  576. iterator insert(const_iterator hint, reference value)
  577. { return tree_type::insert_equal(hint, value); }
  578. //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
  579. template<class Iterator>
  580. void insert(Iterator b, Iterator e)
  581. { tree_type::insert_equal(b, e); }
  582. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  583. //! @copydoc ::boost::intrusive::bstree::insert_before
  584. iterator insert_before(const_iterator pos, reference value);
  585. //! @copydoc ::boost::intrusive::bstree::push_back
  586. void push_back(reference value);
  587. //! @copydoc ::boost::intrusive::bstree::push_front
  588. void push_front(reference value);
  589. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
  590. iterator erase(const_iterator i);
  591. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
  592. iterator erase(const_iterator b, const_iterator e);
  593. //! @copydoc ::boost::intrusive::bstree::erase(const key_type &)
  594. size_type erase(const key_type &key);
  595. //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyTypeKeyCompare)
  596. template<class KeyType, class KeyTypeKeyCompare>
  597. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  598. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
  599. template<class Disposer>
  600. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  601. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  602. template<class Disposer>
  603. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  604. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const key_type &, Disposer)
  605. template<class Disposer>
  606. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  607. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  608. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  609. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  610. //! @copydoc ::boost::intrusive::bstree::clear
  611. void clear();
  612. //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
  613. template<class Disposer>
  614. void clear_and_dispose(Disposer disposer);
  615. //! @copydoc ::boost::intrusive::bstree::count(const key_type &)const
  616. size_type count(const key_type &key) const;
  617. //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyTypeKeyCompare)const
  618. template<class KeyType, class KeyTypeKeyCompare>
  619. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const;
  620. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)
  621. iterator lower_bound(const key_type &key);
  622. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  623. template<class KeyType, class KeyTypeKeyCompare>
  624. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  625. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)const
  626. const_iterator lower_bound(const key_type &key) const;
  627. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  628. template<class KeyType, class KeyTypeKeyCompare>
  629. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  630. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)
  631. iterator upper_bound(const key_type &key);
  632. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  633. template<class KeyType, class KeyTypeKeyCompare>
  634. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  635. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)const
  636. const_iterator upper_bound(const key_type &key) const;
  637. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  638. template<class KeyType, class KeyTypeKeyCompare>
  639. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  640. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)
  641. iterator find(const key_type &key);
  642. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)
  643. template<class KeyType, class KeyTypeKeyCompare>
  644. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  645. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)const
  646. const_iterator find(const key_type &key) const;
  647. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)const
  648. template<class KeyType, class KeyTypeKeyCompare>
  649. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  650. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)
  651. std::pair<iterator,iterator> equal_range(const key_type &key);
  652. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)
  653. template<class KeyType, class KeyTypeKeyCompare>
  654. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp);
  655. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const
  656. std::pair<const_iterator, const_iterator>
  657. equal_range(const key_type &key) const;
  658. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  659. template<class KeyType, class KeyTypeKeyCompare>
  660. std::pair<const_iterator, const_iterator>
  661. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const;
  662. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)
  663. std::pair<iterator,iterator> bounded_range
  664. (const key_type & lower_key, const key_type & upper_key, bool left_closed, bool right_closed);
  665. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  666. template<class KeyType, class KeyTypeKeyCompare>
  667. std::pair<iterator,iterator> bounded_range
  668. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  669. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)const
  670. std::pair<const_iterator, const_iterator>
  671. bounded_range(const key_type & lower_key, const key_type & upper_key, bool left_closed, bool right_closed) const;
  672. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  673. template<class KeyType, class KeyTypeKeyCompare>
  674. std::pair<const_iterator, const_iterator> bounded_range
  675. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  676. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
  677. static iterator s_iterator_to(reference value);
  678. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
  679. static const_iterator s_iterator_to(const_reference value);
  680. //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
  681. iterator iterator_to(reference value);
  682. //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
  683. const_iterator iterator_to(const_reference value) const;
  684. //! @copydoc ::boost::intrusive::bstree::init_node(reference)
  685. static void init_node(reference value);
  686. //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
  687. pointer unlink_leftmost_without_rebalance();
  688. //! @copydoc ::boost::intrusive::bstree::replace_node
  689. void replace_node(iterator replace_this, reference with_this);
  690. //! @copydoc ::boost::intrusive::bstree::remove_node
  691. void remove_node(reference value);
  692. //! @copydoc ::boost::intrusive::bstree::merge_equal
  693. template<class ...Options2>
  694. void merge(bs_multiset<T, Options2...> &source);
  695. //! @copydoc ::boost::intrusive::bstree::merge_equal
  696. template<class ...Options2>
  697. void merge(bs_set<T, Options2...> &source);
  698. #else
  699. template<class Compare2>
  700. void merge(bs_multiset_impl<ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, HeaderHolder> &source)
  701. { return tree_type::merge_equal(source); }
  702. template<class Compare2>
  703. void merge(bs_set_impl<ValueTraits, VoidOrKeyOfValue, Compare2, SizeType, ConstantTimeSize, HeaderHolder> &source)
  704. { return tree_type::merge_equal(source); }
  705. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  706. };
  707. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  708. template<class T, class ...Options>
  709. bool operator!= (const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
  710. template<class T, class ...Options>
  711. bool operator>(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
  712. template<class T, class ...Options>
  713. bool operator<=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
  714. template<class T, class ...Options>
  715. bool operator>=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
  716. template<class T, class ...Options>
  717. void swap(bs_multiset_impl<T, Options...> &x, bs_multiset_impl<T, Options...> &y);
  718. #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  719. //! Helper metafunction to define a \c bs_multiset that yields to the same type when the
  720. //! same options (either explicitly or implicitly) are used.
  721. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  722. template<class T, class ...Options>
  723. #else
  724. template<class T, class O1 = void, class O2 = void
  725. , class O3 = void, class O4 = void
  726. , class O5 = void, class O6 = void>
  727. #endif
  728. struct make_bs_multiset
  729. {
  730. /// @cond
  731. typedef typename pack_options
  732. < bstree_defaults,
  733. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  734. O1, O2, O3, O4, O5, O6
  735. #else
  736. Options...
  737. #endif
  738. >::type packed_options;
  739. typedef typename detail::get_value_traits
  740. <T, typename packed_options::proto_value_traits>::type value_traits;
  741. typedef bs_multiset_impl
  742. < value_traits
  743. , typename packed_options::key_of_value
  744. , typename packed_options::compare
  745. , typename packed_options::size_type
  746. , packed_options::constant_time_size
  747. , typename packed_options::header_holder_type
  748. > implementation_defined;
  749. /// @endcond
  750. typedef implementation_defined type;
  751. };
  752. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  753. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  754. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  755. #else
  756. template<class T, class ...Options>
  757. #endif
  758. class bs_multiset
  759. : public make_bs_multiset<T,
  760. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  761. O1, O2, O3, O4, O5, O6
  762. #else
  763. Options...
  764. #endif
  765. >::type
  766. {
  767. typedef typename make_bs_multiset<T,
  768. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  769. O1, O2, O3, O4, O5, O6
  770. #else
  771. Options...
  772. #endif
  773. >::type Base;
  774. BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset)
  775. public:
  776. typedef typename Base::key_compare key_compare;
  777. typedef typename Base::value_traits value_traits;
  778. typedef typename Base::iterator iterator;
  779. typedef typename Base::const_iterator const_iterator;
  780. //Assert if passed value traits are compatible with the type
  781. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  782. BOOST_INTRUSIVE_FORCEINLINE bs_multiset()
  783. : Base()
  784. {}
  785. BOOST_INTRUSIVE_FORCEINLINE explicit bs_multiset( const key_compare &cmp, const value_traits &v_traits = value_traits())
  786. : Base(cmp, v_traits)
  787. {}
  788. template<class Iterator>
  789. BOOST_INTRUSIVE_FORCEINLINE bs_multiset( Iterator b, Iterator e
  790. , const key_compare &cmp = key_compare()
  791. , const value_traits &v_traits = value_traits())
  792. : Base(b, e, cmp, v_traits)
  793. {}
  794. BOOST_INTRUSIVE_FORCEINLINE bs_multiset(BOOST_RV_REF(bs_multiset) x)
  795. : Base(BOOST_MOVE_BASE(Base, x))
  796. {}
  797. BOOST_INTRUSIVE_FORCEINLINE bs_multiset& operator=(BOOST_RV_REF(bs_multiset) x)
  798. { return static_cast<bs_multiset &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  799. template <class Cloner, class Disposer>
  800. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const bs_multiset &src, Cloner cloner, Disposer disposer)
  801. { Base::clone_from(src, cloner, disposer); }
  802. template <class Cloner, class Disposer>
  803. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(bs_multiset) src, Cloner cloner, Disposer disposer)
  804. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  805. BOOST_INTRUSIVE_FORCEINLINE static bs_multiset &container_from_end_iterator(iterator end_iterator)
  806. { return static_cast<bs_multiset &>(Base::container_from_end_iterator(end_iterator)); }
  807. BOOST_INTRUSIVE_FORCEINLINE static const bs_multiset &container_from_end_iterator(const_iterator end_iterator)
  808. { return static_cast<const bs_multiset &>(Base::container_from_end_iterator(end_iterator)); }
  809. BOOST_INTRUSIVE_FORCEINLINE static bs_multiset &container_from_iterator(iterator it)
  810. { return static_cast<bs_multiset &>(Base::container_from_iterator(it)); }
  811. BOOST_INTRUSIVE_FORCEINLINE static const bs_multiset &container_from_iterator(const_iterator it)
  812. { return static_cast<const bs_multiset &>(Base::container_from_iterator(it)); }
  813. };
  814. #endif
  815. } //namespace intrusive
  816. } //namespace boost
  817. #include <boost/intrusive/detail/config_end.hpp>
  818. #endif //BOOST_INTRUSIVE_BS_SET_HPP