From ae23b7906590e3ae07b74bae3b62acc989219dd5 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 19 Dec 2007 23:28:19 +0000 Subject: [PATCH] Merge in some minor changes. Merged revisions 42157-42182 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/dev ........ r42157 | danieljames | 2007-12-18 23:26:06 +0000 (Tue, 18 Dec 2007) | 1 line Tweak the function specifiers a tad bit. ........ r42158 | danieljames | 2007-12-18 23:30:52 +0000 (Tue, 18 Dec 2007) | 1 line No need to create a node_constructor for every iteration. ........ r42159 | danieljames | 2007-12-18 23:50:29 +0000 (Tue, 18 Dec 2007) | 1 line Pull another node_constructor out of a loop. ........ r42172 | danieljames | 2007-12-19 17:51:41 +0000 (Wed, 19 Dec 2007) | 1 line Remove unrequired include. ........ r42181 | danieljames | 2007-12-19 22:37:34 +0000 (Wed, 19 Dec 2007) | 2 lines Move the unordered library into 'branches' now that it has been accepted. ........ r42182 | danieljames | 2007-12-19 22:39:54 +0000 (Wed, 19 Dec 2007) | 4 lines Actually, there are some things in the unordered code that aren't ready for trunk, so I'll rename the branch and create another one to be added to trunk later. ........ [SVN r42190] --- .../unordered/detail/hash_table_impl.hpp | 27 +++++++++---------- test/helpers/input_iterator.hpp | 1 - 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/boost/unordered/detail/hash_table_impl.hpp b/include/boost/unordered/detail/hash_table_impl.hpp index b9d698ed..363c2bfc 100644 --- a/include/boost/unordered/detail/hash_table_impl.hpp +++ b/include/boost/unordered/detail/hash_table_impl.hpp @@ -238,40 +238,40 @@ namespace boost { // Methods for navigating groups of elements with equal keys. #if BOOST_UNORDERED_HASH_EQUIVALENT - static link_ptr& prev_in_group(link_ptr n) { + static inline link_ptr& prev_in_group(link_ptr n) { return static_cast(*n).group_prev_; } // pre: Must be pointing to the first node in a group. - static link_ptr last_in_group(link_ptr n) { + static inline link_ptr last_in_group(link_ptr n) { BOOST_ASSERT(BOOST_HASH_BORLAND_BOOL(n) && n != prev_in_group(n)->next_); return prev_in_group(n); } // pre: Must be pointing to the first node in a group. - static link_ptr& next_group(link_ptr n) { + static inline link_ptr& next_group(link_ptr n) { BOOST_ASSERT(BOOST_HASH_BORLAND_BOOL(n) && n != prev_in_group(n)->next_); return prev_in_group(n)->next_; } #else - static link_ptr last_in_group(link_ptr n) { + static inline link_ptr last_in_group(link_ptr n) { return n; } - static link_ptr& next_group(link_ptr n) { + static inline link_ptr& next_group(link_ptr n) { BOOST_ASSERT(n); return n->next_; } #endif // pre: Must be pointing to a node - static node& get_node(link_ptr p) { + static inline node& get_node(link_ptr p) { BOOST_ASSERT(p); return static_cast(*p); } // pre: Must be pointing to a node - static reference get_value(link_ptr p) { + static inline reference get_value(link_ptr p) { BOOST_ASSERT(p); return static_cast(*p).value_; } @@ -481,7 +481,7 @@ namespace boost { } #if BOOST_UNORDERED_HASH_EQUIVALENT - size_type group_count(link_ptr it) const + static size_type group_count(link_ptr it) { size_type count = 0; link_ptr first = it; @@ -492,7 +492,7 @@ namespace boost { return count; } #else - size_type group_count(link_ptr) const + static size_type group_count(link_ptr) { return 1; } @@ -1568,9 +1568,9 @@ namespace boost { else { // Only require basic exception safety here reserve_extra(size() + distance); + node_constructor a(this->allocators_); for (; i != j; ++i) { - node_constructor a(this->allocators_); a.construct(*i); key_type const& k = extract_key(a.get()->value_); @@ -1725,8 +1725,8 @@ namespace boost { template void insert(InputIterator i, InputIterator j) { - // If only inserting 1 element, get the required - // safety since insert is only called once. + node_constructor a(this->allocators_); + for (; i != j; ++i) { // No side effects in this initial code size_type hash_value = hash_function()(extract_key(*i)); @@ -1740,7 +1740,6 @@ namespace boost { // Create the node before rehashing in case it throws an // exception (need strong safety in such a case). - node_constructor a(this->allocators_); value_type const& v = *i; a.construct(v); @@ -1790,7 +1789,7 @@ namespace boost { size_type count(key_type const& k) const { link_ptr it = find_iterator(k); // throws, strong - return BOOST_HASH_BORLAND_BOOL(it) ? this->group_count(it) : 0; + return BOOST_HASH_BORLAND_BOOL(it) ? data::group_count(it) : 0; } // find diff --git a/test/helpers/input_iterator.hpp b/test/helpers/input_iterator.hpp index 66f66d75..c45b1eb3 100644 --- a/test/helpers/input_iterator.hpp +++ b/test/helpers/input_iterator.hpp @@ -7,7 +7,6 @@ #define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER #include -#include namespace test {