treap_set.hpp 46 KB

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