avltree.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2007-2013
  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_AVLTREE_HPP
  13. #define BOOST_INTRUSIVE_AVLTREE_HPP
  14. #include <boost/intrusive/detail/config_begin.hpp>
  15. #include <boost/intrusive/intrusive_fwd.hpp>
  16. #include <cstddef>
  17. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>
  18. #include <boost/intrusive/detail/minimal_pair_header.hpp>
  19. #include <boost/static_assert.hpp>
  20. #include <boost/intrusive/avl_set_hook.hpp>
  21. #include <boost/intrusive/detail/avltree_node.hpp>
  22. #include <boost/intrusive/bstree.hpp>
  23. #include <boost/intrusive/detail/tree_node.hpp>
  24. #include <boost/intrusive/detail/ebo_functor_holder.hpp>
  25. #include <boost/intrusive/detail/mpl.hpp>
  26. #include <boost/intrusive/pointer_traits.hpp>
  27. #include <boost/intrusive/detail/get_value_traits.hpp>
  28. #include <boost/intrusive/avltree_algorithms.hpp>
  29. #include <boost/intrusive/link_mode.hpp>
  30. #include <boost/move/utility_core.hpp>
  31. #if defined(BOOST_HAS_PRAGMA_ONCE)
  32. # pragma once
  33. #endif
  34. namespace boost {
  35. namespace intrusive {
  36. /// @cond
  37. struct default_avltree_hook_applier
  38. { template <class T> struct apply{ typedef typename T::default_avltree_hook type; }; };
  39. template<>
  40. struct is_default_hook_tag<default_avltree_hook_applier>
  41. { static const bool value = true; };
  42. struct avltree_defaults
  43. : bstree_defaults
  44. {
  45. typedef default_avltree_hook_applier proto_value_traits;
  46. };
  47. /// @endcond
  48. //! The class template avltree is an intrusive AVL tree container, that
  49. //! is used to construct intrusive avl_set and avl_multiset containers.
  50. //! The no-throw guarantee holds only, if the key_compare object
  51. //! doesn't throw.
  52. //!
  53. //! The template parameter \c T is the type to be managed by the container.
  54. //! The user can specify additional options and if no options are provided
  55. //! default options are used.
  56. //!
  57. //! The container supports the following options:
  58. //! \c base_hook<>/member_hook<>/value_traits<>,
  59. //! \c constant_time_size<>, \c size_type<> and
  60. //! \c compare<>.
  61. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
  62. template<class T, class ...Options>
  63. #else
  64. template<class ValueTraits, class VoidOrKeyOfValue, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
  65. #endif
  66. class avltree_impl
  67. /// @cond
  68. : public bstree_impl<ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, SizeType, ConstantTimeSize, AvlTreeAlgorithms, HeaderHolder>
  69. /// @endcond
  70. {
  71. public:
  72. typedef ValueTraits value_traits;
  73. /// @cond
  74. typedef bstree_impl< ValueTraits, VoidOrKeyOfValue, VoidOrKeyComp, SizeType
  75. , ConstantTimeSize, AvlTreeAlgorithms
  76. , HeaderHolder> tree_type;
  77. typedef tree_type implementation_defined;
  78. /// @endcond
  79. typedef typename implementation_defined::pointer pointer;
  80. typedef typename implementation_defined::const_pointer const_pointer;
  81. typedef typename implementation_defined::value_type value_type;
  82. typedef typename implementation_defined::key_type key_type;
  83. typedef typename implementation_defined::key_of_value key_of_value;
  84. typedef typename implementation_defined::reference reference;
  85. typedef typename implementation_defined::const_reference const_reference;
  86. typedef typename implementation_defined::difference_type difference_type;
  87. typedef typename implementation_defined::size_type size_type;
  88. typedef typename implementation_defined::value_compare value_compare;
  89. typedef typename implementation_defined::key_compare key_compare;
  90. typedef typename implementation_defined::iterator iterator;
  91. typedef typename implementation_defined::const_iterator const_iterator;
  92. typedef typename implementation_defined::reverse_iterator reverse_iterator;
  93. typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
  94. typedef typename implementation_defined::node_traits node_traits;
  95. typedef typename implementation_defined::node node;
  96. typedef typename implementation_defined::node_ptr node_ptr;
  97. typedef typename implementation_defined::const_node_ptr const_node_ptr;
  98. typedef typename implementation_defined::node_algorithms node_algorithms;
  99. static const bool constant_time_size = implementation_defined::constant_time_size;
  100. /// @cond
  101. private:
  102. //noncopyable
  103. BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree_impl)
  104. /// @endcond
  105. public:
  106. typedef typename implementation_defined::insert_commit_data insert_commit_data;
  107. //! @copydoc ::boost::intrusive::bstree::bstree()
  108. avltree_impl()
  109. : tree_type()
  110. {}
  111. //! @copydoc ::boost::intrusive::bstree::bstree(const key_compare &,const value_traits &)
  112. explicit avltree_impl( const key_compare &cmp, const value_traits &v_traits = value_traits())
  113. : tree_type(cmp, v_traits)
  114. {}
  115. //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const key_compare &,const value_traits &)
  116. template<class Iterator>
  117. avltree_impl( bool unique, Iterator b, Iterator e
  118. , const key_compare &cmp = key_compare()
  119. , const value_traits &v_traits = value_traits())
  120. : tree_type(unique, b, e, cmp, v_traits)
  121. {}
  122. //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
  123. avltree_impl(BOOST_RV_REF(avltree_impl) x)
  124. : tree_type(BOOST_MOVE_BASE(tree_type, x))
  125. {}
  126. //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
  127. avltree_impl& operator=(BOOST_RV_REF(avltree_impl) x)
  128. { return static_cast<avltree_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
  129. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  130. //! @copydoc ::boost::intrusive::bstree::~bstree()
  131. ~avltree_impl();
  132. //! @copydoc ::boost::intrusive::bstree::begin()
  133. iterator begin();
  134. //! @copydoc ::boost::intrusive::bstree::begin()const
  135. const_iterator begin() const;
  136. //! @copydoc ::boost::intrusive::bstree::cbegin()const
  137. const_iterator cbegin() const;
  138. //! @copydoc ::boost::intrusive::bstree::end()
  139. iterator end();
  140. //! @copydoc ::boost::intrusive::bstree::end()const
  141. const_iterator end() const;
  142. //! @copydoc ::boost::intrusive::bstree::cend()const
  143. const_iterator cend() const;
  144. //! @copydoc ::boost::intrusive::bstree::rbegin()
  145. reverse_iterator rbegin();
  146. //! @copydoc ::boost::intrusive::bstree::rbegin()const
  147. const_reverse_iterator rbegin() const;
  148. //! @copydoc ::boost::intrusive::bstree::crbegin()const
  149. const_reverse_iterator crbegin() const;
  150. //! @copydoc ::boost::intrusive::bstree::rend()
  151. reverse_iterator rend();
  152. //! @copydoc ::boost::intrusive::bstree::rend()const
  153. const_reverse_iterator rend() const;
  154. //! @copydoc ::boost::intrusive::bstree::crend()const
  155. const_reverse_iterator crend() const;
  156. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
  157. static avltree_impl &container_from_end_iterator(iterator end_iterator);
  158. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
  159. static const avltree_impl &container_from_end_iterator(const_iterator end_iterator);
  160. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
  161. static avltree_impl &container_from_iterator(iterator it);
  162. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
  163. static const avltree_impl &container_from_iterator(const_iterator it);
  164. //! @copydoc ::boost::intrusive::bstree::key_comp()const
  165. key_compare key_comp() const;
  166. //! @copydoc ::boost::intrusive::bstree::value_comp()const
  167. value_compare value_comp() const;
  168. //! @copydoc ::boost::intrusive::bstree::empty()const
  169. bool empty() const;
  170. //! @copydoc ::boost::intrusive::bstree::size()const
  171. size_type size() const;
  172. //! @copydoc ::boost::intrusive::bstree::swap
  173. void swap(avltree_impl& other);
  174. //! @copydoc ::boost::intrusive::bstree::clone_from(const bstree&,Cloner,Disposer)
  175. template <class Cloner, class Disposer>
  176. void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer);
  177. #else //BOOST_INTRUSIVE_DOXYGEN_INVOKED
  178. using tree_type::clone_from;
  179. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  180. //! @copydoc ::boost::intrusive::bstree::clone_from(bstree&&,Cloner,Disposer)
  181. template <class Cloner, class Disposer>
  182. void clone_from(BOOST_RV_REF(avltree_impl) src, Cloner cloner, Disposer disposer)
  183. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  184. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  185. //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
  186. iterator insert_equal(reference value);
  187. //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
  188. iterator insert_equal(const_iterator hint, reference value);
  189. //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
  190. template<class Iterator>
  191. void insert_equal(Iterator b, Iterator e);
  192. //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
  193. std::pair<iterator, bool> insert_unique(reference value);
  194. //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
  195. iterator insert_unique(const_iterator hint, reference value);
  196. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  197. template<class KeyType, class KeyTypeKeyCompare>
  198. std::pair<iterator, bool> insert_unique_check
  199. (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data);
  200. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  201. template<class KeyType, class KeyTypeKeyCompare>
  202. std::pair<iterator, bool> insert_unique_check
  203. (const_iterator hint, const KeyType &key
  204. ,KeyTypeKeyCompare comp, insert_commit_data &commit_data);
  205. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const key_type&,insert_commit_data&)
  206. std::pair<iterator, bool> insert_unique_check
  207. (const key_type &key, insert_commit_data &commit_data);
  208. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const key_type&,insert_commit_data&)
  209. std::pair<iterator, bool> insert_unique_check
  210. (const_iterator hint, const key_type &key, insert_commit_data &commit_data);
  211. //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
  212. iterator insert_unique_commit(reference value, const insert_commit_data &commit_data);
  213. //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
  214. template<class Iterator>
  215. void insert_unique(Iterator b, Iterator e);
  216. //! @copydoc ::boost::intrusive::bstree::insert_before
  217. iterator insert_before(const_iterator pos, reference value);
  218. //! @copydoc ::boost::intrusive::bstree::push_back
  219. void push_back(reference value);
  220. //! @copydoc ::boost::intrusive::bstree::push_front
  221. void push_front(reference value);
  222. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
  223. iterator erase(const_iterator i);
  224. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
  225. iterator erase(const_iterator b, const_iterator e);
  226. //! @copydoc ::boost::intrusive::bstree::erase(const key_type &)
  227. size_type erase(const key_type &key);
  228. //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyTypeKeyCompare)
  229. template<class KeyType, class KeyTypeKeyCompare>
  230. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  231. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
  232. template<class Disposer>
  233. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  234. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  235. template<class Disposer>
  236. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  237. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const key_type &, Disposer)
  238. template<class Disposer>
  239. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  240. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  241. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  242. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  243. //! @copydoc ::boost::intrusive::bstree::clear
  244. void clear();
  245. //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
  246. template<class Disposer>
  247. void clear_and_dispose(Disposer disposer);
  248. //! @copydoc ::boost::intrusive::bstree::count(const key_type &ke)const
  249. size_type count(const key_type &key) const;
  250. //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyTypeKeyCompare)const
  251. template<class KeyType, class KeyTypeKeyCompare>
  252. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const;
  253. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)
  254. iterator lower_bound(const key_type &key);
  255. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  256. template<class KeyType, class KeyTypeKeyCompare>
  257. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  258. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)const
  259. const_iterator lower_bound(const key_type &key) const;
  260. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  261. template<class KeyType, class KeyTypeKeyCompare>
  262. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  263. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &key)
  264. iterator upper_bound(const key_type &key);
  265. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  266. template<class KeyType, class KeyTypeKeyCompare>
  267. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  268. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)const
  269. const_iterator upper_bound(const key_type &key) const;
  270. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  271. template<class KeyType, class KeyTypeKeyCompare>
  272. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  273. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)
  274. iterator find(const key_type &key);
  275. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)
  276. template<class KeyType, class KeyTypeKeyCompare>
  277. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  278. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)const
  279. const_iterator find(const key_type &key) const;
  280. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)const
  281. template<class KeyType, class KeyTypeKeyCompare>
  282. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  283. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)
  284. std::pair<iterator,iterator> equal_range(const key_type &key);
  285. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)
  286. template<class KeyType, class KeyTypeKeyCompare>
  287. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp);
  288. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const
  289. std::pair<const_iterator, const_iterator>
  290. equal_range(const key_type &key) const;
  291. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  292. template<class KeyType, class KeyTypeKeyCompare>
  293. std::pair<const_iterator, const_iterator>
  294. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const;
  295. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)
  296. std::pair<iterator,iterator> bounded_range
  297. (const key_type &lower, const key_type &upper_key, bool left_closed, bool right_closed);
  298. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  299. template<class KeyType, class KeyTypeKeyCompare>
  300. std::pair<iterator,iterator> bounded_range
  301. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  302. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)const
  303. std::pair<const_iterator, const_iterator>
  304. bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
  305. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  306. template<class KeyType, class KeyTypeKeyCompare>
  307. std::pair<const_iterator, const_iterator> bounded_range
  308. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  309. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
  310. static iterator s_iterator_to(reference value);
  311. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
  312. static const_iterator s_iterator_to(const_reference value);
  313. //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
  314. iterator iterator_to(reference value);
  315. //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
  316. const_iterator iterator_to(const_reference value) const;
  317. //! @copydoc ::boost::intrusive::bstree::init_node(reference)
  318. static void init_node(reference value);
  319. //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
  320. pointer unlink_leftmost_without_rebalance();
  321. //! @copydoc ::boost::intrusive::bstree::replace_node
  322. void replace_node(iterator replace_this, reference with_this);
  323. //! @copydoc ::boost::intrusive::bstree::remove_node
  324. void remove_node(reference value);
  325. friend bool operator< (const avltree_impl &x, const avltree_impl &y);
  326. friend bool operator==(const avltree_impl &x, const avltree_impl &y);
  327. friend bool operator!= (const avltree_impl &x, const avltree_impl &y);
  328. friend bool operator>(const avltree_impl &x, const avltree_impl &y);
  329. friend bool operator<=(const avltree_impl &x, const avltree_impl &y);
  330. friend bool operator>=(const avltree_impl &x, const avltree_impl &y);
  331. friend void swap(avltree_impl &x, avltree_impl &y);
  332. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  333. };
  334. //! Helper metafunction to define a \c avltree that yields to the same type when the
  335. //! same options (either explicitly or implicitly) are used.
  336. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  337. template<class T, class ...Options>
  338. #else
  339. template<class T, class O1 = void, class O2 = void
  340. , class O3 = void, class O4 = void
  341. , class O5 = void, class O6 = void>
  342. #endif
  343. struct make_avltree
  344. {
  345. /// @cond
  346. typedef typename pack_options
  347. < avltree_defaults,
  348. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  349. O1, O2, O3, O4, O5, O6
  350. #else
  351. Options...
  352. #endif
  353. >::type packed_options;
  354. typedef typename detail::get_value_traits
  355. <T, typename packed_options::proto_value_traits>::type value_traits;
  356. typedef avltree_impl
  357. < value_traits
  358. , typename packed_options::key_of_value
  359. , typename packed_options::compare
  360. , typename packed_options::size_type
  361. , packed_options::constant_time_size
  362. , typename packed_options::header_holder_type
  363. > implementation_defined;
  364. /// @endcond
  365. typedef implementation_defined type;
  366. };
  367. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  368. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  369. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  370. #else
  371. template<class T, class ...Options>
  372. #endif
  373. class avltree
  374. : public make_avltree<T,
  375. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  376. O1, O2, O3, O4, O5, O6
  377. #else
  378. Options...
  379. #endif
  380. >::type
  381. {
  382. typedef typename make_avltree
  383. <T,
  384. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  385. O1, O2, O3, O4, O5, O6
  386. #else
  387. Options...
  388. #endif
  389. >::type Base;
  390. BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree)
  391. public:
  392. typedef typename Base::key_compare key_compare;
  393. typedef typename Base::value_traits value_traits;
  394. typedef typename Base::iterator iterator;
  395. typedef typename Base::const_iterator const_iterator;
  396. typedef typename Base::reverse_iterator reverse_iterator;
  397. typedef typename Base::const_reverse_iterator const_reverse_iterator;
  398. //Assert if passed value traits are compatible with the type
  399. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  400. avltree()
  401. : Base()
  402. {}
  403. explicit avltree( const key_compare &cmp, const value_traits &v_traits = value_traits())
  404. : Base(cmp, v_traits)
  405. {}
  406. template<class Iterator>
  407. avltree( bool unique, Iterator b, Iterator e
  408. , const key_compare &cmp = key_compare()
  409. , const value_traits &v_traits = value_traits())
  410. : Base(unique, b, e, cmp, v_traits)
  411. {}
  412. avltree(BOOST_RV_REF(avltree) x)
  413. : Base(BOOST_MOVE_BASE(Base, x))
  414. {}
  415. avltree& operator=(BOOST_RV_REF(avltree) x)
  416. { return static_cast<avltree &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  417. template <class Cloner, class Disposer>
  418. void clone_from(const avltree &src, Cloner cloner, Disposer disposer)
  419. { Base::clone_from(src, cloner, disposer); }
  420. template <class Cloner, class Disposer>
  421. void clone_from(BOOST_RV_REF(avltree) src, Cloner cloner, Disposer disposer)
  422. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  423. static avltree &container_from_end_iterator(iterator end_iterator)
  424. { return static_cast<avltree &>(Base::container_from_end_iterator(end_iterator)); }
  425. static const avltree &container_from_end_iterator(const_iterator end_iterator)
  426. { return static_cast<const avltree &>(Base::container_from_end_iterator(end_iterator)); }
  427. static avltree &container_from_iterator(iterator it)
  428. { return static_cast<avltree &>(Base::container_from_iterator(it)); }
  429. static const avltree &container_from_iterator(const_iterator it)
  430. { return static_cast<const avltree &>(Base::container_from_iterator(it)); }
  431. };
  432. #endif
  433. } //namespace intrusive
  434. } //namespace boost
  435. #include <boost/intrusive/detail/config_end.hpp>
  436. #endif //BOOST_INTRUSIVE_AVLTREE_HPP