treap_set.hpp 43 KB

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