|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51408 - trunk/boost/unordered/detail
From: daniel_james_at_[hidden]
Date: 2009-02-22 18:50:05
Author: danieljames
Date: 2009-02-22 18:50:04 EST (Sun, 22 Feb 2009)
New Revision: 51408
URL: http://svn.boost.org/trac/boost/changeset/51408
Log:
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
Text files modified:
trunk/boost/unordered/detail/hash_table_impl.hpp | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
Modified: trunk/boost/unordered/detail/hash_table_impl.hpp
==============================================================================
--- trunk/boost/unordered/detail/hash_table_impl.hpp (original)
+++ trunk/boost/unordered/detail/hash_table_impl.hpp 2009-02-22 18:50:04 EST (Sun, 22 Feb 2009)
@@ -1103,7 +1103,7 @@
// This can throw, but BOOST_UNORDERED_TABLE_DATA's destructor will clean
// up.
- copy_buckets(x.data_, data_, functions_.current());
+ x.copy_buckets_to(data_);
}
// Copy Construct with allocator
@@ -1118,7 +1118,7 @@
// This can throw, but BOOST_UNORDERED_TABLE_DATA's destructor will clean
// up.
- copy_buckets(x.data_, data_, functions_.current());
+ x.copy_buckets_to(data_);
}
// Move Construct
@@ -1143,14 +1143,14 @@
if(x.data_.buckets_) {
// This can throw, but BOOST_UNORDERED_TABLE_DATA's destructor will clean
// up.
- copy_buckets(x.data_, data_, functions_.current());
+ x.copy_buckets_to(data_);
}
}
// Assign
//
// basic exception safety, if buffered_functions::buffer or reserver throws
- // the container is left in a sane, empty state. If copy_buckets
+ // the container is left in a sane, empty state. If copy_buckets_to
// throws the container is left with whatever was successfully
// copied.
@@ -1164,7 +1164,7 @@
mlf_ = x.mlf_; // no throw
calculate_max_load(); // no throw
reserve(x.size()); // throws
- copy_buckets(x.data_, data_, functions_.current()); // throws
+ x.copy_buckets_to(data_); // throws
}
return *this;
@@ -1207,10 +1207,10 @@
// which will clean up if anything throws an exception.
// (all can throw, but with no effect as these are new objects).
data new_this(data_, x.min_buckets_for_size(x.data_.size_));
- copy_buckets(x.data_, new_this, functions_.*new_func_this);
+ x.copy_buckets_to(new_this);
data new_that(x.data_, min_buckets_for_size(data_.size_));
- x.copy_buckets(data_, new_that, x.functions_.*new_func_that);
+ copy_buckets_to(new_that);
// Start updating the data here, no throw from now on.
data_.swap(new_this);
@@ -1251,7 +1251,7 @@
// which will clean up if anything throws an exception.
// (all can throw, but with no effect as these are new objects).
data new_this(data_, x.min_buckets_for_size(x.data_.size_));
- copy_buckets(x.data_, new_this, functions_.*new_func_this);
+ x.copy_buckets_to(new_this);
// Start updating the data here, no throw from now on.
data_.move(new_this);
@@ -1494,22 +1494,23 @@
return;
data new_buckets(data_, n); // throws, seperate
- move_buckets(data_, new_buckets, hash_function());
- // basic/no throw
+ move_buckets_to(new_buckets); // basic/no throw
new_buckets.swap(data_); // no throw
calculate_max_load(); // no throw
}
- // move_buckets & copy_buckets
+ // move_buckets_to & copy_buckets_to
//
// if the hash function throws, basic excpetion safety
// no throw otherwise
- static void move_buckets(data& src, data& dst, hasher const& hf)
+ void move_buckets_to(data& dst)
{
BOOST_ASSERT(dst.size_ == 0);
//BOOST_ASSERT(src.allocators_.node_alloc_ == dst.allocators_.node_alloc_);
+ data& src = this->data_;
+ hasher const& hf = this->hash_function();
bucket_ptr end = src.buckets_end();
for(; src.cached_begin_bucket_ != end;
@@ -1533,12 +1534,14 @@
// basic excpetion safety. If an exception is thrown this will
// leave dst partially filled.
- static void copy_buckets(data const& src, data& dst, functions const& f)
+ void copy_buckets_to(data& dst) const
{
BOOST_ASSERT(dst.size_ == 0);
+
// no throw:
+ data const& src = this->data_;
+ hasher const& hf = this->hash_function();
bucket_ptr end = src.buckets_end();
- hasher const& hf = f.hash_function();
// no throw:
for(bucket_ptr i = src.cached_begin_bucket_; i != end; ++i) {
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