splay_set.hpp 47 KB

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