avl_set.hpp 44 KB

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