avltree.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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::root()
  157. iterator root();
  158. //! @copydoc ::boost::intrusive::bstree::root()const
  159. const_iterator root() const;
  160. //! @copydoc ::boost::intrusive::bstree::croot()const
  161. const_iterator croot() const;
  162. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
  163. static avltree_impl &container_from_end_iterator(iterator end_iterator);
  164. //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
  165. static const avltree_impl &container_from_end_iterator(const_iterator end_iterator);
  166. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
  167. static avltree_impl &container_from_iterator(iterator it);
  168. //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
  169. static const avltree_impl &container_from_iterator(const_iterator it);
  170. //! @copydoc ::boost::intrusive::bstree::key_comp()const
  171. key_compare key_comp() const;
  172. //! @copydoc ::boost::intrusive::bstree::value_comp()const
  173. value_compare value_comp() const;
  174. //! @copydoc ::boost::intrusive::bstree::empty()const
  175. bool empty() const;
  176. //! @copydoc ::boost::intrusive::bstree::size()const
  177. size_type size() const;
  178. //! @copydoc ::boost::intrusive::bstree::swap
  179. void swap(avltree_impl& other);
  180. //! @copydoc ::boost::intrusive::bstree::clone_from(const bstree&,Cloner,Disposer)
  181. template <class Cloner, class Disposer>
  182. void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer);
  183. #else //BOOST_INTRUSIVE_DOXYGEN_INVOKED
  184. using tree_type::clone_from;
  185. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  186. //! @copydoc ::boost::intrusive::bstree::clone_from(bstree&&,Cloner,Disposer)
  187. template <class Cloner, class Disposer>
  188. void clone_from(BOOST_RV_REF(avltree_impl) src, Cloner cloner, Disposer disposer)
  189. { tree_type::clone_from(BOOST_MOVE_BASE(tree_type, src), cloner, disposer); }
  190. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  191. //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
  192. iterator insert_equal(reference value);
  193. //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
  194. iterator insert_equal(const_iterator hint, reference value);
  195. //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
  196. template<class Iterator>
  197. void insert_equal(Iterator b, Iterator e);
  198. //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
  199. std::pair<iterator, bool> insert_unique(reference value);
  200. //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
  201. iterator insert_unique(const_iterator hint, reference value);
  202. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  203. template<class KeyType, class KeyTypeKeyCompare>
  204. std::pair<iterator, bool> insert_unique_check
  205. (const KeyType &key, KeyTypeKeyCompare comp, insert_commit_data &commit_data);
  206. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyTypeKeyCompare,insert_commit_data&)
  207. template<class KeyType, class KeyTypeKeyCompare>
  208. std::pair<iterator, bool> insert_unique_check
  209. (const_iterator hint, const KeyType &key
  210. ,KeyTypeKeyCompare comp, insert_commit_data &commit_data);
  211. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const key_type&,insert_commit_data&)
  212. std::pair<iterator, bool> insert_unique_check
  213. (const key_type &key, insert_commit_data &commit_data);
  214. //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const key_type&,insert_commit_data&)
  215. std::pair<iterator, bool> insert_unique_check
  216. (const_iterator hint, const key_type &key, insert_commit_data &commit_data);
  217. //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
  218. iterator insert_unique_commit(reference value, const insert_commit_data &commit_data);
  219. //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
  220. template<class Iterator>
  221. void insert_unique(Iterator b, Iterator e);
  222. //! @copydoc ::boost::intrusive::bstree::insert_before
  223. iterator insert_before(const_iterator pos, reference value);
  224. //! @copydoc ::boost::intrusive::bstree::push_back
  225. void push_back(reference value);
  226. //! @copydoc ::boost::intrusive::bstree::push_front
  227. void push_front(reference value);
  228. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
  229. iterator erase(const_iterator i);
  230. //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
  231. iterator erase(const_iterator b, const_iterator e);
  232. //! @copydoc ::boost::intrusive::bstree::erase(const key_type &)
  233. size_type erase(const key_type &key);
  234. //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyTypeKeyCompare)
  235. template<class KeyType, class KeyTypeKeyCompare>
  236. size_type erase(const KeyType& key, KeyTypeKeyCompare comp);
  237. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
  238. template<class Disposer>
  239. iterator erase_and_dispose(const_iterator i, Disposer disposer);
  240. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
  241. template<class Disposer>
  242. iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
  243. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const key_type &, Disposer)
  244. template<class Disposer>
  245. size_type erase_and_dispose(const key_type &key, Disposer disposer);
  246. //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyTypeKeyCompare,Disposer)
  247. template<class KeyType, class KeyTypeKeyCompare, class Disposer>
  248. size_type erase_and_dispose(const KeyType& key, KeyTypeKeyCompare comp, Disposer disposer);
  249. //! @copydoc ::boost::intrusive::bstree::clear
  250. void clear();
  251. //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
  252. template<class Disposer>
  253. void clear_and_dispose(Disposer disposer);
  254. //! @copydoc ::boost::intrusive::bstree::count(const key_type &ke)const
  255. size_type count(const key_type &key) const;
  256. //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyTypeKeyCompare)const
  257. template<class KeyType, class KeyTypeKeyCompare>
  258. size_type count(const KeyType& key, KeyTypeKeyCompare comp) const;
  259. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)
  260. iterator lower_bound(const key_type &key);
  261. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)
  262. template<class KeyType, class KeyTypeKeyCompare>
  263. iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp);
  264. //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &)const
  265. const_iterator lower_bound(const key_type &key) const;
  266. //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare)const
  267. template<class KeyType, class KeyTypeKeyCompare>
  268. const_iterator lower_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  269. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &key)
  270. iterator upper_bound(const key_type &key);
  271. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)
  272. template<class KeyType, class KeyTypeKeyCompare>
  273. iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp);
  274. //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &)const
  275. const_iterator upper_bound(const key_type &key) const;
  276. //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare)const
  277. template<class KeyType, class KeyTypeKeyCompare>
  278. const_iterator upper_bound(const KeyType& key, KeyTypeKeyCompare comp) const;
  279. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)
  280. iterator find(const key_type &key);
  281. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)
  282. template<class KeyType, class KeyTypeKeyCompare>
  283. iterator find(const KeyType& key, KeyTypeKeyCompare comp);
  284. //! @copydoc ::boost::intrusive::bstree::find(const key_type &)const
  285. const_iterator find(const key_type &key) const;
  286. //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare)const
  287. template<class KeyType, class KeyTypeKeyCompare>
  288. const_iterator find(const KeyType& key, KeyTypeKeyCompare comp) const;
  289. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)
  290. std::pair<iterator,iterator> equal_range(const key_type &key);
  291. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)
  292. template<class KeyType, class KeyTypeKeyCompare>
  293. std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp);
  294. //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const
  295. std::pair<const_iterator, const_iterator>
  296. equal_range(const key_type &key) const;
  297. //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare)const
  298. template<class KeyType, class KeyTypeKeyCompare>
  299. std::pair<const_iterator, const_iterator>
  300. equal_range(const KeyType& key, KeyTypeKeyCompare comp) const;
  301. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)
  302. std::pair<iterator,iterator> bounded_range
  303. (const key_type &lower, const key_type &upper_key, bool left_closed, bool right_closed);
  304. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)
  305. template<class KeyType, class KeyTypeKeyCompare>
  306. std::pair<iterator,iterator> bounded_range
  307. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed);
  308. //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool)const
  309. std::pair<const_iterator, const_iterator>
  310. bounded_range(const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const;
  311. //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool)const
  312. template<class KeyType, class KeyTypeKeyCompare>
  313. std::pair<const_iterator, const_iterator> bounded_range
  314. (const KeyType& lower_key, const KeyType& upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const;
  315. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
  316. static iterator s_iterator_to(reference value);
  317. //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
  318. static const_iterator s_iterator_to(const_reference value);
  319. //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
  320. iterator iterator_to(reference value);
  321. //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
  322. const_iterator iterator_to(const_reference value) const;
  323. //! @copydoc ::boost::intrusive::bstree::init_node(reference)
  324. static void init_node(reference value);
  325. //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
  326. pointer unlink_leftmost_without_rebalance();
  327. //! @copydoc ::boost::intrusive::bstree::replace_node
  328. void replace_node(iterator replace_this, reference with_this);
  329. //! @copydoc ::boost::intrusive::bstree::remove_node
  330. void remove_node(reference value);
  331. //! @copydoc ::boost::intrusive::bstree::merge_unique(bstree<T, Options2...>&)
  332. template<class T, class ...Options2>
  333. void merge_unique(avltree<T, Options2...> &);
  334. //! @copydoc ::boost::intrusive::bstree::merge_equal(bstree<T, Options2...>&)
  335. template<class T, class ...Options2>
  336. void merge_equal(avltree<T, Options2...> &);
  337. friend bool operator< (const avltree_impl &x, const avltree_impl &y);
  338. friend bool operator==(const avltree_impl &x, const avltree_impl &y);
  339. friend bool operator!= (const avltree_impl &x, const avltree_impl &y);
  340. friend bool operator>(const avltree_impl &x, const avltree_impl &y);
  341. friend bool operator<=(const avltree_impl &x, const avltree_impl &y);
  342. friend bool operator>=(const avltree_impl &x, const avltree_impl &y);
  343. friend void swap(avltree_impl &x, avltree_impl &y);
  344. #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  345. };
  346. //! Helper metafunction to define a \c avltree that yields to the same type when the
  347. //! same options (either explicitly or implicitly) are used.
  348. #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  349. template<class T, class ...Options>
  350. #else
  351. template<class T, class O1 = void, class O2 = void
  352. , class O3 = void, class O4 = void
  353. , class O5 = void, class O6 = void>
  354. #endif
  355. struct make_avltree
  356. {
  357. /// @cond
  358. typedef typename pack_options
  359. < avltree_defaults,
  360. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  361. O1, O2, O3, O4, O5, O6
  362. #else
  363. Options...
  364. #endif
  365. >::type packed_options;
  366. typedef typename detail::get_value_traits
  367. <T, typename packed_options::proto_value_traits>::type value_traits;
  368. typedef avltree_impl
  369. < value_traits
  370. , typename packed_options::key_of_value
  371. , typename packed_options::compare
  372. , typename packed_options::size_type
  373. , packed_options::constant_time_size
  374. , typename packed_options::header_holder_type
  375. > implementation_defined;
  376. /// @endcond
  377. typedef implementation_defined type;
  378. };
  379. #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  380. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  381. template<class T, class O1, class O2, class O3, class O4, class O5, class O6>
  382. #else
  383. template<class T, class ...Options>
  384. #endif
  385. class avltree
  386. : public make_avltree<T,
  387. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  388. O1, O2, O3, O4, O5, O6
  389. #else
  390. Options...
  391. #endif
  392. >::type
  393. {
  394. typedef typename make_avltree
  395. <T,
  396. #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
  397. O1, O2, O3, O4, O5, O6
  398. #else
  399. Options...
  400. #endif
  401. >::type Base;
  402. BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree)
  403. public:
  404. typedef typename Base::key_compare key_compare;
  405. typedef typename Base::value_traits value_traits;
  406. typedef typename Base::iterator iterator;
  407. typedef typename Base::const_iterator const_iterator;
  408. typedef typename Base::reverse_iterator reverse_iterator;
  409. typedef typename Base::const_reverse_iterator const_reverse_iterator;
  410. //Assert if passed value traits are compatible with the type
  411. BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
  412. BOOST_INTRUSIVE_FORCEINLINE avltree()
  413. : Base()
  414. {}
  415. BOOST_INTRUSIVE_FORCEINLINE explicit avltree( const key_compare &cmp, const value_traits &v_traits = value_traits())
  416. : Base(cmp, v_traits)
  417. {}
  418. template<class Iterator>
  419. BOOST_INTRUSIVE_FORCEINLINE avltree( bool unique, Iterator b, Iterator e
  420. , const key_compare &cmp = key_compare()
  421. , const value_traits &v_traits = value_traits())
  422. : Base(unique, b, e, cmp, v_traits)
  423. {}
  424. BOOST_INTRUSIVE_FORCEINLINE avltree(BOOST_RV_REF(avltree) x)
  425. : Base(BOOST_MOVE_BASE(Base, x))
  426. {}
  427. BOOST_INTRUSIVE_FORCEINLINE avltree& operator=(BOOST_RV_REF(avltree) x)
  428. { return static_cast<avltree &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
  429. template <class Cloner, class Disposer>
  430. BOOST_INTRUSIVE_FORCEINLINE void clone_from(const avltree &src, Cloner cloner, Disposer disposer)
  431. { Base::clone_from(src, cloner, disposer); }
  432. template <class Cloner, class Disposer>
  433. BOOST_INTRUSIVE_FORCEINLINE void clone_from(BOOST_RV_REF(avltree) src, Cloner cloner, Disposer disposer)
  434. { Base::clone_from(BOOST_MOVE_BASE(Base, src), cloner, disposer); }
  435. BOOST_INTRUSIVE_FORCEINLINE static avltree &container_from_end_iterator(iterator end_iterator)
  436. { return static_cast<avltree &>(Base::container_from_end_iterator(end_iterator)); }
  437. BOOST_INTRUSIVE_FORCEINLINE static const avltree &container_from_end_iterator(const_iterator end_iterator)
  438. { return static_cast<const avltree &>(Base::container_from_end_iterator(end_iterator)); }
  439. BOOST_INTRUSIVE_FORCEINLINE static avltree &container_from_iterator(iterator it)
  440. { return static_cast<avltree &>(Base::container_from_iterator(it)); }
  441. BOOST_INTRUSIVE_FORCEINLINE static const avltree &container_from_iterator(const_iterator it)
  442. { return static_cast<const avltree &>(Base::container_from_iterator(it)); }
  443. };
  444. #endif
  445. } //namespace intrusive
  446. } //namespace boost
  447. #include <boost/intrusive/detail/config_end.hpp>
  448. #endif //BOOST_INTRUSIVE_AVLTREE_HPP