bs_set.hpp 45 KB

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