avl_set.hpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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