treap_set.hpp 47 KB

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