Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/sgtree.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 ///////////////////////////////////////////////////////////////////////////// | 1 ///////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 // (C) Copyright Ion Gaztanaga 2007-2013 | 3 // (C) Copyright Ion Gaztanaga 2007-2014 |
4 // | 4 // |
5 // Distributed under the Boost Software License, Version 1.0. | 5 // Distributed under the Boost Software License, Version 1.0. |
6 // (See accompanying file LICENSE_1_0.txt or copy at | 6 // (See accompanying file LICENSE_1_0.txt or copy at |
7 // http://www.boost.org/LICENSE_1_0.txt) | 7 // http://www.boost.org/LICENSE_1_0.txt) |
8 // | 8 // |
17 | 17 |
18 #ifndef BOOST_INTRUSIVE_SGTREE_HPP | 18 #ifndef BOOST_INTRUSIVE_SGTREE_HPP |
19 #define BOOST_INTRUSIVE_SGTREE_HPP | 19 #define BOOST_INTRUSIVE_SGTREE_HPP |
20 | 20 |
21 #include <boost/intrusive/detail/config_begin.hpp> | 21 #include <boost/intrusive/detail/config_begin.hpp> |
22 #include <algorithm> | 22 #include <boost/intrusive/intrusive_fwd.hpp> |
23 #include <cstddef> | |
24 #include <functional> | |
25 #include <iterator> | |
26 #include <utility> | |
27 #include <cmath> | |
28 #include <cstddef> | |
29 #include <boost/intrusive/detail/assert.hpp> | 23 #include <boost/intrusive/detail/assert.hpp> |
30 #include <boost/static_assert.hpp> | 24 #include <boost/static_assert.hpp> |
31 #include <boost/intrusive/intrusive_fwd.hpp> | |
32 #include <boost/intrusive/bs_set_hook.hpp> | 25 #include <boost/intrusive/bs_set_hook.hpp> |
33 #include <boost/intrusive/bstree.hpp> | 26 #include <boost/intrusive/bstree.hpp> |
34 #include <boost/intrusive/detail/tree_node.hpp> | 27 #include <boost/intrusive/detail/tree_node.hpp> |
35 #include <boost/intrusive/detail/ebo_functor_holder.hpp> | |
36 #include <boost/intrusive/pointer_traits.hpp> | 28 #include <boost/intrusive/pointer_traits.hpp> |
37 #include <boost/intrusive/detail/mpl.hpp> | 29 #include <boost/intrusive/detail/mpl.hpp> |
38 #include <boost/intrusive/detail/utilities.hpp> | 30 #include <boost/intrusive/detail/math.hpp> |
39 #include <boost/intrusive/options.hpp> | 31 #include <boost/intrusive/detail/get_value_traits.hpp> |
40 #include <boost/intrusive/sgtree_algorithms.hpp> | 32 #include <boost/intrusive/sgtree_algorithms.hpp> |
33 #include <boost/intrusive/detail/key_nodeptr_comp.hpp> | |
41 #include <boost/intrusive/link_mode.hpp> | 34 #include <boost/intrusive/link_mode.hpp> |
42 #include <boost/move/move.hpp> | 35 |
36 #include <boost/move/utility_core.hpp> | |
37 #include <boost/move/adl_move_swap.hpp> | |
38 | |
39 #include <cstddef> | |
40 #include <boost/intrusive/detail/minimal_less_equal_header.hpp> | |
41 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair | |
42 #include <cmath> | |
43 #include <cstddef> | |
44 | |
45 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
46 # pragma once | |
47 #endif | |
43 | 48 |
44 namespace boost { | 49 namespace boost { |
45 namespace intrusive { | 50 namespace intrusive { |
46 | 51 |
47 /// @cond | 52 /// @cond |
48 | 53 |
49 namespace detail{ | 54 namespace detail{ |
55 | |
56 ///////////////////////////////////////////////////////////// | |
57 // | |
58 // Halpha for fixed floating_point<false> option | |
59 // | |
60 ///////////////////////////////////////////////////////////// | |
50 | 61 |
51 //! Returns floor(log2(n)/log2(sqrt(2))) -> floor(2*log2(n)) | 62 //! Returns floor(log2(n)/log2(sqrt(2))) -> floor(2*log2(n)) |
52 //! Undefined if N is 0. | 63 //! Undefined if N is 0. |
53 //! | 64 //! |
54 //! This function does not use float point operations. | 65 //! This function does not use float point operations. |
55 inline std::size_t calculate_h_sqrt2 (std::size_t n) | 66 inline std::size_t calculate_h_sqrt2 (std::size_t n) |
56 { | 67 { |
57 std::size_t f_log2 = detail::floor_log2(n); | 68 std::size_t f_log2 = detail::floor_log2(n); |
58 return (2*f_log2) + (n >= detail::sqrt2_pow_2xplus1 (f_log2)); | 69 return (2*f_log2) + static_cast<std::size_t>(n >= detail::sqrt2_pow_2xplus1(f_log2)); |
59 } | 70 } |
60 | 71 |
61 struct h_alpha_sqrt2_t | 72 struct h_alpha_sqrt2_t |
62 { | 73 { |
63 h_alpha_sqrt2_t(void){} | 74 h_alpha_sqrt2_t(void){} |
74 const std::size_t max_tree_size_limit = ((~std::size_t(0))/std::size_t(3)); | 85 const std::size_t max_tree_size_limit = ((~std::size_t(0))/std::size_t(3)); |
75 return max_tree_size > max_tree_size_limit ? max_tree_size/4*3 : max_tree_size*3/4; | 86 return max_tree_size > max_tree_size_limit ? max_tree_size/4*3 : max_tree_size*3/4; |
76 } | 87 } |
77 }; | 88 }; |
78 | 89 |
90 ///////////////////////////////////////////////////////////// | |
91 // | |
92 // Halpha for fixed floating_point<true> option | |
93 // | |
94 ///////////////////////////////////////////////////////////// | |
95 | |
79 struct h_alpha_t | 96 struct h_alpha_t |
80 { | 97 { |
81 explicit h_alpha_t(float inv_minus_logalpha) | 98 explicit h_alpha_t(float inv_minus_logalpha) |
82 : inv_minus_logalpha_(inv_minus_logalpha) | 99 : inv_minus_logalpha_(inv_minus_logalpha) |
83 {} | 100 {} |
84 | 101 |
85 std::size_t operator()(std::size_t n) const | 102 std::size_t operator()(std::size_t n) const |
86 { | 103 { |
87 //Returns floor(log2(1/alpha(n))) -> | 104 //////////////////////////////////////////////////////////// |
88 // floor(log2(n)/log(1/alpha)) -> | 105 // This function must return "floor(log2(1/alpha(n)))" -> |
89 // floor(log2(n)/(-log2(alpha))) | 106 // floor(log2(n)/log(1/alpha)) -> |
90 //return static_cast<std::size_t>(std::log(float(n))*inv_minus_logalpha_); | 107 // floor(log2(n)/-log2(alpha)) |
108 // floor(log2(n)*(1/-log2(alpha))) | |
109 //////////////////////////////////////////////////////////// | |
91 return static_cast<std::size_t>(detail::fast_log2(float(n))*inv_minus_logalpha_); | 110 return static_cast<std::size_t>(detail::fast_log2(float(n))*inv_minus_logalpha_); |
92 } | 111 } |
93 | 112 |
94 private: | 113 private: |
95 //Since the function will be repeatedly called | 114 //Since the function will be repeatedly called |
116 struct alpha_holder | 135 struct alpha_holder |
117 { | 136 { |
118 typedef boost::intrusive::detail::h_alpha_t h_alpha_t; | 137 typedef boost::intrusive::detail::h_alpha_t h_alpha_t; |
119 typedef boost::intrusive::detail::alpha_by_max_size_t multiply_by_alpha_t; | 138 typedef boost::intrusive::detail::alpha_by_max_size_t multiply_by_alpha_t; |
120 | 139 |
121 alpha_holder() : max_tree_size_(0) | 140 alpha_holder() |
122 { set_alpha(0.7f); } | 141 : max_tree_size_() |
142 { set_alpha(0.70711f); } // ~1/sqrt(2) | |
123 | 143 |
124 float get_alpha() const | 144 float get_alpha() const |
125 { return alpha_; } | 145 { return alpha_; } |
126 | 146 |
127 void set_alpha(float alpha) | 147 void set_alpha(float alpha) |
129 alpha_ = alpha; | 149 alpha_ = alpha; |
130 inv_minus_logalpha_ = 1/(-detail::fast_log2(alpha)); | 150 inv_minus_logalpha_ = 1/(-detail::fast_log2(alpha)); |
131 } | 151 } |
132 | 152 |
133 h_alpha_t get_h_alpha_t() const | 153 h_alpha_t get_h_alpha_t() const |
134 { return h_alpha_t(/*alpha_, */inv_minus_logalpha_); } | 154 { return h_alpha_t(inv_minus_logalpha_); } |
135 | 155 |
136 multiply_by_alpha_t get_multiply_by_alpha_t() const | 156 multiply_by_alpha_t get_multiply_by_alpha_t() const |
137 { return multiply_by_alpha_t(alpha_); } | 157 { return multiply_by_alpha_t(alpha_); } |
138 | 158 |
139 protected: | 159 protected: |
149 //without using floating point operations | 169 //without using floating point operations |
150 //Downside: alpha CAN't be changed. | 170 //Downside: alpha CAN't be changed. |
151 typedef boost::intrusive::detail::h_alpha_sqrt2_t h_alpha_t; | 171 typedef boost::intrusive::detail::h_alpha_sqrt2_t h_alpha_t; |
152 typedef boost::intrusive::detail::alpha_0_75_by_max_size_t multiply_by_alpha_t; | 172 typedef boost::intrusive::detail::alpha_0_75_by_max_size_t multiply_by_alpha_t; |
153 | 173 |
174 alpha_holder() | |
175 : max_tree_size_() | |
176 {} | |
177 | |
154 float get_alpha() const | 178 float get_alpha() const |
155 { return 0.70710677f; } | 179 { return 0.70710677f; } |
156 | 180 |
157 void set_alpha(float) | 181 void set_alpha(float) |
158 { //alpha CAN't be changed. | 182 { //alpha CAN't be changed. |
170 | 194 |
171 } //namespace detail{ | 195 } //namespace detail{ |
172 | 196 |
173 struct sgtree_defaults | 197 struct sgtree_defaults |
174 { | 198 { |
175 typedef detail::default_bstree_hook proto_value_traits; | 199 typedef default_bstree_hook_applier proto_value_traits; |
176 static const bool constant_time_size = true; | 200 static const bool constant_time_size = true; |
177 typedef std::size_t size_type; | 201 typedef std::size_t size_type; |
178 typedef void compare; | 202 typedef void compare; |
179 static const bool floating_point = true; | 203 static const bool floating_point = true; |
204 typedef void header_holder_type; | |
180 }; | 205 }; |
181 | 206 |
182 /// @endcond | 207 /// @endcond |
183 | 208 |
184 //! The class template sgtree is an intrusive scapegoat tree container, that | 209 //! The class template sgtree is an intrusive scapegoat tree container, that |
195 //! \c floating_point<>, \c size_type<> and | 220 //! \c floating_point<>, \c size_type<> and |
196 //! \c compare<>. | 221 //! \c compare<>. |
197 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | 222 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) |
198 template<class T, class ...Options> | 223 template<class T, class ...Options> |
199 #else | 224 #else |
200 template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool FloatingPoint> | 225 template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool FloatingPoint, typename HeaderHolder> |
201 #endif | 226 #endif |
202 class sgtree_impl | 227 class sgtree_impl |
203 /// @cond | 228 /// @cond |
204 : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, true, SgTreeAlgorithms> | 229 : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, true, SgTreeAlgorithms, HeaderHolder> |
205 , public detail::alpha_holder<FloatingPoint, SizeType> | 230 , public detail::alpha_holder<FloatingPoint, SizeType> |
206 /// @endcond | 231 /// @endcond |
207 { | 232 { |
208 public: | 233 public: |
209 typedef ValueTraits value_traits; | 234 typedef ValueTraits value_traits; |
210 /// @cond | 235 /// @cond |
211 typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType | 236 typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType |
212 , true, SgTreeAlgorithms> tree_type; | 237 , true, SgTreeAlgorithms, HeaderHolder> tree_type; |
213 typedef tree_type implementation_defined; | 238 typedef tree_type implementation_defined; |
214 typedef typename tree_type::real_value_traits real_value_traits; | |
215 | 239 |
216 /// @endcond | 240 /// @endcond |
217 | 241 |
218 typedef typename implementation_defined::pointer pointer; | 242 typedef typename implementation_defined::pointer pointer; |
219 typedef typename implementation_defined::const_pointer const_pointer; | 243 typedef typename implementation_defined::const_pointer const_pointer; |
246 typedef detail::alpha_holder<FloatingPoint, SizeType> alpha_traits; | 270 typedef detail::alpha_holder<FloatingPoint, SizeType> alpha_traits; |
247 typedef typename alpha_traits::h_alpha_t h_alpha_t; | 271 typedef typename alpha_traits::h_alpha_t h_alpha_t; |
248 typedef typename alpha_traits::multiply_by_alpha_t multiply_by_alpha_t; | 272 typedef typename alpha_traits::multiply_by_alpha_t multiply_by_alpha_t; |
249 | 273 |
250 BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree_impl) | 274 BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree_impl) |
251 BOOST_STATIC_ASSERT(((int)real_value_traits::link_mode != (int)auto_unlink)); | 275 BOOST_STATIC_ASSERT(((int)value_traits::link_mode != (int)auto_unlink)); |
252 | 276 |
253 enum { safemode_or_autounlink = | 277 enum { safemode_or_autounlink = |
254 (int)real_value_traits::link_mode == (int)auto_unlink || | 278 (int)value_traits::link_mode == (int)auto_unlink || |
255 (int)real_value_traits::link_mode == (int)safe_link }; | 279 (int)value_traits::link_mode == (int)safe_link }; |
256 | 280 |
257 /// @endcond | 281 /// @endcond |
258 | 282 |
259 public: | 283 public: |
260 | 284 |
279 this->insert_equal(b, e); | 303 this->insert_equal(b, e); |
280 } | 304 } |
281 | 305 |
282 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) | 306 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&) |
283 sgtree_impl(BOOST_RV_REF(sgtree_impl) x) | 307 sgtree_impl(BOOST_RV_REF(sgtree_impl) x) |
284 : tree_type(::boost::move(static_cast<tree_type&>(x))), alpha_traits(x.get_alpha_traits()) | 308 : tree_type(BOOST_MOVE_BASE(tree_type, x)), alpha_traits(x.get_alpha_traits()) |
285 { std::swap(this->get_alpha_traits(), x.get_alpha_traits()); } | 309 { ::boost::adl_move_swap(this->get_alpha_traits(), x.get_alpha_traits()); } |
286 | 310 |
287 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) | 311 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&) |
288 sgtree_impl& operator=(BOOST_RV_REF(sgtree_impl) x) | 312 sgtree_impl& operator=(BOOST_RV_REF(sgtree_impl) x) |
289 { | 313 { |
290 this->get_alpha_traits() = x.get_alpha_traits(); | 314 this->get_alpha_traits() = x.get_alpha_traits(); |
291 return static_cast<sgtree_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); | 315 return static_cast<sgtree_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); |
292 } | 316 } |
293 | 317 |
294 /// @cond | 318 /// @cond |
295 private: | 319 private: |
296 | 320 |
378 | 402 |
379 //! @copydoc ::boost::intrusive::bstree::swap | 403 //! @copydoc ::boost::intrusive::bstree::swap |
380 void swap(sgtree_impl& other) | 404 void swap(sgtree_impl& other) |
381 { | 405 { |
382 //This can throw | 406 //This can throw |
383 using std::swap; | |
384 this->tree_type::swap(static_cast<tree_type&>(other)); | 407 this->tree_type::swap(static_cast<tree_type&>(other)); |
385 swap(this->get_alpha_traits(), other.get_alpha_traits()); | 408 ::boost::adl_move_swap(this->get_alpha_traits(), other.get_alpha_traits()); |
386 } | 409 } |
387 | 410 |
388 //! @copydoc ::boost::intrusive::bstree::clone_from | 411 //! @copydoc ::boost::intrusive::bstree::clone_from |
389 //! Additional notes: it also copies the alpha factor from the source container. | 412 //! Additional notes: it also copies the alpha factor from the source container. |
390 template <class Cloner, class Disposer> | 413 template <class Cloner, class Disposer> |
395 } | 418 } |
396 | 419 |
397 //! @copydoc ::boost::intrusive::bstree::insert_equal(reference) | 420 //! @copydoc ::boost::intrusive::bstree::insert_equal(reference) |
398 iterator insert_equal(reference value) | 421 iterator insert_equal(reference value) |
399 { | 422 { |
400 detail::key_nodeptr_comp<value_compare, real_value_traits> | 423 detail::key_nodeptr_comp<value_compare, value_traits> |
401 key_node_comp(this->value_comp(), &this->get_real_value_traits()); | 424 key_node_comp(this->value_comp(), &this->get_value_traits()); |
402 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 425 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
403 if(safemode_or_autounlink) | 426 if(safemode_or_autounlink) |
404 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 427 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
405 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 428 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
406 node_ptr p = node_algorithms::insert_equal_upper_bound | 429 node_ptr p = node_algorithms::insert_equal_upper_bound |
407 (this->tree_type::header_ptr(), to_insert, key_node_comp | 430 (this->tree_type::header_ptr(), to_insert, key_node_comp |
408 , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); | 431 , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); |
409 this->tree_type::sz_traits().increment(); | 432 this->tree_type::sz_traits().increment(); |
410 this->max_tree_size_ = (size_type)max_tree_size; | 433 this->max_tree_size_ = (size_type)max_tree_size; |
411 return iterator(p, this->real_value_traits_ptr()); | 434 return iterator(p, this->priv_value_traits_ptr()); |
412 } | 435 } |
413 | 436 |
414 //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference) | 437 //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference) |
415 iterator insert_equal(const_iterator hint, reference value) | 438 iterator insert_equal(const_iterator hint, reference value) |
416 { | 439 { |
417 detail::key_nodeptr_comp<value_compare, real_value_traits> | 440 detail::key_nodeptr_comp<value_compare, value_traits> |
418 key_node_comp(this->value_comp(), &this->get_real_value_traits()); | 441 key_node_comp(this->value_comp(), &this->get_value_traits()); |
419 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 442 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
420 if(safemode_or_autounlink) | 443 if(safemode_or_autounlink) |
421 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 444 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
422 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 445 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
423 node_ptr p = node_algorithms::insert_equal | 446 node_ptr p = node_algorithms::insert_equal |
424 (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp | 447 (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp |
425 , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); | 448 , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); |
426 this->tree_type::sz_traits().increment(); | 449 this->tree_type::sz_traits().increment(); |
427 this->max_tree_size_ = (size_type)max_tree_size; | 450 this->max_tree_size_ = (size_type)max_tree_size; |
428 return iterator(p, this->real_value_traits_ptr()); | 451 return iterator(p, this->priv_value_traits_ptr()); |
429 } | 452 } |
430 | 453 |
431 //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator) | 454 //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator) |
432 template<class Iterator> | 455 template<class Iterator> |
433 void insert_equal(Iterator b, Iterator e) | 456 void insert_equal(Iterator b, Iterator e) |
460 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) | 483 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&) |
461 template<class KeyType, class KeyValueCompare> | 484 template<class KeyType, class KeyValueCompare> |
462 std::pair<iterator, bool> insert_unique_check | 485 std::pair<iterator, bool> insert_unique_check |
463 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) | 486 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data) |
464 { | 487 { |
465 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | 488 detail::key_nodeptr_comp<KeyValueCompare, value_traits> |
466 comp(key_value_comp, &this->get_real_value_traits()); | 489 comp(key_value_comp, &this->get_value_traits()); |
467 std::pair<node_ptr, bool> ret = | 490 std::pair<node_ptr, bool> ret = |
468 (node_algorithms::insert_unique_check | 491 (node_algorithms::insert_unique_check |
469 (this->tree_type::header_ptr(), key, comp, commit_data)); | 492 (this->tree_type::header_ptr(), key, comp, commit_data)); |
470 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | 493 return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); |
471 } | 494 } |
472 | 495 |
473 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) | 496 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&) |
474 template<class KeyType, class KeyValueCompare> | 497 template<class KeyType, class KeyValueCompare> |
475 std::pair<iterator, bool> insert_unique_check | 498 std::pair<iterator, bool> insert_unique_check |
476 (const_iterator hint, const KeyType &key | 499 (const_iterator hint, const KeyType &key |
477 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) | 500 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data) |
478 { | 501 { |
479 detail::key_nodeptr_comp<KeyValueCompare, real_value_traits> | 502 detail::key_nodeptr_comp<KeyValueCompare, value_traits> |
480 comp(key_value_comp, &this->get_real_value_traits()); | 503 comp(key_value_comp, &this->get_value_traits()); |
481 std::pair<node_ptr, bool> ret = | 504 std::pair<node_ptr, bool> ret = |
482 (node_algorithms::insert_unique_check | 505 (node_algorithms::insert_unique_check |
483 (this->tree_type::header_ptr(), hint.pointed_node(), key, comp, commit_data)); | 506 (this->tree_type::header_ptr(), hint.pointed_node(), key, comp, commit_data)); |
484 return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second); | 507 return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second); |
485 } | 508 } |
486 | 509 |
487 //! @copydoc ::boost::intrusive::bstree::insert_unique_commit | 510 //! @copydoc ::boost::intrusive::bstree::insert_unique_commit |
488 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) | 511 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) |
489 { | 512 { |
490 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 513 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
491 if(safemode_or_autounlink) | 514 if(safemode_or_autounlink) |
492 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 515 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
493 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 516 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
494 node_algorithms::insert_unique_commit | 517 node_algorithms::insert_unique_commit |
495 ( this->tree_type::header_ptr(), to_insert, commit_data | 518 ( this->tree_type::header_ptr(), to_insert, commit_data |
496 , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); | 519 , (std::size_t)this->size(), this->get_h_alpha_func(), max_tree_size); |
497 this->tree_type::sz_traits().increment(); | 520 this->tree_type::sz_traits().increment(); |
498 this->max_tree_size_ = (size_type)max_tree_size; | 521 this->max_tree_size_ = (size_type)max_tree_size; |
499 return iterator(to_insert, this->real_value_traits_ptr()); | 522 return iterator(to_insert, this->priv_value_traits_ptr()); |
500 } | 523 } |
501 | 524 |
502 //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator) | 525 //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator) |
503 template<class Iterator> | 526 template<class Iterator> |
504 void insert_unique(Iterator b, Iterator e) | 527 void insert_unique(Iterator b, Iterator e) |
515 } | 538 } |
516 | 539 |
517 //! @copydoc ::boost::intrusive::bstree::insert_before | 540 //! @copydoc ::boost::intrusive::bstree::insert_before |
518 iterator insert_before(const_iterator pos, reference value) | 541 iterator insert_before(const_iterator pos, reference value) |
519 { | 542 { |
520 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 543 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
521 if(safemode_or_autounlink) | 544 if(safemode_or_autounlink) |
522 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 545 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
523 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 546 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
524 node_ptr p = node_algorithms::insert_before | 547 node_ptr p = node_algorithms::insert_before |
525 ( this->tree_type::header_ptr(), pos.pointed_node(), to_insert | 548 ( this->tree_type::header_ptr(), pos.pointed_node(), to_insert |
526 , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); | 549 , (size_type)this->size(), this->get_h_alpha_func(), max_tree_size); |
527 this->tree_type::sz_traits().increment(); | 550 this->tree_type::sz_traits().increment(); |
528 this->max_tree_size_ = (size_type)max_tree_size; | 551 this->max_tree_size_ = (size_type)max_tree_size; |
529 return iterator(p, this->real_value_traits_ptr()); | 552 return iterator(p, this->priv_value_traits_ptr()); |
530 } | 553 } |
531 | 554 |
532 //! @copydoc ::boost::intrusive::bstree::push_back | 555 //! @copydoc ::boost::intrusive::bstree::push_back |
533 void push_back(reference value) | 556 void push_back(reference value) |
534 { | 557 { |
535 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 558 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
536 if(safemode_or_autounlink) | 559 if(safemode_or_autounlink) |
537 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 560 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
538 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 561 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
539 node_algorithms::push_back | 562 node_algorithms::push_back |
540 ( this->tree_type::header_ptr(), to_insert | 563 ( this->tree_type::header_ptr(), to_insert |
544 } | 567 } |
545 | 568 |
546 //! @copydoc ::boost::intrusive::bstree::push_front | 569 //! @copydoc ::boost::intrusive::bstree::push_front |
547 void push_front(reference value) | 570 void push_front(reference value) |
548 { | 571 { |
549 node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value)); | 572 node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); |
550 if(safemode_or_autounlink) | 573 if(safemode_or_autounlink) |
551 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); | 574 BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); |
552 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; | 575 std::size_t max_tree_size = (std::size_t)this->max_tree_size_; |
553 node_algorithms::push_front | 576 node_algorithms::push_front |
554 ( this->tree_type::header_ptr(), to_insert | 577 ( this->tree_type::header_ptr(), to_insert |
603 template<class Disposer> | 626 template<class Disposer> |
604 iterator erase_and_dispose(const_iterator i, Disposer disposer) | 627 iterator erase_and_dispose(const_iterator i, Disposer disposer) |
605 { | 628 { |
606 node_ptr to_erase(i.pointed_node()); | 629 node_ptr to_erase(i.pointed_node()); |
607 iterator ret(this->erase(i)); | 630 iterator ret(this->erase(i)); |
608 disposer(this->get_real_value_traits().to_value_ptr(to_erase)); | 631 disposer(this->get_value_traits().to_value_ptr(to_erase)); |
609 return ret; | 632 return ret; |
610 } | 633 } |
611 | 634 |
612 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) | 635 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) |
613 template<class Disposer> | 636 template<class Disposer> |
664 size_type count(const_reference value) const; | 687 size_type count(const_reference value) const; |
665 | 688 |
666 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const | 689 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const |
667 template<class KeyType, class KeyValueCompare> | 690 template<class KeyType, class KeyValueCompare> |
668 size_type count(const KeyType& key, KeyValueCompare comp) const; | 691 size_type count(const KeyType& key, KeyValueCompare comp) const; |
669 | 692 |
670 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) | 693 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference) |
671 iterator lower_bound(const_reference value); | 694 iterator lower_bound(const_reference value); |
672 | 695 |
673 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) | 696 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare) |
674 template<class KeyType, class KeyValueCompare> | 697 template<class KeyType, class KeyValueCompare> |
675 iterator lower_bound(const KeyType& key, KeyValueCompare comp); | 698 iterator lower_bound(const KeyType& key, KeyValueCompare comp); |
676 | 699 |
677 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const | 700 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const |
856 //! same options (either explicitly or implicitly) are used. | 879 //! same options (either explicitly or implicitly) are used. |
857 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 880 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
858 template<class T, class ...Options> | 881 template<class T, class ...Options> |
859 #else | 882 #else |
860 template<class T, class O1 = void, class O2 = void | 883 template<class T, class O1 = void, class O2 = void |
861 , class O3 = void, class O4 = void> | 884 , class O3 = void, class O4 = void |
885 , class O5 = void> | |
862 #endif | 886 #endif |
863 struct make_sgtree | 887 struct make_sgtree |
864 { | 888 { |
865 /// @cond | 889 /// @cond |
866 typedef typename pack_options | 890 typedef typename pack_options |
867 < sgtree_defaults, | 891 < sgtree_defaults, |
868 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 892 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
869 O1, O2, O3, O4 | 893 O1, O2, O3, O4, O5 |
870 #else | 894 #else |
871 Options... | 895 Options... |
872 #endif | 896 #endif |
873 >::type packed_options; | 897 >::type packed_options; |
874 | 898 |
878 typedef sgtree_impl | 902 typedef sgtree_impl |
879 < value_traits | 903 < value_traits |
880 , typename packed_options::compare | 904 , typename packed_options::compare |
881 , typename packed_options::size_type | 905 , typename packed_options::size_type |
882 , packed_options::floating_point | 906 , packed_options::floating_point |
907 , typename packed_options::header_holder_type | |
883 > implementation_defined; | 908 > implementation_defined; |
884 /// @endcond | 909 /// @endcond |
885 typedef implementation_defined type; | 910 typedef implementation_defined type; |
886 }; | 911 }; |
887 | 912 |
888 | 913 |
889 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED | 914 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED |
890 | 915 |
891 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 916 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
892 template<class T, class O1, class O2, class O3, class O4> | 917 template<class T, class O1, class O2, class O3, class O4, class O5> |
893 #else | 918 #else |
894 template<class T, class ...Options> | 919 template<class T, class ...Options> |
895 #endif | 920 #endif |
896 class sgtree | 921 class sgtree |
897 : public make_sgtree<T, | 922 : public make_sgtree<T, |
898 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 923 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
899 O1, O2, O3, O4 | 924 O1, O2, O3, O4, O5 |
900 #else | 925 #else |
901 Options... | 926 Options... |
902 #endif | 927 #endif |
903 >::type | 928 >::type |
904 { | 929 { |
905 typedef typename make_sgtree | 930 typedef typename make_sgtree |
906 <T, | 931 <T, |
907 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) | 932 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) |
908 O1, O2, O3, O4 | 933 O1, O2, O3, O4, O5 |
909 #else | 934 #else |
910 Options... | 935 Options... |
911 #endif | 936 #endif |
912 >::type Base; | 937 >::type Base; |
913 BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree) | 938 BOOST_MOVABLE_BUT_NOT_COPYABLE(sgtree) |
914 | 939 |
915 public: | 940 public: |
916 typedef typename Base::value_compare value_compare; | 941 typedef typename Base::value_compare value_compare; |
917 typedef typename Base::value_traits value_traits; | 942 typedef typename Base::value_traits value_traits; |
918 typedef typename Base::real_value_traits real_value_traits; | |
919 typedef typename Base::iterator iterator; | 943 typedef typename Base::iterator iterator; |
920 typedef typename Base::const_iterator const_iterator; | 944 typedef typename Base::const_iterator const_iterator; |
921 typedef typename Base::reverse_iterator reverse_iterator; | 945 typedef typename Base::reverse_iterator reverse_iterator; |
922 typedef typename Base::const_reverse_iterator const_reverse_iterator; | 946 typedef typename Base::const_reverse_iterator const_reverse_iterator; |
923 | 947 |
924 //Assert if passed value traits are compatible with the type | 948 //Assert if passed value traits are compatible with the type |
925 BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value)); | 949 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value)); |
926 | 950 |
927 explicit sgtree( const value_compare &cmp = value_compare() | 951 explicit sgtree( const value_compare &cmp = value_compare() |
928 , const value_traits &v_traits = value_traits()) | 952 , const value_traits &v_traits = value_traits()) |
929 : Base(cmp, v_traits) | 953 : Base(cmp, v_traits) |
930 {} | 954 {} |
935 , const value_traits &v_traits = value_traits()) | 959 , const value_traits &v_traits = value_traits()) |
936 : Base(unique, b, e, cmp, v_traits) | 960 : Base(unique, b, e, cmp, v_traits) |
937 {} | 961 {} |
938 | 962 |
939 sgtree(BOOST_RV_REF(sgtree) x) | 963 sgtree(BOOST_RV_REF(sgtree) x) |
940 : Base(::boost::move(static_cast<Base&>(x))) | 964 : Base(BOOST_MOVE_BASE(Base, x)) |
941 {} | 965 {} |
942 | 966 |
943 sgtree& operator=(BOOST_RV_REF(sgtree) x) | 967 sgtree& operator=(BOOST_RV_REF(sgtree) x) |
944 { return static_cast<sgtree &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); } | 968 { return static_cast<sgtree &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); } |
945 | 969 |
946 static sgtree &container_from_end_iterator(iterator end_iterator) | 970 static sgtree &container_from_end_iterator(iterator end_iterator) |
947 { return static_cast<sgtree &>(Base::container_from_end_iterator(end_iterator)); } | 971 { return static_cast<sgtree &>(Base::container_from_end_iterator(end_iterator)); } |
948 | 972 |
949 static const sgtree &container_from_end_iterator(const_iterator end_iterator) | 973 static const sgtree &container_from_end_iterator(const_iterator end_iterator) |