splay_set.hpp 46 KB

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