Unordered: Call policy functions as static functions.

[SVN r77831]
This commit is contained in:
Daniel James
2012-04-08 15:28:26 +00:00
parent 9f199eaa23
commit 4e759b4444
6 changed files with 55 additions and 37 deletions

View File

@@ -169,6 +169,7 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
}
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 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
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 @@ namespace boost { namespace unordered { namespace detail {
{
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 @@ namespace boost { namespace unordered { namespace detail {
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;