From ec31a6b75b87ac17fc4d329ad0e76637f2b0095f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 24 Sep 2012 12:17:34 +0000 Subject: [PATCH] Merge from trunk [SVN r80689] --- include/boost/intrusive/avltree.hpp | 2 +- .../intrusive/circular_slist_algorithms.hpp | 9 +- .../boost/intrusive/detail/avltree_node.hpp | 22 +- .../detail/common_slist_algorithms.hpp | 3 +- include/boost/intrusive/detail/list_node.hpp | 10 +- .../boost/intrusive/detail/rbtree_node.hpp | 34 +- include/boost/intrusive/detail/slist_node.hpp | 5 +- .../intrusive/detail/tree_algorithms.hpp | 35 +- include/boost/intrusive/detail/tree_node.hpp | 15 +- include/boost/intrusive/detail/utilities.hpp | 81 +-- include/boost/intrusive/hashtable.hpp | 498 ++++++++---------- include/boost/intrusive/list.hpp | 2 +- include/boost/intrusive/options.hpp | 6 - include/boost/intrusive/pointer_traits.hpp | 2 +- include/boost/intrusive/rbtree.hpp | 2 +- include/boost/intrusive/rbtree_algorithms.hpp | 21 +- include/boost/intrusive/sgtree.hpp | 2 +- include/boost/intrusive/slist.hpp | 2 +- include/boost/intrusive/splaytree.hpp | 2 +- include/boost/intrusive/treap.hpp | 2 +- 20 files changed, 340 insertions(+), 415 deletions(-) diff --git a/include/boost/intrusive/avltree.hpp b/include/boost/intrusive/avltree.hpp index 84376a8..c936f37 100644 --- a/include/boost/intrusive/avltree.hpp +++ b/include/boost/intrusive/avltree.hpp @@ -89,7 +89,7 @@ class avltree_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/circular_slist_algorithms.hpp b/include/boost/intrusive/circular_slist_algorithms.hpp index c39b3d0..fc3848e 100644 --- a/include/boost/intrusive/circular_slist_algorithms.hpp +++ b/include/boost/intrusive/circular_slist_algorithms.hpp @@ -172,18 +172,17 @@ class circular_slist_algorithms static node_ptr get_previous_previous_node(const node_ptr & this_node) { return get_previous_previous_node(this_node, this_node); } - //! Requires: this_node and prev_prev_init_node must be in the same circular list. + //! Requires: this_node and p must be in the same circular list. //! //! Effects: Returns the previous node of the previous node of this_node in the - //! circular list starting. the search from prev_init_node. The first node checked - //! for equality is NodeTraits::get_next((NodeTraits::get_next(prev_prev_init_node)). + //! circular list starting. the search from p. The first node checked + //! for equality is NodeTraits::get_next((NodeTraits::get_next(p)). //! //! Complexity: Linear to the number of elements in the circular list. //! //! Throws: Nothing. - static node_ptr get_previous_previous_node(const node_ptr & prev_prev_init_node, const node_ptr & this_node) + static node_ptr get_previous_previous_node(node_ptr p, const node_ptr & this_node) { - node_ptr p = prev_prev_init_node; node_ptr p_next = NodeTraits::get_next(p); node_ptr p_next_next = NodeTraits::get_next(p_next); while (this_node != p_next_next){ diff --git a/include/boost/intrusive/detail/avltree_node.hpp b/include/boost/intrusive/detail/avltree_node.hpp index aec0dab..f6aefcb 100644 --- a/include/boost/intrusive/detail/avltree_node.hpp +++ b/include/boost/intrusive/detail/avltree_node.hpp @@ -68,19 +68,28 @@ struct default_avltree_node_traits_impl typedef typename node::balance balance; - static const node_ptr & get_parent(const const_node_ptr & n) + static node_ptr get_parent(const const_node_ptr & n) + { return n->parent_; } + + static node_ptr get_parent(const node_ptr & n) { return n->parent_; } static void set_parent(const node_ptr & n, const node_ptr & p) { n->parent_ = p; } - static const node_ptr & get_left(const const_node_ptr & n) + static node_ptr get_left(const const_node_ptr & n) + { return n->left_; } + + static node_ptr get_left(const node_ptr & n) { return n->left_; } static void set_left(const node_ptr & n, const node_ptr & l) { n->left_ = l; } - static const node_ptr & get_right(const const_node_ptr & n) + static node_ptr get_right(const const_node_ptr & n) + { return n->right_; } + + static node_ptr get_right(const node_ptr & n) { return n->right_; } static void set_right(const node_ptr & n, const node_ptr & r) @@ -89,6 +98,9 @@ struct default_avltree_node_traits_impl static balance get_balance(const const_node_ptr & n) { return n->balance_; } + static balance get_balance(const node_ptr & n) + { return n->balance_; } + static void set_balance(const node_ptr & n, balance b) { n->balance_ = b; } @@ -125,13 +137,13 @@ struct compact_avltree_node_traits_impl static void set_parent(const node_ptr & n, const node_ptr & p) { ptr_bit::set_pointer(n->parent_, p); } - static const node_ptr & get_left(const const_node_ptr & n) + static node_ptr get_left(const const_node_ptr & n) { return n->left_; } static void set_left(const node_ptr & n, const node_ptr & l) { n->left_ = l; } - static const node_ptr & get_right(const const_node_ptr & n) + static node_ptr get_right(const const_node_ptr & n) { return n->right_; } static void set_right(const node_ptr & n, const node_ptr & r) diff --git a/include/boost/intrusive/detail/common_slist_algorithms.hpp b/include/boost/intrusive/detail/common_slist_algorithms.hpp index 942b35a..166f78d 100644 --- a/include/boost/intrusive/detail/common_slist_algorithms.hpp +++ b/include/boost/intrusive/detail/common_slist_algorithms.hpp @@ -31,9 +31,8 @@ class common_slist_algorithms typedef typename NodeTraits::const_node_ptr const_node_ptr; typedef NodeTraits node_traits; - static node_ptr get_previous_node(const node_ptr & prev_init_node, const node_ptr & this_node) + static node_ptr get_previous_node(node_ptr p, const node_ptr & this_node) { - node_ptr p = prev_init_node; for( node_ptr p_next ; this_node != (p_next = NodeTraits::get_next(p)) ; p = p_next){ diff --git a/include/boost/intrusive/detail/list_node.hpp b/include/boost/intrusive/detail/list_node.hpp index d406af6..32274e6 100644 --- a/include/boost/intrusive/detail/list_node.hpp +++ b/include/boost/intrusive/detail/list_node.hpp @@ -44,13 +44,19 @@ struct list_node_traits typedef typename pointer_traits :: template rebind_pointer::type const_node_ptr; - static const node_ptr &get_previous(const const_node_ptr & n) + static node_ptr get_previous(const const_node_ptr & n) + { return n->prev_; } + + static node_ptr get_previous(const node_ptr & n) { return n->prev_; } static void set_previous(const node_ptr & n, const node_ptr & prev) { n->prev_ = prev; } - static const node_ptr &get_next(const const_node_ptr & n) + static node_ptr get_next(const const_node_ptr & n) + { return n->next_; } + + static node_ptr get_next(const node_ptr & n) { return n->next_; } static void set_next(const node_ptr & n, const node_ptr & next) diff --git a/include/boost/intrusive/detail/rbtree_node.hpp b/include/boost/intrusive/detail/rbtree_node.hpp index b76582b..92d9417 100644 --- a/include/boost/intrusive/detail/rbtree_node.hpp +++ b/include/boost/intrusive/detail/rbtree_node.hpp @@ -68,19 +68,28 @@ struct default_rbtree_node_traits_impl typedef typename node::color color; - static const node_ptr & get_parent(const const_node_ptr & n) + static node_ptr get_parent(const const_node_ptr & n) + { return n->parent_; } + + static node_ptr get_parent(const node_ptr & n) { return n->parent_; } static void set_parent(const node_ptr & n, const node_ptr & p) { n->parent_ = p; } - static const node_ptr & get_left(const const_node_ptr & n) + static node_ptr get_left(const const_node_ptr & n) + { return n->left_; } + + static node_ptr get_left(const node_ptr & n) { return n->left_; } static void set_left(const node_ptr & n, const node_ptr & l) { n->left_ = l; } - static const node_ptr & get_right(const const_node_ptr & n) + static node_ptr get_right(const const_node_ptr & n) + { return n->right_; } + + static node_ptr get_right(const node_ptr & n) { return n->right_; } static void set_right(const node_ptr & n, const node_ptr & r) @@ -89,6 +98,9 @@ struct default_rbtree_node_traits_impl static color get_color(const const_node_ptr & n) { return n->color_; } + static color get_color(const node_ptr & n) + { return n->color_; } + static void set_color(const node_ptr & n, color c) { n->color_ = c; } @@ -117,16 +129,25 @@ struct compact_rbtree_node_traits_impl static node_ptr get_parent(const const_node_ptr & n) { return ptr_bit::get_pointer(n->parent_); } + static node_ptr get_parent(const node_ptr & n) + { return ptr_bit::get_pointer(n->parent_); } + static void set_parent(const node_ptr & n, const node_ptr & p) { ptr_bit::set_pointer(n->parent_, p); } - static const node_ptr & get_left(const const_node_ptr & n) + static node_ptr get_left(const const_node_ptr & n) + { return n->left_; } + + static node_ptr get_left(const node_ptr & n) { return n->left_; } static void set_left(const node_ptr & n, const node_ptr & l) { n->left_ = l; } - static const node_ptr & get_right(const const_node_ptr & n) + static node_ptr get_right(const const_node_ptr & n) + { return n->right_; } + + static node_ptr get_right(const node_ptr & n) { return n->right_; } static void set_right(const node_ptr & n, const node_ptr & r) @@ -135,6 +156,9 @@ struct compact_rbtree_node_traits_impl static color get_color(const const_node_ptr & n) { return (color)ptr_bit::get_bits(n->parent_); } + static color get_color(const node_ptr & n) + { return (color)ptr_bit::get_bits(n->parent_); } + static void set_color(const node_ptr & n, color c) { ptr_bit::set_bits(n->parent_, c != 0); } diff --git a/include/boost/intrusive/detail/slist_node.hpp b/include/boost/intrusive/detail/slist_node.hpp index 0eddbcd..ee92919 100644 --- a/include/boost/intrusive/detail/slist_node.hpp +++ b/include/boost/intrusive/detail/slist_node.hpp @@ -42,7 +42,10 @@ struct slist_node_traits typedef typename pointer_traits ::template rebind_pointer::type const_node_ptr; - static const node_ptr &get_next(const const_node_ptr & n) + static node_ptr get_next(const const_node_ptr & n) + { return n->next_; } + + static node_ptr get_next(const node_ptr & n) { return n->next_; } static void set_next(const node_ptr & n, const node_ptr & next) diff --git a/include/boost/intrusive/detail/tree_algorithms.hpp b/include/boost/intrusive/detail/tree_algorithms.hpp index c92d39b..acdedd9 100644 --- a/include/boost/intrusive/detail/tree_algorithms.hpp +++ b/include/boost/intrusive/detail/tree_algorithms.hpp @@ -485,15 +485,14 @@ class tree_algorithms //! Complexity: Logarithmic to the size of the subtree. //! //! Throws: Nothing. - static node_ptr minimum (const node_ptr & node) + static node_ptr minimum (node_ptr node) { - node_ptr p(node); - for(node_ptr p_left = NodeTraits::get_left(p) + for(node_ptr p_left = NodeTraits::get_left(node) ;p_left - ;p_left = NodeTraits::get_left(p)){ - p = p_left; + ;p_left = NodeTraits::get_left(node)){ + node = p_left; } - return p; + return node; } //! Requires: 'node' is a node of a tree but not the header. @@ -503,15 +502,14 @@ class tree_algorithms //! Complexity: Logarithmic to the size of the subtree. //! //! Throws: Nothing. - static node_ptr maximum(const node_ptr & node) + static node_ptr maximum(node_ptr node) { - node_ptr p(node); - for(node_ptr p_right = NodeTraits::get_right(p) + for(node_ptr p_right = NodeTraits::get_right(node) ;p_right - ;p_right = NodeTraits::get_right(p)){ - p = p_right; + ;p_right = NodeTraits::get_right(node)){ + node = p_right; } - return p; + return node; } //! Requires: 'node' must not be part of any tree. @@ -1171,14 +1169,13 @@ class tree_algorithms //! Complexity: Logarithmic to the number of nodes in the tree. //! //! Throws: Nothing. - static std::size_t depth(const const_node_ptr & node) + static std::size_t depth(const_node_ptr node) { - const_node_ptr p(node); std::size_t depth = 0; node_ptr p_parent; - while(p != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(p))){ + while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){ ++depth; - p = p_parent; + node = p_parent; } return depth; } @@ -1295,12 +1292,10 @@ class tree_algorithms } template - static void dispose_subtree(const node_ptr & node, Disposer disposer) + static void dispose_subtree(node_ptr x, Disposer disposer) { - node_ptr save; - node_ptr x(node); while (x){ - save = NodeTraits::get_left(x); + node_ptr save(NodeTraits::get_left(x)); if (save) { // Right rotation NodeTraits::set_left(x, NodeTraits::get_right(save)); diff --git a/include/boost/intrusive/detail/tree_node.hpp b/include/boost/intrusive/detail/tree_node.hpp index 09fa7a4..aa3374e 100644 --- a/include/boost/intrusive/detail/tree_node.hpp +++ b/include/boost/intrusive/detail/tree_node.hpp @@ -41,19 +41,28 @@ struct tree_node_traits typedef typename pointer_traits::template rebind_pointer::type const_node_ptr; - static const node_ptr & get_parent(const const_node_ptr & n) + static node_ptr get_parent(const const_node_ptr & n) + { return n->parent_; } + + static node_ptr get_parent(const node_ptr & n) { return n->parent_; } static void set_parent(const node_ptr & n, const node_ptr & p) { n->parent_ = p; } - static const node_ptr & get_left(const const_node_ptr & n) + static node_ptr get_left(const const_node_ptr & n) + { return n->left_; } + + static node_ptr get_left(const node_ptr & n) { return n->left_; } static void set_left(const node_ptr & n, const node_ptr & l) { n->left_ = l; } - static const node_ptr & get_right(const const_node_ptr & n) + static node_ptr get_right(const const_node_ptr & n) + { return n->right_; } + + static node_ptr get_right(const node_ptr & n) { return n->right_; } static void set_right(const node_ptr & n, const node_ptr & r) diff --git a/include/boost/intrusive/detail/utilities.hpp b/include/boost/intrusive/detail/utilities.hpp index c6bc798..722a7a3 100644 --- a/include/boost/intrusive/detail/utilities.hpp +++ b/include/boost/intrusive/detail/utilities.hpp @@ -41,64 +41,29 @@ struct internal_member_value_traits static const bool value = sizeof(test(0)) == sizeof(detail::two); }; -template -struct internal_base_hook_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; +#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \ +template \ +struct TRAITS_PREFIX##_bool\ +{\ + template\ + struct two_or_three {one _[2 + Add];};\ + template static one test(...);\ + template static two_or_three test (int);\ + static const std::size_t value = sizeof(test(0));\ +};\ +\ +template \ +struct TRAITS_PREFIX##_bool_is_true\ +{\ + static const bool value = TRAITS_PREFIX##_bool::value > sizeof(one)*2;\ +};\ +// -template -struct internal_base_hook_bool_is_true -{ - static const bool value = internal_base_hook_bool::value > sizeof(one)*2; -}; - -template -struct internal_any_hook_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; - -template -struct internal_any_hook_bool_is_true -{ - static const bool value = internal_any_hook_bool::value > sizeof(one)*2; -}; - - -template -struct external_value_traits_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; - -template -struct external_bucket_traits_bool -{ - template - struct two_or_three {one _[2 + Add];}; - template static one test(...); - template static two_or_three test (int); - static const std::size_t value = sizeof(test(0)); -}; - -template -struct external_value_traits_is_true -{ - static const bool value = external_value_traits_bool::value > sizeof(one)*2; -}; +BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, boost_intrusive_tags::is_base_hook) +BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook) +BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_value_traits, external_value_traits) +BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_bucket_traits, external_bucket_traits) +BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(resizable, resizable) template struct node_holder @@ -644,7 +609,7 @@ struct store_cont_ptr_on_it { typedef typename Container::value_traits value_traits; static const bool value = store_cont_ptr_on_it_impl - ::value>::value; + ::value>::value; }; template diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 2435a08..09d5c9e 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -135,7 +135,7 @@ template struct real_from_supposed_value_traits { typedef typename detail::eval_if_c - < detail::external_value_traits_is_true + < detail::external_value_traits_bool_is_true ::value , detail::eval_value_traits @@ -384,7 +384,7 @@ struct group_functions slist_node_ptr possible_end = node_traits::get_next(last_node_group); while(!(bucket_beg <= possible_end && possible_end <= bucket_end)){ - first_node_of_group = dcast_bucket_ptr(possible_end); + first_node_of_group = group_functions::dcast_bucket_ptr(possible_end); last_node_group = group_traits::get_next(first_node_of_group); possible_end = node_traits::get_next(last_node_group); } @@ -395,7 +395,7 @@ struct group_functions { //Just iterate using group links and obtain the node //before "first_in_group)" - node_ptr prev_node = dcast_bucket_ptr(bucket_node); + node_ptr prev_node = group_functions::dcast_bucket_ptr(bucket_node); node_ptr nxt(node_traits::get_next(prev_node)); while(nxt != first_in_group){ prev_node = group_traits::get_next(nxt); @@ -480,7 +480,7 @@ struct group_functions , const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr) { slist_node_ptr prev; - node_ptr elem(dcast_bucket_ptr(i)); + node_ptr elem(group_functions::dcast_bucket_ptr(i)); //It's the last in group if the next_node is a bucket slist_node_ptr nxt(node_traits::get_next(elem)); @@ -687,7 +687,7 @@ class hashtable_impl /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits @@ -695,7 +695,7 @@ class hashtable_impl >::type real_value_traits; typedef typename Config::bucket_traits bucket_traits; static const bool external_bucket_traits = - detail::external_bucket_traits_is_true::value; + detail::external_bucket_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_bucket_traits , detail::eval_bucket_traits @@ -894,14 +894,14 @@ class hashtable_impl , const value_traits &v_traits = value_traits()) : data_(b_traits, hash_func, equal_func, v_traits) { - priv_initialize_buckets(); + this->priv_initialize_buckets(); this->priv_size_traits().set_size(size_type(0)); - size_type bucket_size = this->priv_buckets_len(); + size_type bucket_size = this->priv_bucket_count(); BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_size != 0); //Check power of two bucket array if the option is activated BOOST_INTRUSIVE_INVARIANT_ASSERT (!power_2_buckets || (0 == (bucket_size & (bucket_size-1)))); - priv_split_traits().set_size(bucket_size>>1); + this->priv_split_traits().set_size(bucket_size>>1); } //! Effects: to-do @@ -913,7 +913,7 @@ class hashtable_impl , ::boost::move(x.priv_value_traits()) ) { - priv_swap_cache(cache_begin_t(), x); + this->priv_swap_cache(cache_begin_t(), x); x.priv_initialize_cache(); if(constant_time_size){ this->priv_size_traits().set_size(size_type(0)); @@ -976,7 +976,7 @@ class hashtable_impl //! //! Throws: Nothing. iterator end() - { return iterator(priv_invalid_local_it(), 0); } + { return iterator(this->priv_invalid_local_it(), 0); } //! Effects: Returns a const_iterator pointing to the end of the unordered_set. //! @@ -992,7 +992,7 @@ class hashtable_impl //! //! Throws: Nothing. const_iterator cend() const - { return const_iterator(priv_invalid_local_it(), 0); } + { return const_iterator(this->priv_invalid_local_it(), 0); } //! Effects: Returns the hasher object used by the unordered_set. //! @@ -1026,9 +1026,9 @@ class hashtable_impl return this->begin() == this->end(); } else{ - size_type buckets_len = this->priv_buckets_len(); - const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets()); - for (size_type n = 0; n < buckets_len; ++n, ++b){ + size_type bucket_count = this->priv_bucket_count(); + const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer()); + for (size_type n = 0; n < bucket_count; ++n, ++b){ if(!b->empty()){ return false; } @@ -1049,9 +1049,9 @@ class hashtable_impl return this->priv_size_traits().get_size(); else{ size_type len = 0; - size_type buckets_len = this->priv_buckets_len(); - const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_buckets()); - for (size_type n = 0; n < buckets_len; ++n, ++b){ + size_type bucket_count = this->priv_bucket_count(); + const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer()); + for (size_type n = 0; n < bucket_count; ++n, ++b){ len += b->size(); } return len; @@ -1077,7 +1077,7 @@ class hashtable_impl //These can't throw swap(this->priv_bucket_traits(), other.priv_bucket_traits()); swap(this->priv_value_traits(), other.priv_value_traits()); - priv_swap_cache(cache_begin_t(), other); + this->priv_swap_cache(cache_begin_t(), other); if(constant_time_size){ size_type backup = this->priv_size_traits().get_size(); this->priv_size_traits().set_size(other.priv_size_traits().get_size()); @@ -1125,8 +1125,8 @@ class hashtable_impl //If src bucket count is bigger or equal, structural copy is possible if(!incremental && (src_bucket_count >= dst_bucket_count)){ //First clone the first ones - const bucket_ptr src_buckets = src.priv_buckets(); - const bucket_ptr dst_buckets = this->priv_buckets(); + const bucket_ptr src_buckets = src.priv_bucket_pointer(); + const bucket_ptr dst_buckets = this->priv_bucket_pointer(); size_type constructed; typedef node_cast_adaptor > NodeDisposer; typedef node_cast_adaptor > NodeCloner; @@ -1147,7 +1147,7 @@ class hashtable_impl ; constructed < src_bucket_count ; ++constructed){ bucket_type &dst_b = - dst_buckets[priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)]; + dst_buckets[this->priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)]; bucket_type &src_b = src_buckets[constructed]; for( siterator b(src_b.begin()), e(src_b.end()) ; b != e @@ -1161,8 +1161,8 @@ class hashtable_impl rollback.release(); this->priv_size_traits().set_size(src.priv_size_traits().get_size()); this->priv_split_traits().set_size(dst_bucket_count); - priv_insertion_update_cache(0u); - priv_erasure_update_cache(); + this->priv_insertion_update_cache(0u); + this->priv_erasure_update_cache(); } else if(store_hash){ //Unlike previous cloning algorithm, this can throw @@ -1209,7 +1209,7 @@ class hashtable_impl siterator prev; siterator it = this->priv_find (value, this->priv_hasher(), this->priv_equal(), bucket_num, hash_value, prev); - return priv_insert_equal_find(value, bucket_num, hash_value, it); + return this->priv_insert_equal_find(value, bucket_num, hash_value, it); } //! Requires: Dereferencing iterator must yield an lvalue @@ -1323,7 +1323,7 @@ class hashtable_impl siterator prev; siterator prev_pos = this->priv_find(key, hash_func, equal_func, bucket_num, commit_data.hash, prev); - bool success = prev_pos == priv_invalid_local_it(); + bool success = prev_pos == this->priv_invalid_local_it(); if(success){ prev_pos = prev; } @@ -1351,14 +1351,14 @@ class hashtable_impl //! After a successful rehashing insert_commit_data remains valid. iterator insert_unique_commit(reference value, const insert_commit_data &commit_data) { - size_type bucket_num = priv_hash_to_bucket(commit_data.hash); - bucket_type &b = this->priv_buckets()[bucket_num]; + size_type bucket_num = this->priv_hash_to_bucket(commit_data.hash); + bucket_type &b = this->priv_bucket_pointer()[bucket_num]; this->priv_size_traits().increment(); - node_ptr n = pointer_traits::pointer_to(priv_value_to_node(value)); + node_ptr n = pointer_traits::pointer_to(this->priv_value_to_node(value)); node_functions_t::store_hash(n, commit_data.hash, store_hash_t()); if(safemode_or_autounlink) BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n)); - priv_insertion_update_cache(bucket_num); + this->priv_insertion_update_cache(bucket_num); group_functions_t::insert_in_group(node_ptr(), n, optimize_multikey_t()); return iterator(b.insert_after(b.before_begin(), *n), this); } @@ -1443,9 +1443,9 @@ class hashtable_impl /// @endcond ) { - priv_erase(i, disposer, optimize_multikey_t()); + this->priv_erase(i, disposer, optimize_multikey_t()); this->priv_size_traits().decrement(); - priv_erasure_update_cache(); + this->priv_erasure_update_cache(); } //! Requires: Disposer::operator()(pointer) shouldn't throw. @@ -1468,8 +1468,9 @@ class hashtable_impl siterator first_local_it(b.slist_it()); size_type first_bucket_num = this->priv_get_bucket_num(first_local_it); + const bucket_ptr bucket_pointer = this->priv_bucket_pointer(); siterator before_first_local_it - = priv_get_previous(priv_buckets()[first_bucket_num], first_local_it); + = this->priv_get_previous(bucket_pointer[first_bucket_num], first_local_it); size_type last_bucket_num; siterator last_local_it; @@ -1477,14 +1478,14 @@ class hashtable_impl //of the last bucket if(e == this->end()){ last_bucket_num = this->bucket_count() - 1; - last_local_it = priv_buckets()[last_bucket_num].end(); + last_local_it = bucket_pointer[last_bucket_num].end(); } else{ last_local_it = e.slist_it(); last_bucket_num = this->priv_get_bucket_num(last_local_it); } - priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer); - priv_erasure_update_cache(first_bucket_num, last_bucket_num); + this->priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer); + this->priv_erasure_update_cache(first_bucket_num, last_bucket_num); } } @@ -1505,7 +1506,7 @@ class hashtable_impl //! to the erased elements. No destructors are called. template size_type erase_and_dispose(const_reference value, Disposer disposer) - { return this->erase_and_dispose(value, priv_hasher(), priv_equal(), disposer); } + { return this->erase_and_dispose(value, this->priv_hasher(), this->priv_equal(), disposer); } //! Requires: Disposer::operator()(pointer) shouldn't throw. //! @@ -1531,7 +1532,7 @@ class hashtable_impl siterator prev; siterator it = this->priv_find(key, hash_func, equal_func, bucket_num, h, prev); - bool success = it != priv_invalid_local_it(); + bool success = it != this->priv_invalid_local_it(); size_type count(0); if(!success){ return 0; @@ -1539,15 +1540,15 @@ class hashtable_impl else if(optimize_multikey){ siterator last = bucket_type::s_iterator_to (*node_traits::get_next(group_functions_t::get_last_in_group - (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); + (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); this->priv_erase_range_impl(bucket_num, prev, last, disposer, count); } else{ //If found erase all equal values - bucket_type &b = this->priv_buckets()[bucket_num]; + bucket_type &b = this->priv_bucket_pointer()[bucket_num]; for(siterator end = b.end(); it != end; ++count, ++it){ slist_node_ptr n(it.pointed_node()); - const value_type &v = priv_value_from_slist_node(n); + const value_type &v = this->priv_value_from_slist_node(n); if(compare_hash){ std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t()); if(h != vh || !equal_func(key, v)){ @@ -1561,7 +1562,7 @@ class hashtable_impl } b.erase_after_and_dispose(prev, it, make_node_disposer(disposer)); } - priv_erasure_update_cache(); + this->priv_erasure_update_cache(); return count; } @@ -1576,7 +1577,7 @@ class hashtable_impl //! to the erased elements. No destructors are called. void clear() { - priv_clear_buckets(); + this->priv_clear_buckets(); this->priv_size_traits().set_size(size_type(0)); } @@ -1596,13 +1597,13 @@ class hashtable_impl { if(!constant_time_size || !this->empty()){ size_type num_buckets = this->bucket_count(); - bucket_ptr b = this->priv_buckets(); + bucket_ptr b = this->priv_bucket_pointer(); for(; num_buckets--; ++b){ b->clear_and_dispose(make_node_disposer(disposer)); } this->priv_size_traits().set_size(size_type(0)); } - priv_initialize_cache(); + this->priv_initialize_cache(); } //! Effects: Returns the number of contained elements with the given value @@ -1805,7 +1806,7 @@ class hashtable_impl //! Throws: If the internal hash function throws. iterator iterator_to(reference value) { - return iterator(bucket_type::s_iterator_to(priv_value_to_node(value)), this); + return iterator(bucket_type::s_iterator_to(this->priv_value_to_node(value)), this); } //! Requires: value must be an lvalue and shall be in a unordered_set of @@ -1899,7 +1900,7 @@ class hashtable_impl //! //! Throws: Nothing. size_type bucket_count() const - { return this->priv_buckets_len(); } + { return this->priv_bucket_count(); } //! Requires: n is in the range [0, this->bucket_count()). //! @@ -1909,7 +1910,7 @@ class hashtable_impl //! //! Throws: Nothing. size_type bucket_size(size_type n) const - { return this->priv_buckets()[n].size(); } + { return this->priv_bucket_pointer()[n].size(); } //! Effects: Returns the index of the bucket in which elements //! with keys equivalent to k would be found, if any such element existed. @@ -1936,7 +1937,7 @@ class hashtable_impl //! Note: the return value is in the range [0, this->bucket_count()). template size_type bucket(const KeyType& k, const KeyHasher &hash_func) const - { return priv_hash_to_bucket(hash_func(k)); } + { return this->priv_hash_to_bucket(hash_func(k)); } //! Effects: Returns the bucket array pointer passed in the constructor //! or the last rehash function. @@ -1945,7 +1946,7 @@ class hashtable_impl //! //! Throws: Nothing. bucket_ptr bucket_pointer() const - { return this->priv_buckets(); } + { return this->priv_bucket_pointer(); } //! Requires: n is in the range [0, this->bucket_count()). //! @@ -1959,7 +1960,7 @@ class hashtable_impl //! Note: [this->begin(n), this->end(n)) is a valid range //! containing all of the elements in the nth bucket. local_iterator begin(size_type n) - { return local_iterator(this->priv_buckets()[n].begin(), this); } + { return local_iterator(this->priv_bucket_pointer()[n].begin(), this); } //! Requires: n is in the range [0, this->bucket_count()). //! @@ -1988,7 +1989,7 @@ class hashtable_impl //! containing all of the elements in the nth bucket. const_local_iterator cbegin(size_type n) const { - siterator sit = const_cast(this->priv_buckets()[n]).begin(); + siterator sit = const_cast(this->priv_bucket_pointer()[n]).begin(); return const_local_iterator(sit, this); } @@ -2004,7 +2005,7 @@ class hashtable_impl //! Note: [this->begin(n), this->end(n)) is a valid range //! containing all of the elements in the nth bucket. local_iterator end(size_type n) - { return local_iterator(this->priv_buckets()[n].end(), this); } + { return local_iterator(this->priv_bucket_pointer()[n].end(), this); } //! Requires: n is in the range [0, this->bucket_count()). //! @@ -2032,19 +2033,19 @@ class hashtable_impl //! Note: [this->begin(n), this->end(n)) is a valid range //! containing all of the elements in the nth bucket. const_local_iterator cend(size_type n) const - { return const_local_iterator(const_cast(this->priv_buckets()[n]).end(), this); } + { return const_local_iterator(const_cast(this->priv_bucket_pointer()[n]).end(), this); } - //! Requires: new_buckets must be a pointer to a new bucket array - //! or the same as the old bucket array. new_size is the length of the - //! the array pointed by new_buckets. If new_buckets == this->bucket_pointer() - //! n can be bigger or smaller than this->bucket_count(). + //! Requires: new_bucket_traits can hold a pointer to a new bucket array + //! or the same as the old bucket array with a different length. new_size is the length of the + //! the array pointed by new_buckets. If new_bucket_traits.bucket_begin() == this->bucket_pointer() + //! new_bucket_traits.bucket_count() can be bigger or smaller than this->bucket_count(). //! 'new_bucket_traits' copy constructor should not throw. //! - //! Effects: Updates the internal reference with the new bucket erases + //! Effects: Updates the internal reference with the new bucket, erases //! the values from the old bucket and inserts then in the new one. //! Bucket traits hold by *this is assigned from new_bucket_traits. //! If the container is configured as incremental<>, the split bucket is set - //! to the new bucket_len(). + //! to the new bucket_count(). //! //! If store_hash option is true, this method does not use the hash function. //! @@ -2053,27 +2054,27 @@ class hashtable_impl //! Throws: If the hasher functor throws. Basic guarantee. void rehash(const bucket_traits &new_bucket_traits) { - bucket_ptr new_buckets = new_bucket_traits.bucket_begin(); - size_type new_buckets_len = new_bucket_traits.bucket_count(); - bucket_ptr old_buckets = this->priv_buckets(); - size_type old_buckets_len = this->priv_buckets_len(); + const bucket_ptr new_buckets = new_bucket_traits.bucket_begin(); + size_type new_bucket_count = new_bucket_traits.bucket_count(); + const bucket_ptr old_buckets = this->priv_bucket_pointer(); + size_type old_bucket_count = this->priv_bucket_count(); //Check power of two bucket array if the option is activated BOOST_INTRUSIVE_INVARIANT_ASSERT - (!power_2_buckets || (0 == (new_buckets_len & (new_buckets_len-1u)))); + (!power_2_buckets || (0 == (new_bucket_count & (new_bucket_count-1u)))); - size_type n = priv_get_cache_bucket_num(); + size_type n = this->priv_get_cache_bucket_num(); const bool same_buffer = old_buckets == new_buckets; //If the new bucket length is a common factor //of the old one we can avoid hash calculations. - const bool fast_shrink = (!incremental) && (old_buckets_len > new_buckets_len) && - (power_2_buckets ||(old_buckets_len % new_buckets_len) == 0); + const bool fast_shrink = (!incremental) && (old_bucket_count > new_bucket_count) && + (power_2_buckets ||(old_bucket_count % new_bucket_count) == 0); //If we are shrinking the same bucket array and it's //is a fast shrink, just rehash the last nodes - size_type new_first_bucket_num = new_buckets_len; - if(same_buffer && fast_shrink && (n < new_buckets_len)){ - n = new_buckets_len; - new_first_bucket_num = priv_get_cache_bucket_num(); + size_type new_first_bucket_num = new_bucket_count; + if(same_buffer && fast_shrink && (n < new_bucket_count)){ + n = new_bucket_count; + new_first_bucket_num = this->priv_get_cache_bucket_num(); } //Anti-exception stuff: they destroy the elements if something goes wrong. @@ -2084,19 +2085,19 @@ class hashtable_impl bucket_type & newbuck = new_buckets[0]; bucket_type & oldbuck = old_buckets[0]; detail::exception_array_disposer - rollback1(newbuck, node_disp, new_buckets_len); + rollback1(newbuck, node_disp, new_bucket_count); detail::exception_array_disposer - rollback2(oldbuck, node_disp, old_buckets_len); + rollback2(oldbuck, node_disp, old_bucket_count); //Put size in a safe value for rollback exception size_type size_backup = this->priv_size_traits().get_size(); this->priv_size_traits().set_size(0); //Put cache to safe position - priv_initialize_cache(); - priv_insertion_update_cache(size_type(0u)); + this->priv_initialize_cache(); + this->priv_insertion_update_cache(size_type(0u)); //Iterate through nodes - for(; n < old_buckets_len; ++n){ + for(; n < old_bucket_count; ++n){ bucket_type &old_bucket = old_buckets[n]; if(!fast_shrink){ @@ -2104,14 +2105,14 @@ class hashtable_impl siterator end(old_bucket.end()); siterator i(old_bucket.begin()); for(;i != end; ++i){ - const value_type &v = priv_value_from_slist_node(i.pointed_node()); + const value_type &v = this->priv_value_from_slist_node(i.pointed_node()); const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); - const size_type new_n = priv_hash_to_bucket(hash_value, new_buckets_len, new_buckets_len); + const size_type new_n = this->priv_hash_to_bucket(hash_value, new_bucket_count, new_bucket_count); if(cache_begin && new_n < new_first_bucket_num) new_first_bucket_num = new_n; siterator last = bucket_type::s_iterator_to (*group_functions_t::get_last_in_group - (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); + (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); if(same_buffer && new_n == n){ before_i = last; } @@ -2123,7 +2124,7 @@ class hashtable_impl } } else{ - const size_type new_n = priv_hash_to_bucket(n, new_buckets_len, new_buckets_len); + const size_type new_n = this->priv_hash_to_bucket(n, new_bucket_count, new_bucket_count); if(cache_begin && new_n < new_first_bucket_num) new_first_bucket_num = new_n; bucket_type &new_b = new_buckets[new_n]; @@ -2131,16 +2132,16 @@ class hashtable_impl new_b.splice_after( new_b.before_begin() , old_bucket , old_bucket.before_begin() - , priv_get_last(old_bucket)); + , hashtable_impl::priv_get_last(old_bucket)); } } } this->priv_size_traits().set_size(size_backup); - this->priv_split_traits().set_size(new_buckets_len); + this->priv_split_traits().set_size(new_bucket_count); this->priv_real_bucket_traits() = new_bucket_traits; - priv_initialize_cache(); - priv_insertion_update_cache(new_first_bucket_num); + this->priv_initialize_cache(); + this->priv_insertion_update_cache(new_first_bucket_num); rollback1.release(); rollback2.release(); } @@ -2158,57 +2159,57 @@ class hashtable_impl { //This function is only available for containers with incremental hashing BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); - size_type split_idx = priv_split_traits().get_size(); - size_type bucket_len = priv_buckets_len(); + const size_type split_idx = this->priv_split_traits().get_size(); + const size_type bucket_count = this->priv_bucket_count(); + const bucket_ptr bucket_pointer = this->priv_bucket_pointer(); if(grow){ //Test if the split variable can be changed - if(split_idx >= bucket_len) + if(split_idx >= bucket_count) return false; - size_type bucket_len = priv_buckets_len(); - size_type bucket_to_rehash = split_idx - bucket_len/2; - bucket_type &old_bucket = this->priv_buckets()[bucket_to_rehash]; + const size_type bucket_to_rehash = split_idx - bucket_count/2; + bucket_type &old_bucket = bucket_pointer[bucket_to_rehash]; siterator before_i(old_bucket.before_begin()); - siterator end(old_bucket.end()); + const siterator end(old_bucket.end()); siterator i(old_bucket.begin()); - priv_split_traits().increment(); + this->priv_split_traits().increment(); //Anti-exception stuff: if an exception is thrown while //moving elements from old_bucket to the target bucket, all moved //elements are moved back to the original one. detail::incremental_rehash_rollback rollback - ( this->priv_buckets()[split_idx], old_bucket, priv_split_traits()); + ( bucket_pointer[split_idx], old_bucket, this->priv_split_traits()); for(;i != end; ++i){ - const value_type &v = priv_value_from_slist_node(i.pointed_node()); + const value_type &v = this->priv_value_from_slist_node(i.pointed_node()); const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t()); - const size_type new_n = priv_hash_to_bucket(hash_value); + const size_type new_n = this->priv_hash_to_bucket(hash_value); siterator last = bucket_type::s_iterator_to (*group_functions_t::get_last_in_group - (dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); + (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t())); if(new_n == bucket_to_rehash){ before_i = last; } else{ - bucket_type &new_b = this->priv_buckets()[new_n]; + bucket_type &new_b = bucket_pointer[new_n]; new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last); } i = before_i; } rollback.release(); - priv_erasure_update_cache(); + this->priv_erasure_update_cache(); return true; } else{ //Test if the split variable can be changed - if(split_idx <= bucket_len/2) + if(split_idx <= bucket_count/2) return false; - const size_type target_bucket_num = split_idx - 1 - bucket_len/2; - bucket_type &target_bucket = this->priv_buckets()[target_bucket_num]; - bucket_type &source_bucket = this->priv_buckets()[split_idx-1]; + const size_type target_bucket_num = split_idx - 1 - bucket_count/2; + bucket_type &target_bucket = bucket_pointer[target_bucket_num]; + bucket_type &source_bucket = bucket_pointer[split_idx-1]; target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket); - priv_split_traits().decrement(); - priv_insertion_update_cache(target_bucket_num); + this->priv_split_traits().decrement(); + this->priv_insertion_update_cache(target_bucket_num); return true; } } @@ -2231,7 +2232,7 @@ class hashtable_impl //This function is only available for containers with incremental hashing BOOST_STATIC_ASSERT(( incremental && power_2_buckets )); size_type new_bucket_traits_size = new_bucket_traits.bucket_count(); - size_type cur_bucket_traits = this->priv_buckets_len(); + size_type cur_bucket_traits = this->priv_bucket_count(); if(new_bucket_traits_size/2 != cur_bucket_traits && new_bucket_traits_size != cur_bucket_traits/2){ return false; } @@ -2249,8 +2250,8 @@ class hashtable_impl return false; } - const size_type ini_n = priv_get_cache_bucket_num(); - const bucket_ptr old_buckets = this->priv_buckets(); + const size_type ini_n = this->priv_get_cache_bucket_num(); + const bucket_ptr old_buckets = this->priv_bucket_pointer(); this->priv_real_bucket_traits() = new_bucket_traits; if(new_bucket_traits.bucket_begin() != old_buckets){ for(size_type n = ini_n; n < split_idx; ++n){ @@ -2259,8 +2260,8 @@ class hashtable_impl new_bucket.splice_after(new_bucket.cbefore_begin(), old_bucket); } //Put cache to safe position - priv_initialize_cache(); - priv_insertion_update_cache(ini_n); + this->priv_initialize_cache(); + this->priv_insertion_update_cache(ini_n); } return true; } @@ -2321,22 +2322,22 @@ class hashtable_impl private: std::size_t priv_hash_to_bucket(std::size_t hash_value) const - { return priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), priv_split_traits().get_size()); } + { return this->priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); } - std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_len, std::size_t split) const + std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_count, std::size_t split) const { - std::size_t bucket_number = priv_hash_to_bucket_impl(hash_value, bucket_len, power_2_buckets_t()); + std::size_t bucket_number = hashtable_impl::priv_hash_to_bucket_impl(hash_value, bucket_count, power_2_buckets_t()); if(incremental) if(bucket_number >= split) - bucket_number -= bucket_len/2; + bucket_number -= bucket_count/2; return bucket_number; } - std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::false_) const - { return hash_value % bucket_len; } + static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::false_) + { return hash_value % bucket_count; } - std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_len, detail::true_) const - { return hash_value & (bucket_len - 1); } + static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_count, detail::true_) + { return hash_value & (bucket_count - 1); } const key_equal &priv_equal() const { return static_cast(this->data_.internal_.bucket_hash_equal_.get()); } @@ -2351,10 +2352,10 @@ class hashtable_impl { return data_; } value_type &priv_value_from_slist_node(slist_node_ptr n) - { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); } + { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); } const value_type &priv_value_from_slist_node(slist_node_ptr n) const - { return *this->get_real_value_traits().to_value_ptr(dcast_bucket_ptr(n)); } + { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); } const real_bucket_traits &priv_real_bucket_traits(detail::false_) const { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; } @@ -2386,15 +2387,12 @@ class hashtable_impl hasher &priv_hasher() { return static_cast(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); } - bucket_ptr priv_buckets() const + bucket_ptr priv_bucket_pointer() const { return this->priv_real_bucket_traits().bucket_begin(); } - size_type priv_buckets_len() const + size_type priv_bucket_count() const { return this->priv_real_bucket_traits().bucket_count(); } - static node_ptr uncast(const const_node_ptr & ptr) - { return node_ptr(const_cast(boost::intrusive::detail::to_raw_pointer(ptr))); } - node &priv_value_to_node(value_type &v) { return *this->get_real_value_traits().to_node_ptr(v); } @@ -2417,11 +2415,11 @@ class hashtable_impl void priv_erase_range_impl (size_type bucket_num, siterator before_first_it, siterator end, Disposer disposer, size_type &num_erased) { - const bucket_ptr buckets = priv_buckets(); + const bucket_ptr buckets = this->priv_bucket_pointer(); bucket_type &b = buckets[bucket_num]; if(before_first_it == b.before_begin() && end == b.end()){ - priv_erase_range_impl(bucket_num, 1, disposer, num_erased); + this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased); } else{ num_erased = 0; @@ -2429,7 +2427,7 @@ class hashtable_impl ++to_erase; slist_node_ptr end_ptr = end.pointed_node(); while(to_erase != end){ - group_functions_t::erase_from_group(end_ptr, dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t()); + group_functions_t::erase_from_group(end_ptr, hashtable_impl::dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t()); to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer)); ++num_erased; } @@ -2442,7 +2440,7 @@ class hashtable_impl (size_type first_bucket_num, size_type num_buckets, Disposer disposer, size_type &num_erased) { //Now fully clear the intermediate buckets - const bucket_ptr buckets = priv_buckets(); + const bucket_ptr buckets = this->priv_bucket_pointer(); num_erased = 0; for(size_type i = first_bucket_num; i < (num_buckets + first_bucket_num); ++i){ bucket_type &b = buckets[i]; @@ -2451,7 +2449,7 @@ class hashtable_impl ++nxt; siterator end(b.end()); while(nxt != end){ - group_functions_t::init_group(dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t()); + group_functions_t::init_group(hashtable_impl::dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t()); nxt = b.erase_after_and_dispose (b_begin, make_node_disposer(disposer)); this->priv_size_traits().decrement(); @@ -2467,14 +2465,14 @@ class hashtable_impl { size_type num_erased; if (first_bucket == last_bucket){ - priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased); + this->priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased); } else { - bucket_type *b = (&this->priv_buckets()[0]); - priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased); + bucket_type *b = (&this->priv_bucket_pointer()[0]); + this->priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased); if(size_type n = (last_bucket - first_bucket - 1)) - priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased); - priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased); + this->priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased); + this->priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased); } } @@ -2485,10 +2483,10 @@ class hashtable_impl { return node_traits::get_hash(this->get_real_value_traits().to_node_ptr(v)); } std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const - { return priv_hasher()(v); } + { return this->priv_hasher()(v); } std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) const - { return node_traits::get_hash(dcast_bucket_ptr(n)); } + { return node_traits::get_hash(hashtable_impl::dcast_bucket_ptr(n)); } std::size_t priv_stored_hash(slist_node_ptr, detail::false_) const { @@ -2501,7 +2499,7 @@ class hashtable_impl { siterator it(b.begin()), itend(b.end()); while(it != itend){ - node_ptr to_erase(dcast_bucket_ptr(it.pointed_node())); + node_ptr to_erase(hashtable_impl::dcast_bucket_ptr(it.pointed_node())); ++it; group_algorithms::init(to_erase); } @@ -2511,7 +2509,7 @@ class hashtable_impl {} std::size_t priv_get_bucket_num(siterator it) - { return priv_get_bucket_num_hash_dispatch(it, store_hash_t()); } + { return this->priv_get_bucket_num_hash_dispatch(it, store_hash_t()); } std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_) { @@ -2520,15 +2518,15 @@ class hashtable_impl } std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_) - { return priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); } + { return this->priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); } std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_) { - bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); + const bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1); slist_node_ptr bb = group_functions_t::get_bucket_before_begin ( f->end().pointed_node() , l->end().pointed_node() - , dcast_bucket_ptr(it.pointed_node())); + , hashtable_impl::dcast_bucket_ptr(it.pointed_node())); //Now get the bucket_impl from the iterator const bucket_type &b = static_cast (bucket_type::slist_type::container_from_end_iterator(bucket_type::s_iterator_to(*bb))); @@ -2538,7 +2536,7 @@ class hashtable_impl std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_) { - bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); + bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1); slist_node_ptr first_ptr(f->cend().pointed_node()) , last_ptr(l->cend().pointed_node()); @@ -2557,12 +2555,12 @@ class hashtable_impl siterator priv_get_previous (bucket_type &b, siterator i) - { return priv_get_previous(b, i, optimize_multikey_t()); } + { return this->priv_get_previous(b, i, optimize_multikey_t()); } siterator priv_get_previous (bucket_type &b, siterator i, detail::true_) { - node_ptr elem(dcast_bucket_ptr(i.pointed_node())); + node_ptr elem(hashtable_impl::dcast_bucket_ptr(i.pointed_node())); node_ptr prev_in_group(group_traits::get_next(elem)); bool first_in_group = node_traits::get_next(prev_in_group) != elem; typename bucket_type::node &n = first_in_group @@ -2577,7 +2575,7 @@ class hashtable_impl { return b.previous(i); } static siterator priv_get_last(bucket_type &b) - { return priv_get_last(b, optimize_multikey_t()); } + { return hashtable_impl::priv_get_last(b, optimize_multikey_t()); } static siterator priv_get_last(bucket_type &b, detail::true_) { @@ -2585,11 +2583,11 @@ class hashtable_impl //This requires checking the first node of the next group or //the bucket node. slist_node_ptr end_ptr(b.end().pointed_node()); - node_ptr possible_end(node_traits::get_next( dcast_bucket_ptr(end_ptr))); + node_ptr possible_end(node_traits::get_next( hashtable_impl::dcast_bucket_ptr(end_ptr))); node_ptr last_node_group(possible_end); while(end_ptr != possible_end){ - last_node_group = group_traits::get_next(dcast_bucket_ptr(possible_end)); + last_node_group = group_traits::get_next(hashtable_impl::dcast_bucket_ptr(possible_end)); possible_end = node_traits::get_next(last_node_group); } return bucket_type::s_iterator_to(*last_node_group); @@ -2597,87 +2595,7 @@ class hashtable_impl static siterator priv_get_last(bucket_type &b, detail::false_) { return b.previous(b.end()); } -/* - siterator priv_get_previous_and_next_in_group - (siterator i, node_ptr &nxt_in_group) - { - siterator prev; - node_ptr elem(dcast_bucket_ptr(i.pointed_node())); - bucket_ptr f(priv_buckets()), l(f + priv_buckets_len() - 1); - slist_node_ptr first_end_ptr(f->cend().pointed_node()); - slist_node_ptr last_end_ptr (l->cend().pointed_node()); - - node_ptr nxt(node_traits::get_next(elem)); - node_ptr prev_in_group(group_traits::get_next(elem)); - bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr) || - (group_traits::get_next(nxt) != elem); - bool first_in_group = node_traits::get_next(prev_in_group) != elem; - - if(first_in_group){ - node_ptr start_pos; - if(last_in_group){ - start_pos = elem; - nxt_in_group = node_ptr(); - } - else{ - start_pos = prev_in_group; - nxt_in_group = node_traits::get_next(elem); - } - slist_node_ptr bucket_node; - if(store_hash){ - bucket_node = this->priv_buckets() - [this->priv_hash_to_bucket - (this->priv_stored_hash(elem, store_hash_t())) - ].before_begin().pointed_node(); - } - else{ - bucket_node = group_functions_t::get_bucket_before_begin - (first_end_ptr, last_end_ptr, start_pos); - } - prev = bucket_type::s_iterator_to - (*group_functions_t::get_prev_to_first_in_group(bucket_node, elem)); - } - else{ - if(last_in_group){ - nxt_in_group = group_functions_t::get_first_in_group_of_last_in_group(elem); - } - else{ - nxt_in_group = node_traits::get_next(elem); - } - prev = bucket_type::s_iterator_to(*group_traits::get_next(elem)); - } - return prev; - } -*/ - -/* - template - void priv_erase(const_iterator i, Disposer disposer, detail::true_) - { - siterator elem(i.slist_it()); - node_ptr nxt_in_group; - siterator prev = priv_get_previous_and_next_in_group(elem, nxt_in_group); - bucket_type::s_erase_after_and_dispose(prev, make_node_disposer(disposer)); - if(nxt_in_group) - group_algorithms::unlink_after(nxt_in_group); - if(safemode_or_autounlink) - group_algorithms::init(dcast_bucket_ptr(elem.pointed_node())); - } -*/ - -/* - if(store_hash){ - bucket_node = this->priv_buckets() - [this->priv_hash_to_bucket - (this->priv_stored_hash(elem, store_hash_t())) - ].before_begin().pointed_node(); - } - else{ - bucket_node = group_functions_t::get_bucket_before_begin - (first_end_ptr, last_end_ptr, start_pos); - } -*/ template void priv_erase(const_iterator i, Disposer disposer, detail::true_) { @@ -2685,14 +2603,14 @@ class hashtable_impl slist_node_ptr f_bucket_end, l_bucket_end; if(store_hash){ f_bucket_end = l_bucket_end = - (this->priv_buckets() + (this->priv_bucket_pointer() [this->priv_hash_to_bucket (this->priv_stored_hash(elem, store_hash_t())) ]).before_begin().pointed_node(); } else{ - f_bucket_end = this->priv_buckets()->cend().pointed_node(); - l_bucket_end = f_bucket_end + priv_buckets_len() - 1; + f_bucket_end = this->priv_bucket_pointer()->cend().pointed_node(); + l_bucket_end = f_bucket_end + this->priv_bucket_count() - 1; } node_ptr nxt_in_group; siterator prev = bucket_type::s_iterator_to @@ -2703,15 +2621,15 @@ class hashtable_impl if(nxt_in_group) group_algorithms::unlink_after(nxt_in_group); if(safemode_or_autounlink) - group_algorithms::init(dcast_bucket_ptr(elem)); + group_algorithms::init(hashtable_impl::dcast_bucket_ptr(elem)); } template void priv_erase(const_iterator i, Disposer disposer, detail::false_) { siterator to_erase(i.slist_it()); - bucket_type &b = this->priv_buckets()[this->priv_get_bucket_num(to_erase)]; - siterator prev(priv_get_previous(b, to_erase)); + bucket_type &b = this->priv_bucket_pointer()[this->priv_get_bucket_num(to_erase)]; + siterator prev(this->priv_get_previous(b, to_erase)); b.erase_after_and_dispose(prev, make_node_disposer(disposer)); } @@ -2722,28 +2640,28 @@ class hashtable_impl } siterator priv_invalid_local_it() const - { return priv_invalid_bucket()->end(); } + { return this->priv_invalid_bucket()->end(); } siterator priv_begin() const - { return priv_begin(cache_begin_t()); } + { return this->priv_begin(cache_begin_t()); } siterator priv_begin(detail::false_) const { size_type n = 0; - size_type buckets_len = this->priv_buckets_len(); - for (n = 0; n < buckets_len; ++n){ - bucket_type &b = this->priv_buckets()[n]; + size_type bucket_count = this->priv_bucket_count(); + for (n = 0; n < bucket_count; ++n){ + bucket_type &b = this->priv_bucket_pointer()[n]; if(!b.empty()){ return b.begin(); } } - return priv_invalid_local_it(); + return this->priv_invalid_local_it(); } siterator priv_begin(detail::true_) const { - if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == priv_invalid_bucket()){ - return priv_invalid_local_it(); + if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == this->priv_invalid_bucket()){ + return this->priv_invalid_local_it(); } else{ return this->data_.internal_.bucket_hash_equal_.cached_begin_->begin(); @@ -2751,20 +2669,20 @@ class hashtable_impl } void priv_initialize_cache() - { priv_initialize_cache(cache_begin_t()); } + { this->priv_initialize_cache(cache_begin_t()); } void priv_initialize_cache(detail::true_) - { this->data_.internal_.bucket_hash_equal_.cached_begin_ = priv_invalid_bucket(); } + { this->data_.internal_.bucket_hash_equal_.cached_begin_ = this->priv_invalid_bucket(); } void priv_initialize_cache(detail::false_) {} void priv_insertion_update_cache(size_type insertion_bucket) - { priv_insertion_update_cache(insertion_bucket, cache_begin_t()); } + { this->priv_insertion_update_cache(insertion_bucket, cache_begin_t()); } void priv_insertion_update_cache(size_type insertion_bucket, detail::true_) { - bucket_ptr p = priv_buckets() + insertion_bucket; + bucket_ptr p = this->priv_bucket_pointer() + insertion_bucket; if(p < this->data_.internal_.bucket_hash_equal_.cached_begin_){ this->data_.internal_.bucket_hash_equal_.cached_begin_ = p; } @@ -2774,16 +2692,16 @@ class hashtable_impl {} void priv_erasure_update_cache(size_type first_bucket, size_type last_bucket) - { priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); } + { this->priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); } void priv_erasure_update_cache(size_type first_bucket_num, size_type last_bucket_num, detail::true_) { //If the last bucket is the end, the cache must be updated //to the last position if all - if(priv_get_cache_bucket_num() == first_bucket_num && - priv_buckets()[first_bucket_num].empty() ){ - priv_set_cache(priv_buckets() + last_bucket_num); - priv_erasure_update_cache(); + if(this->priv_get_cache_bucket_num() == first_bucket_num && + this->priv_bucket_pointer()[first_bucket_num].empty() ){ + this->priv_set_cache(this->priv_bucket_pointer() + last_bucket_num); + this->priv_erasure_update_cache(); } } @@ -2791,23 +2709,23 @@ class hashtable_impl {} void priv_erasure_update_cache() - { priv_erasure_update_cache(cache_begin_t()); } + { this->priv_erasure_update_cache(cache_begin_t()); } void priv_erasure_update_cache(detail::true_) { if(constant_time_size && !size()){ - priv_initialize_cache(); + this->priv_initialize_cache(); } else{ - size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - priv_buckets(); - for( const size_type num_buckets = this->priv_buckets_len() + size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer(); + for( const size_type num_buckets = this->priv_bucket_count() ; current_n < num_buckets ; ++current_n, ++this->data_.internal_.bucket_hash_equal_.cached_begin_){ if(!this->data_.internal_.bucket_hash_equal_.cached_begin_->empty()){ return; } } - priv_initialize_cache(); + this->priv_initialize_cache(); } } @@ -2824,22 +2742,22 @@ class hashtable_impl {} bucket_ptr priv_get_cache() - { return priv_get_cache(cache_begin_t()); } + { return this->priv_get_cache(cache_begin_t()); } bucket_ptr priv_get_cache(detail::true_) { return this->data_.internal_.bucket_hash_equal_.cached_begin_; } bucket_ptr priv_get_cache(detail::false_) - { return this->priv_buckets(); } + { return this->priv_bucket_pointer(); } void priv_set_cache(const bucket_ptr &p) { this->data_.internal_.bucket_hash_equal_.set_cache(p); } size_type priv_get_cache_bucket_num() - { return priv_get_cache_bucket_num(cache_begin_t()); } + { return this->priv_get_cache_bucket_num(cache_begin_t()); } size_type priv_get_cache_bucket_num(detail::true_) - { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_buckets(); } + { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer(); } size_type priv_get_cache_bucket_num(detail::false_) { return 0u; } @@ -2847,25 +2765,25 @@ class hashtable_impl void priv_clear_buckets() { this->priv_clear_buckets - ( priv_get_cache() - , this->priv_buckets_len() - (priv_get_cache() - priv_buckets())); + ( this->priv_get_cache() + , this->priv_bucket_count() - (this->priv_get_cache() - this->priv_bucket_pointer())); } void priv_initialize_buckets() - { this->priv_clear_buckets(priv_buckets(), this->priv_buckets_len()); } + { this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); } - void priv_clear_buckets(bucket_ptr buckets_ptr, size_type buckets_len) + void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_count) { - for(; buckets_len--; ++buckets_ptr){ + for(; bucket_count--; ++buckets_ptr){ if(safemode_or_autounlink){ - priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t()); + hashtable_impl::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t()); buckets_ptr->clear_and_dispose(detail::init_disposer()); } else{ buckets_ptr->clear(); } } - priv_initialize_cache(); + this->priv_initialize_cache(); } template @@ -2874,25 +2792,25 @@ class hashtable_impl , KeyValueEqual equal_func, size_type &bucket_number, std::size_t &h, siterator &previt) const { h = hash_func(key); - return priv_find_with_hash(key, equal_func, bucket_number, h, previt); + return this->priv_find_with_hash(key, equal_func, bucket_number, h, previt); } template siterator priv_find_with_hash ( const KeyType &key, KeyValueEqual equal_func, size_type &bucket_number, const std::size_t h, siterator &previt) const { - bucket_number = priv_hash_to_bucket(h); - bucket_type &b = this->priv_buckets()[bucket_number]; + bucket_number = this->priv_hash_to_bucket(h); + bucket_type &b = this->priv_bucket_pointer()[bucket_number]; previt = b.before_begin(); if(constant_time_size && this->empty()){ - return priv_invalid_local_it(); + return this->priv_invalid_local_it(); } siterator it = previt; ++it; while(it != b.end()){ - const value_type &v = priv_value_from_slist_node(it.pointed_node()); + const value_type &v = this->priv_value_from_slist_node(it.pointed_node()); if(compare_hash){ std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t()); if(h == vh && equal_func(key, v)){ @@ -2905,7 +2823,7 @@ class hashtable_impl if(optimize_multikey){ previt = bucket_type::s_iterator_to (*group_functions_t::get_last_in_group - (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())); + (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())); it = previt; } else{ @@ -2914,7 +2832,7 @@ class hashtable_impl ++it; } previt = b.before_begin(); - return priv_invalid_local_it(); + return this->priv_invalid_local_it(); } iterator priv_insert_equal_with_hash(reference value, std::size_t hash_value) @@ -2923,18 +2841,18 @@ class hashtable_impl siterator prev; siterator it = this->priv_find_with_hash (value, this->priv_equal(), bucket_num, hash_value, prev); - return priv_insert_equal_find(value, bucket_num, hash_value, it); + return this->priv_insert_equal_find(value, bucket_num, hash_value, it); } iterator priv_insert_equal_find(reference value, size_type bucket_num, std::size_t hash_value, siterator it) { - bucket_type &b = this->priv_buckets()[bucket_num]; - bool found_equal = it != priv_invalid_local_it(); + bucket_type &b = this->priv_bucket_pointer()[bucket_num]; + bool found_equal = it != this->priv_invalid_local_it(); if(!found_equal){ it = b.before_begin(); } //Now store hash if needed - node_ptr n = pointer_traits::pointer_to(priv_value_to_node(value)); + node_ptr n = pointer_traits::pointer_to(this->priv_value_to_node(value)); node_functions_t::store_hash(n, hash_value, store_hash_t()); //Checks for some modes if(safemode_or_autounlink) @@ -2942,11 +2860,11 @@ class hashtable_impl //Shorcut for optimize_multikey cases if(optimize_multikey){ node_ptr first_in_group = found_equal ? - dcast_bucket_ptr(it.pointed_node()) : node_ptr(); + hashtable_impl::dcast_bucket_ptr(it.pointed_node()) : node_ptr(); group_functions_t::insert_in_group(first_in_group, n, optimize_multikey_t()); } //Update cache and increment size if needed - priv_insertion_update_cache(bucket_num); + this->priv_insertion_update_cache(bucket_num); this->priv_size_traits().increment(); //Insert the element in the bucket after it return iterator(b.insert_after(it, *n), this); @@ -2966,20 +2884,20 @@ class hashtable_impl siterator prev; //Let's see if the element is present std::pair to_return - ( priv_find(key, hash_func, equal_func, bucket_number_first, h, prev) - , priv_invalid_local_it()); + ( this->priv_find(key, hash_func, equal_func, bucket_number_first, h, prev) + , this->priv_invalid_local_it()); if(to_return.first == to_return.second){ bucket_number_second = bucket_number_first; return to_return; } //If it's present, find the first that it's not equal in //the same bucket - bucket_type &b = this->priv_buckets()[bucket_number_first]; + bucket_type &b = this->priv_bucket_pointer()[bucket_number_first]; siterator it = to_return.first; if(optimize_multikey){ to_return.second = bucket_type::s_iterator_to (*node_traits::get_next(group_functions_t::get_last_in_group - (dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); + (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()))); count = std::distance(it, to_return.second); if(to_return.second != b.end()){ bucket_number_second = bucket_number_first; @@ -2990,7 +2908,7 @@ class hashtable_impl ++count; ++it; while(it != b.end()){ - const value_type &v = priv_value_from_slist_node(it.pointed_node()); + const value_type &v = this->priv_value_from_slist_node(it.pointed_node()); if(compare_hash){ std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t()); if(hv != h || !equal_func(key, v)){ @@ -3011,9 +2929,9 @@ class hashtable_impl //If we reached the end, find the first, non-empty bucket for(bucket_number_second = bucket_number_first+1 - ; bucket_number_second != this->priv_buckets_len() + ; bucket_number_second != this->priv_bucket_count() ; ++bucket_number_second){ - bucket_type &b = this->priv_buckets()[bucket_number_second]; + bucket_type &b = this->priv_bucket_pointer()[bucket_number_second]; if(!b.empty()){ to_return.second = b.begin(); return to_return; @@ -3021,7 +2939,7 @@ class hashtable_impl } //Otherwise, return the end node - to_return.second = priv_invalid_local_it(); + to_return.second = this->priv_invalid_local_it(); return to_return; } /// @endcond @@ -3055,7 +2973,9 @@ struct make_hashtable_opt typedef typename detail::get_value_traits ::type value_traits; static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value;/* + static const bool resizable_bucket_traits = + detail::resizable_bool_is_true::value;*/ typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index 5450bc5..569d942 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -83,7 +83,7 @@ class list_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/options.hpp b/include/boost/intrusive/options.hpp index e657438..b1dd944 100644 --- a/include/boost/intrusive/options.hpp +++ b/include/boost/intrusive/options.hpp @@ -57,12 +57,6 @@ struct eval_value_traits typedef typename ValueTraits::value_traits type; }; -template -struct external_bucket_traits_is_true -{ - static const bool value = external_bucket_traits_bool::value == 3; -}; - template struct eval_bucket_traits { diff --git a/include/boost/intrusive/pointer_traits.hpp b/include/boost/intrusive/pointer_traits.hpp index 3ed1afb..98ca6b9 100644 --- a/include/boost/intrusive/pointer_traits.hpp +++ b/include/boost/intrusive/pointer_traits.hpp @@ -170,7 +170,7 @@ struct pointer_traits template static pointer priv_static_cast_from(boost::false_type, const UPtr &uptr) - { return pointer_to(static_cast(*uptr)); } + { return pointer_to(*static_cast(to_raw_pointer(uptr))); } //priv_const_cast_from template diff --git a/include/boost/intrusive/rbtree.hpp b/include/boost/intrusive/rbtree.hpp index 1c0c30e..2f3ee56 100644 --- a/include/boost/intrusive/rbtree.hpp +++ b/include/boost/intrusive/rbtree.hpp @@ -89,7 +89,7 @@ class rbtree_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/rbtree_algorithms.hpp b/include/boost/intrusive/rbtree_algorithms.hpp index 451a550..fc28630 100644 --- a/include/boost/intrusive/rbtree_algorithms.hpp +++ b/include/boost/intrusive/rbtree_algorithms.hpp @@ -805,26 +805,26 @@ class rbtree_algorithms // NodeTraits::get_parent(NodeTraits::get_parent(p)) == p; } - static void rebalance_after_erasure(const node_ptr & header, const node_ptr &xnode, const node_ptr &xnode_parent) + static void rebalance_after_erasure(const node_ptr & header, node_ptr x, node_ptr x_parent) { - node_ptr x(xnode), x_parent(xnode_parent); - while(x != NodeTraits::get_parent(header) && (x == node_ptr() || NodeTraits::get_color(x) == NodeTraits::black())){ + while(x != NodeTraits::get_parent(header) && (!x || NodeTraits::get_color(x) == NodeTraits::black())){ if(x == NodeTraits::get_left(x_parent)){ node_ptr w = NodeTraits::get_right(x_parent); + BOOST_ASSERT(w); if(NodeTraits::get_color(w) == NodeTraits::red()){ NodeTraits::set_color(w, NodeTraits::black()); NodeTraits::set_color(x_parent, NodeTraits::red()); tree_algorithms::rotate_left(x_parent, header); w = NodeTraits::get_right(x_parent); } - if((NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()) && - (NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black())){ + if((!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()) && + (!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black())){ NodeTraits::set_color(w, NodeTraits::red()); x = x_parent; x_parent = NodeTraits::get_parent(x_parent); } else { - if(NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()){ + if(!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()){ NodeTraits::set_color(NodeTraits::get_left(w), NodeTraits::black()); NodeTraits::set_color(w, NodeTraits::red()); tree_algorithms::rotate_right(w, header); @@ -847,14 +847,14 @@ class rbtree_algorithms tree_algorithms::rotate_right(x_parent, header); w = NodeTraits::get_left(x_parent); } - if((NodeTraits::get_right(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()) && - (NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black())){ + if((!NodeTraits::get_right(w) || NodeTraits::get_color(NodeTraits::get_right(w)) == NodeTraits::black()) && + (!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black())){ NodeTraits::set_color(w, NodeTraits::red()); x = x_parent; x_parent = NodeTraits::get_parent(x_parent); } else { - if(NodeTraits::get_left(w) == node_ptr() || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()){ + if(!NodeTraits::get_left(w) || NodeTraits::get_color(NodeTraits::get_left(w)) == NodeTraits::black()){ NodeTraits::set_color(NodeTraits::get_right(w), NodeTraits::black()); NodeTraits::set_color(w, NodeTraits::red()); tree_algorithms::rotate_left(w, header); @@ -874,9 +874,8 @@ class rbtree_algorithms } - static void rebalance_after_insertion(const node_ptr & header, const node_ptr &pnode) + static void rebalance_after_insertion(const node_ptr & header, node_ptr p) { - node_ptr p(pnode); NodeTraits::set_color(p, NodeTraits::red()); while(p != NodeTraits::get_parent(header) && NodeTraits::get_color(NodeTraits::get_parent(p)) == NodeTraits::red()){ node_ptr p_parent(NodeTraits::get_parent(p)); diff --git a/include/boost/intrusive/sgtree.hpp b/include/boost/intrusive/sgtree.hpp index f181f54..00de67f 100644 --- a/include/boost/intrusive/sgtree.hpp +++ b/include/boost/intrusive/sgtree.hpp @@ -215,7 +215,7 @@ class sgtree_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index d7fc131..6c9ac53 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -112,7 +112,7 @@ class slist_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/splaytree.hpp b/include/boost/intrusive/splaytree.hpp index a1c5209..e559ee7 100644 --- a/include/boost/intrusive/splaytree.hpp +++ b/include/boost/intrusive/splaytree.hpp @@ -88,7 +88,7 @@ class splaytree_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits diff --git a/include/boost/intrusive/treap.hpp b/include/boost/intrusive/treap.hpp index b539acc..006b2d9 100644 --- a/include/boost/intrusive/treap.hpp +++ b/include/boost/intrusive/treap.hpp @@ -91,7 +91,7 @@ class treap_impl typedef typename Config::value_traits value_traits; /// @cond static const bool external_value_traits = - detail::external_value_traits_is_true::value; + detail::external_value_traits_bool_is_true::value; typedef typename detail::eval_if_c < external_value_traits , detail::eval_value_traits