Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77831 - in trunk/boost/unordered: . detail
From: dnljms_at_[hidden]
Date: 2012-04-08 11:28:27


Author: danieljames
Date: 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
New Revision: 77831
URL: http://svn.boost.org/trac/boost/changeset/77831

Log:
Unordered: Call policy functions as static functions.
Text files modified:
   trunk/boost/unordered/detail/buckets.hpp | 15 +++++++++------
   trunk/boost/unordered/detail/equivalent.hpp | 30 +++++++++++++++++++-----------
   trunk/boost/unordered/detail/table.hpp | 12 ++++++------
   trunk/boost/unordered/detail/unique.hpp | 27 +++++++++++++++++----------
   trunk/boost/unordered/unordered_map.hpp | 4 ++--
   trunk/boost/unordered/unordered_set.hpp | 4 ++--
   6 files changed, 55 insertions(+), 37 deletions(-)

Modified: trunk/boost/unordered/detail/buckets.hpp
==============================================================================
--- trunk/boost/unordered/detail/buckets.hpp (original)
+++ trunk/boost/unordered/detail/buckets.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -280,6 +280,7 @@
         typedef boost::unordered::detail::allocator_traits<A> traits;
         typedef typename traits::value_type value_type;
 
+ typedef Policy policy;
         typedef Node node;
         typedef Bucket bucket;
         typedef typename boost::unordered::detail::rebind_wrap<A, node>::type
@@ -334,7 +335,7 @@
         std::size_t max_bucket_count() const
         {
             // -1 to account for the start bucket.
- return this->prev_bucket_count(
+ return policy::prev_bucket_count(
                 bucket_allocator_traits::max_size(bucket_alloc()) - 1);
         }
 
@@ -379,7 +380,8 @@
             if (!ptr) return 0;
 
             std::size_t count = 0;
- while(ptr && this->to_bucket(this->bucket_count_, ptr->hash_) == index)
+ while(ptr &&
+ policy::to_bucket(this->bucket_count_, ptr->hash_) == index)
             {
                 ++count;
                 ptr = static_cast<node_pointer>(ptr->next_);
@@ -574,7 +576,7 @@
             else
             {
                 bucket_pointer next_bucket = this->get_bucket(
- this->to_bucket(this->bucket_count_, next->hash_));
+ policy::to_bucket(this->bucket_count_, next->hash_));
 
                 if (next_bucket != bucket)
                 {
@@ -600,7 +602,7 @@
                     if (n == end) return;
     
                     std::size_t new_bucket_index =
- this->to_bucket(this->bucket_count_, n->hash_);
+ policy::to_bucket(this->bucket_count_, n->hash_);
                     if (bucket_index != new_bucket_index) {
                         bucket_index = new_bucket_index;
                         break;
@@ -616,7 +618,7 @@
                 if (n == end) break;
     
                 std::size_t new_bucket_index =
- this->to_bucket(this->bucket_count_, n->hash_);
+ policy::to_bucket(this->bucket_count_, n->hash_);
                 if (bucket_index != new_bucket_index) {
                     bucket_index = new_bucket_index;
                     this->get_bucket(bucket_index)->next_ = previous_pointer();
@@ -625,7 +627,8 @@
     
             // Finally fix the bucket containing the trailing node.
             if (n) {
- this->get_bucket(this->to_bucket(this->bucket_count_, n->hash_))->next_
+ this->get_bucket(
+ policy::to_bucket(this->bucket_count_, n->hash_))->next_
                     = prev;
             }
         }

Modified: trunk/boost/unordered/detail/equivalent.hpp
==============================================================================
--- trunk/boost/unordered/detail/equivalent.hpp (original)
+++ trunk/boost/unordered/detail/equivalent.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -173,6 +173,7 @@
         typedef typename table::value_type value_type;
         typedef typename table::bucket bucket;
         typedef typename table::buckets buckets;
+ typedef typename table::policy policy;
         typedef typename table::node_pointer node_pointer;
         typedef typename table::node_allocator node_allocator;
         typedef typename table::node_allocator_traits node_allocator_traits;
@@ -223,7 +224,8 @@
                 Key const& k,
                 Pred const& eq) const
         {
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, hash);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, hash);
             node_pointer n = this->get_start(bucket_index);
 
             for (;;)
@@ -238,7 +240,8 @@
                 }
                 else
                 {
- if (this->to_bucket(this->bucket_count_, node_hash) != bucket_index)
+ if (policy::to_bucket(this->bucket_count_, node_hash)
+ != bucket_index)
                         return node_pointer();
                 }
 
@@ -401,23 +404,25 @@
             if(pos) {
                 this->add_after_node(n, pos);
                 if (n->next_) {
- std::size_t next_bucket = this->to_bucket(
+ std::size_t next_bucket = policy::to_bucket(
                         this->bucket_count_,
                         static_cast<node_pointer>(n->next_)->hash_);
- if (next_bucket != this->to_bucket(this->bucket_count_, hash)) {
+ if (next_bucket !=
+ policy::to_bucket(this->bucket_count_, hash)) {
                         this->get_bucket(next_bucket)->next_ = n;
                     }
                 }
             }
             else {
- bucket_pointer b = this->get_bucket(this->to_bucket(this->bucket_count_, hash));
+ bucket_pointer b = this->get_bucket(
+ policy::to_bucket(this->bucket_count_, hash));
 
                 if (!b->next_)
                 {
                     previous_pointer start_node = this->get_previous_start();
                     
                     if (start_node->next_) {
- this->get_bucket(this->to_bucket(this->bucket_count_,
+ this->get_bucket(policy::to_bucket(this->bucket_count_,
                             static_cast<node_pointer>(start_node->next_)->hash_
                         ))->next_ = n;
                     }
@@ -528,7 +533,8 @@
             if(!this->size_) return 0;
 
             std::size_t hash = this->hash(k);
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, hash);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, hash);
             bucket_pointer bucket = this->get_bucket(bucket_index);
 
             previous_pointer prev = bucket->next_;
@@ -539,7 +545,8 @@
                 if (!prev->next_) return 0;
                 std::size_t node_hash =
                     static_cast<node_pointer>(prev->next_)->hash_;
- if (this->to_bucket(this->bucket_count_, node_hash) != bucket_index)
+ if (policy::to_bucket(this->bucket_count_, node_hash)
+ != bucket_index)
                     return 0;
                 if (node_hash == hash &&
                     this->key_eq()(k, this->get_key(
@@ -564,7 +571,7 @@
             node_pointer next = static_cast<node_pointer>(r->next_);
 
             bucket_pointer bucket = this->get_bucket(
- this->to_bucket(this->bucket_count_, r->hash_));
+ policy::to_bucket(this->bucket_count_, r->hash_));
             previous_pointer prev = unlink_node(*bucket, r);
 
             this->fix_buckets(bucket, prev, next);
@@ -578,7 +585,8 @@
         {
             if (r1 == r2) return r2;
 
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, r1->hash_);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, r1->hash_);
             previous_pointer prev = unlink_nodes(
                 *this->get_bucket(bucket_index), r1, r2);
             this->fix_buckets_range(bucket_index, prev, r1, r2);
@@ -813,7 +821,7 @@
         static previous_pointer place_in_bucket(buckets& dst,
                 previous_pointer prev, node_pointer end)
         {
- bucket_pointer b = dst.get_bucket(dst.to_bucket(
+ bucket_pointer b = dst.get_bucket(policy::to_bucket(
                         dst.bucket_count_, end->hash_));
 
             if (!b->next_) {

Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -402,7 +402,7 @@
             // Or from rehash post-condition:
             // count > size / mlf_
 
- return this->new_bucket_count(
+ return policy::new_bucket_count(
                 boost::unordered::detail::double_to_size(floor(
                     static_cast<double>(size) /
                     static_cast<double>(mlf_))) + 1);
@@ -415,7 +415,7 @@
                 hasher const& hf,
                 key_equal const& eq,
                 node_allocator const& a) :
- buckets(a, this->new_bucket_count(num_buckets)),
+ buckets(a, policy::new_bucket_count(num_buckets)),
             functions(hf, eq),
             mlf_(1.0f),
             max_load_(0)
@@ -595,7 +595,7 @@
 
         std::size_t hash(key_type const& k) const
         {
- return this->apply_hash(this->hash_function(), k);
+ return policy::apply_hash(this->hash_function(), k);
         }
 
         // Find Node
@@ -608,7 +608,7 @@
         {
             if (!this->size_) return node_pointer();
             return static_cast<table_impl const*>(this)->
- find_node_impl(this->apply_hash(hash_function, k), k, eq);
+ find_node_impl(policy::apply_hash(hash_function, k), k, eq);
         }
 
         node_pointer find_node(
@@ -678,10 +678,10 @@
 
         if(!this->size_) {
             if(this->buckets_) this->delete_buckets();
- this->bucket_count_ = this->new_bucket_count(min_buckets);
+ this->bucket_count_ = policy::new_bucket_count(min_buckets);
         }
         else {
- min_buckets = this->new_bucket_count((std::max)(min_buckets,
+ min_buckets = policy::new_bucket_count((std::max)(min_buckets,
                 boost::unordered::detail::double_to_size(floor(
                     static_cast<double>(this->size_) /
                     static_cast<double>(mlf_))) + 1));

Modified: trunk/boost/unordered/detail/unique.hpp
==============================================================================
--- trunk/boost/unordered/detail/unique.hpp (original)
+++ trunk/boost/unordered/detail/unique.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -169,6 +169,7 @@
         typedef typename table::value_type value_type;
         typedef typename table::bucket bucket;
         typedef typename table::buckets buckets;
+ typedef typename table::policy policy;
         typedef typename table::node_pointer node_pointer;
         typedef typename table::node_allocator node_allocator;
         typedef typename table::node_allocator_traits node_allocator_traits;
@@ -221,7 +222,8 @@
                 Key const& k,
                 Pred const& eq) const
         {
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, hash);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, hash);
             node_pointer n = this->get_start(bucket_index);
 
             for (;;)
@@ -236,7 +238,8 @@
                 }
                 else
                 {
- if (this->to_bucket(this->bucket_count_, node_hash) != bucket_index)
+ if (policy::to_bucket(this->bucket_count_, node_hash)
+ != bucket_index)
                         return node_pointer();
                 }
 
@@ -302,14 +305,15 @@
             node_pointer n = a.release();
             n->hash_ = hash;
     
- bucket_pointer b = this->get_bucket(this->to_bucket(this->bucket_count_, hash));
+ bucket_pointer b = this->get_bucket(
+ policy::to_bucket(this->bucket_count_, hash));
 
             if (!b->next_)
             {
                 previous_pointer start_node = this->get_previous_start();
                 
                 if (start_node->next_) {
- this->get_bucket(this->to_bucket(this->bucket_count_,
+ this->get_bucket(policy::to_bucket(this->bucket_count_,
                         static_cast<node_pointer>(start_node->next_)->hash_)
                     )->next_ = n;
                 }
@@ -528,7 +532,8 @@
             if(!this->size_) return 0;
 
             std::size_t hash = this->hash(k);
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, hash);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, hash);
             bucket_pointer bucket = this->get_bucket(bucket_index);
 
             previous_pointer prev = bucket->next_;
@@ -539,7 +544,8 @@
                 if (!prev->next_) return 0;
                 std::size_t node_hash =
                     static_cast<node_pointer>(prev->next_)->hash_;
- if (this->to_bucket(this->bucket_count_, node_hash) != bucket_index)
+ if (policy::to_bucket(this->bucket_count_, node_hash)
+ != bucket_index)
                     return 0;
                 if (node_hash == hash &&
                         this->key_eq()(k, this->get_key(
@@ -561,7 +567,7 @@
             node_pointer next = static_cast<node_pointer>(r->next_);
 
             bucket_pointer bucket = this->get_bucket(
- this->to_bucket(this->bucket_count_, r->hash_));
+ policy::to_bucket(this->bucket_count_, r->hash_));
             previous_pointer prev = unlink_node(*bucket, r);
 
             this->fix_buckets(bucket, prev, next);
@@ -575,7 +581,8 @@
         {
             if (r1 == r2) return r2;
 
- std::size_t bucket_index = this->to_bucket(this->bucket_count_, r1->hash_);
+ std::size_t bucket_index =
+ policy::to_bucket(this->bucket_count_, r1->hash_);
             previous_pointer prev = unlink_nodes(
                 *this->get_bucket(bucket_index), r1, r2);
             this->fix_buckets_range(bucket_index, prev, r1, r2);
@@ -693,8 +700,8 @@
                 previous_pointer prev)
         {
             node_pointer n = static_cast<node_pointer>(prev->next_);
- bucket_pointer b = dst.get_bucket(dst.to_bucket(dst.bucket_count_,
- n->hash_));
+ bucket_pointer b = dst.get_bucket(
+ buckets::to_bucket(dst.bucket_count_, n->hash_));
 
             if (!b->next_) {
                 b->next_ = prev;

Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -465,7 +465,7 @@
 
         size_type bucket(const key_type& k) const
         {
- return table_.to_bucket(table_.bucket_count_,
+ return table::to_bucket(table_.bucket_count_,
                 table_.hash(k));
         }
 
@@ -947,7 +947,7 @@
 
         size_type bucket(const key_type& k) const
         {
- return table_.to_bucket(table_.bucket_count_,
+ return table::to_bucket(table_.bucket_count_,
                 table_.hash(k));
         }
 

Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2012-04-08 11:28:26 EDT (Sun, 08 Apr 2012)
@@ -450,7 +450,7 @@
 
         size_type bucket(const key_type& k) const
         {
- return table_.to_bucket(table_.bucket_count_,
+ return table::to_bucket(table_.bucket_count_,
                 table_.hash(k));
         }
 
@@ -922,7 +922,7 @@
 
         size_type bucket(const key_type& k) const
         {
- return table_.to_bucket(table_.bucket_count_,
+ return table::to_bucket(table_.bucket_count_,
                 table_.hash(k));
         }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk