From df1e1598a5c9a4753a05f009e3886f84ec9efbb0 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 18 Mar 2007 20:00:59 +0000 Subject: [PATCH] Import latest changes to the unordered containers. Includes: Copyright update. Switch back to the version where the sentinel points to itself. Remove alternative versions of swap. Workaround a borland bug or two. More consistent use of class/swap/template. Avoid a few warnings. Add a no-throw swap to the allocator for exception testing. [SVN r3793] --- doc/buckets.qbk | 6 +- doc/comparison.qbk | 9 +- doc/hash_equality.qbk | 4 + doc/intro.qbk | 4 + doc/rationale.qbk | 11 +- doc/ref.xml | 6 + doc/src_code/insensitive.cpp | 2 +- doc/unordered.qbk | 6 +- examples/case_insensitive.hpp | 2 +- examples/case_insensitive_test.cpp | 2 +- include/boost/unordered/detail/allocator.hpp | 2 +- include/boost/unordered/detail/hash_table.hpp | 11 +- .../unordered/detail/hash_table_impl.hpp | 498 ++++++++---------- include/boost/unordered_map.hpp | 2 +- include/boost/unordered_set.hpp | 2 +- test/Jamfile.v2 | 2 +- test/container/compile_tests.hpp | 2 +- test/container/link_test_1.cpp | 2 +- test/container/link_test_2.cpp | 2 +- test/container/map_compile.cpp | 2 +- test/container/set_compile.cpp | 2 +- test/container/simple_tests.cpp | 2 +- test/exception/Jamfile.v2 | 8 +- test/exception/assign_tests.cpp | 2 +- test/exception/constructor_tests.cpp | 2 +- test/exception/containers.hpp | 2 +- test/exception/copy_tests.cpp | 2 +- test/exception/erase_tests.cpp | 2 +- test/exception/insert_tests.cpp | 2 +- test/exception/rehash_tests.cpp | 2 +- test/exception/swap_tests.cpp | 2 +- test/helpers/check_return_type.hpp | 2 +- test/helpers/equivalent.hpp | 2 +- test/helpers/fwd.hpp | 2 +- test/helpers/generators.hpp | 2 +- test/helpers/helpers.hpp | 2 +- test/helpers/input_iterator.hpp | 2 +- test/helpers/invariants.hpp | 2 +- test/helpers/metafunctions.hpp | 2 +- test/helpers/random_values.hpp | 2 +- test/helpers/strong.hpp | 2 +- test/helpers/tracker.hpp | 2 +- test/objects/exception.hpp | 7 +- test/objects/fwd.hpp | 2 +- test/objects/minimal.hpp | 10 +- test/objects/test.hpp | 2 +- test/unordered/Jamfile.v2 | 6 +- test/unordered/assign_tests.cpp | 2 +- test/unordered/bucket_tests.cpp | 2 +- test/unordered/compile_tests.cpp | 8 +- test/unordered/constructor_tests.cpp | 2 +- test/unordered/copy_tests.cpp | 2 +- test/unordered/equivalent_keys_tests.cpp | 2 +- test/unordered/erase_equiv_tests.cpp | 2 +- test/unordered/erase_tests.cpp | 2 +- test/unordered/find_tests.cpp | 2 +- test/unordered/insert_tests.cpp | 2 +- test/unordered/load_factor_tests.cpp | 2 +- test/unordered/rehash_tests.cpp | 2 +- test/unordered/swap_tests.cpp | 2 +- test/unordered/unnecessary_copy_tests.cpp | 2 +- 61 files changed, 334 insertions(+), 354 deletions(-) diff --git a/doc/buckets.qbk b/doc/buckets.qbk index 099ca7ff..4fbc6282 100644 --- a/doc/buckets.qbk +++ b/doc/buckets.qbk @@ -1,3 +1,7 @@ +[/ Copyright 2006-2007 Daniel James. + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] + [section:buckets The Data Structure] The containers are made up of a number of 'buckets', each of which can contain @@ -6,7 +10,7 @@ boost::unordered_set unordered_set] with 7 buckets containing 5 elements, `A`, `B`, `C`, `D` and `E` (this is just for illustration, in practise containers will have more buckets). -[$../diagrams/buckets.png] +[$../../libs/unordered/doc/diagrams/buckets.png] In order to decide which bucket to place an element in, the container applies `Hash` to the element's key (for `unordered_set` and `unordered_multiset` the diff --git a/doc/comparison.qbk b/doc/comparison.qbk index 53e28bff..e36e3064 100644 --- a/doc/comparison.qbk +++ b/doc/comparison.qbk @@ -1,3 +1,7 @@ +[/ Copyright 2006-2007 Daniel James. + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] + [section:comparison Comparison with Associative Containers] [table Interface differences. @@ -10,7 +14,10 @@ ] [ [`Compare` exposed by member typedef `key_compare`, accessed by member function `key_comp()`] - [`Hash` exposed by member typedef `hasher`, accessed by member function `hash_function()`.\n`Pred` by member typedef `key_equal` and member function `key_eq()`.] + [ + `Hash` exposed by member typedef `hasher`, accessed by member function `hash_function()`. + + `Pred` by member typedef `key_equal` and member function `key_eq()`.] ] [ [Member typedef `value_compare` supplies an ordering comparison for member elements, accessed by member function `value_comp()`.] diff --git a/doc/hash_equality.qbk b/doc/hash_equality.qbk index 158b32ea..e2844a07 100644 --- a/doc/hash_equality.qbk +++ b/doc/hash_equality.qbk @@ -1,3 +1,7 @@ +[/ Copyright 2006-2007 Daniel James. + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] + [section:hash_equality Equality Predicates and Hash Functions] [/TODO: A better introduction to hash functions?] diff --git a/doc/intro.qbk b/doc/intro.qbk index 5c44afad..d6e290ff 100644 --- a/doc/intro.qbk +++ b/doc/intro.qbk @@ -1,3 +1,7 @@ +[/ Copyright 2006-2007 Daniel James. + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] + [def __tr1__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2009.pdf C++ Standard Library Technical Report]] diff --git a/doc/rationale.qbk b/doc/rationale.qbk index d79cd93e..ec8f3d30 100644 --- a/doc/rationale.qbk +++ b/doc/rationale.qbk @@ -1,3 +1,7 @@ +[/ Copyright 2006-2007 Daniel James. + / Distributed under the Boost Software License, Version 1.0. (See accompanying + / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ] + [def __wang__ [@http://www.concentric.net/~Ttwang/tech/inthash.htm Thomas Wang's article on integer hash functions]] @@ -96,14 +100,11 @@ Need to look into this one. [h3 [@http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#431 431. Swapping containers with unequal allocators]] -In a fit of probably unwise enthusiasm, I implemented all the three versions -with a macro (BOOST_UNORDERED_SWAP_METHOD) to pick which one is used. As -suggested by Howard Hinnant, I set option 3 as the default. I'll probably -remove the alternative implementations before review. +I'm following Howard Hinnant's advice and implement option 3. There is currently a further issue - if the allocator's swap does throw there's no guarantee what state the allocators will be in. The only solution seems to -be to double buffer the allocators. +be to double buffer the allocators. But I'm assuming that it won't throw for now. [h3 [@http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#518 518. Are insert and erase stable for unordered_multiset and unordered_multimap?]] diff --git a/doc/ref.xml b/doc/ref.xml index e0125e17..b834598f 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -1,3 +1,9 @@ + +