2006-05-17 17:19:16 +00:00
|
|
|
|
Merge hash and unordered changes.
Remove deprecated headers, move hash_fwd.hpp into hash subdirectory. And
several minor internal changes.
Mostly minor internal details.
Merged revisions 51262-51263,51407-51409,51504-51505,51644-51646,51667 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r51262 | danieljames | 2009-02-15 19:32:04 +0000 (Sun, 15 Feb 2009) | 1 line
Use the new 'boost:' links for the hash, unordered and quickbook documentation.
........
r51263 | danieljames | 2009-02-15 19:32:19 +0000 (Sun, 15 Feb 2009) | 2 lines
Don't copy images for the standalone hash and unordered documentation, was only
really required before the libraries were integrated into boost.
........
r51407 | danieljames | 2009-02-22 23:49:51 +0000 (Sun, 22 Feb 2009) | 1 line
Fix the hash dirname.
........
r51408 | danieljames | 2009-02-22 23:50:04 +0000 (Sun, 22 Feb 2009) | 1 line
Make copy_buckets and move_buckets member functions - so that calling them is a bit simpler.
........
r51409 | danieljames | 2009-02-22 23:50:20 +0000 (Sun, 22 Feb 2009) | 1 line
Move some of the data structure classes out of hash table data.
........
r51504 | danieljames | 2009-03-01 14:15:09 +0000 (Sun, 01 Mar 2009) | 1 line
Add missing return for operator=.
........
r51505 | danieljames | 2009-03-01 14:15:39 +0000 (Sun, 01 Mar 2009) | 3 lines
Make the sort stable.
Doesn't really matter, but it might as well be.
........
r51644 | danieljames | 2009-03-08 09:44:51 +0000 (Sun, 08 Mar 2009) | 1 line
Detab.
........
r51645 | danieljames | 2009-03-08 09:45:11 +0000 (Sun, 08 Mar 2009) | 4 lines
Move hash_fwd into the hash subdirectory.
I should have done this in the last release. But now all of the hash
implementation is in the hash subdirectory.
........
r51646 | danieljames | 2009-03-08 09:45:30 +0000 (Sun, 08 Mar 2009) | 3 lines
Remove deprecated headers.
Fixes #2412.
........
r51667 | danieljames | 2009-03-09 20:56:23 +0000 (Mon, 09 Mar 2009) | 1 line
Update copyright dates in hash and unordered.
........
[SVN r51729]
2009-03-11 22:51:09 +00:00
|
|
|
// Copyright 2006-2009 Daniel James.
|
2006-07-01 22:31:26 +00:00
|
|
|
// 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)
|
2006-05-17 17:19:16 +00:00
|
|
|
|
|
|
|
#include <boost/unordered_set.hpp>
|
|
|
|
#include <boost/unordered_map.hpp>
|
2008-03-24 17:03:15 +00:00
|
|
|
#include "../helpers/test.hpp"
|
2006-05-17 17:19:16 +00:00
|
|
|
#include "../objects/test.hpp"
|
|
|
|
#include "../helpers/random_values.hpp"
|
|
|
|
#include "../helpers/tracker.hpp"
|
|
|
|
#include "../helpers/equivalent.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2008-03-24 17:03:15 +00:00
|
|
|
namespace assign_tests {
|
|
|
|
|
2007-12-06 11:42:28 +00:00
|
|
|
test::seed_t seed(96785);
|
|
|
|
|
2006-05-17 17:19:16 +00:00
|
|
|
template <class T>
|
2008-01-20 18:55:57 +00:00
|
|
|
void assign_tests1(T*, test::random_generator generator = test::default_generator)
|
2006-05-17 17:19:16 +00:00
|
|
|
{
|
2008-01-10 22:30:46 +00:00
|
|
|
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
2006-05-17 17:19:16 +00:00
|
|
|
|
|
|
|
std::cerr<<"assign_tests1.1\n";
|
|
|
|
{
|
|
|
|
T x;
|
|
|
|
x = x;
|
2008-04-17 07:39:24 +00:00
|
|
|
BOOST_CHECK(x.empty());
|
|
|
|
BOOST_CHECK(test::equivalent(x.hash_function(), hf));
|
|
|
|
BOOST_CHECK(test::equivalent(x.key_eq(), eq));
|
2006-05-17 17:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr<<"assign_tests1.2\n";
|
|
|
|
{
|
2008-01-20 18:55:57 +00:00
|
|
|
test::random_values<T> v(1000, generator);
|
2006-05-17 17:19:16 +00:00
|
|
|
T x(v.begin(), v.end());
|
|
|
|
|
|
|
|
test::ordered<T> tracker = test::create_ordered(x);
|
2006-06-12 23:30:46 +00:00
|
|
|
tracker.insert_range(v.begin(), v.end());
|
2006-05-17 17:19:16 +00:00
|
|
|
|
|
|
|
x = x;
|
|
|
|
tracker.compare(x);
|
|
|
|
|
|
|
|
T y;
|
|
|
|
y.max_load_factor(x.max_load_factor() / 20);
|
|
|
|
y = x;
|
|
|
|
tracker.compare(y);
|
2008-04-17 07:39:24 +00:00
|
|
|
BOOST_CHECK(x.max_load_factor() == y.max_load_factor());
|
2006-05-17 17:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2008-01-20 18:55:57 +00:00
|
|
|
void assign_tests2(T*, test::random_generator generator = test::default_generator)
|
2006-05-17 17:19:16 +00:00
|
|
|
{
|
2008-01-10 22:30:46 +00:00
|
|
|
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
2006-05-17 17:19:16 +00:00
|
|
|
|
|
|
|
std::cerr<<"assign_tests2.1\n";
|
|
|
|
{
|
2008-01-20 18:55:57 +00:00
|
|
|
test::random_values<T> v(1000, generator);
|
2006-05-17 17:19:16 +00:00
|
|
|
T x1(v.begin(), v.end(), 0, hf1, eq1);
|
|
|
|
T x2(0, hf2, eq2);
|
|
|
|
x2 = x1;
|
2008-04-17 07:39:24 +00:00
|
|
|
BOOST_CHECK(test::equivalent(x2.hash_function(), hf1));
|
|
|
|
BOOST_CHECK(test::equivalent(x2.key_eq(), eq1));
|
2006-06-12 23:30:46 +00:00
|
|
|
test::check_container(x2, v);
|
2006-05-17 17:19:16 +00:00
|
|
|
}
|
2006-05-21 17:14:11 +00:00
|
|
|
|
|
|
|
std::cerr<<"assign_tests2.2\n";
|
|
|
|
{
|
2008-01-20 18:55:57 +00:00
|
|
|
test::random_values<T> v1(100, generator), v2(100, generator);
|
2006-05-21 17:14:11 +00:00
|
|
|
T x1(v1.begin(), v1.end(), 0, hf1, eq1, al1);
|
|
|
|
T x2(v2.begin(), v2.end(), 0, hf2, eq2, al2);
|
|
|
|
x2 = x1;
|
2008-04-17 07:39:24 +00:00
|
|
|
BOOST_CHECK(test::equivalent(x2.hash_function(), hf1));
|
|
|
|
BOOST_CHECK(test::equivalent(x2.key_eq(), eq1));
|
|
|
|
BOOST_CHECK(test::equivalent(x2.get_allocator(), al2));
|
2006-06-12 23:30:46 +00:00
|
|
|
test::check_container(x2, v1);
|
2006-05-21 17:14:11 +00:00
|
|
|
}
|
2006-05-17 17:19:16 +00:00
|
|
|
}
|
|
|
|
|
2008-03-24 17:03:15 +00:00
|
|
|
boost::unordered_set<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_set;
|
|
|
|
boost::unordered_multiset<test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multiset;
|
|
|
|
boost::unordered_map<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_map;
|
|
|
|
boost::unordered_multimap<test::object, test::object, test::hash, test::equal_to, test::allocator<test::object> >* test_multimap;
|
|
|
|
|
|
|
|
using test::default_generator;
|
|
|
|
using test::generate_collisions;
|
|
|
|
|
|
|
|
UNORDERED_TEST(assign_tests1,
|
|
|
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
|
|
|
((default_generator)(generate_collisions))
|
|
|
|
)
|
|
|
|
|
|
|
|
UNORDERED_TEST(assign_tests2,
|
|
|
|
((test_set)(test_multiset)(test_map)(test_multimap))
|
|
|
|
((default_generator)(generate_collisions))
|
|
|
|
)
|
|
|
|
|
Merge latest hash and unordered developments, and add support for initialiser
lists to config.
Merged revisions 49338,49924-49927,49955,50029,50118 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r49338 | danieljames | 2008-10-15 10:44:41 +0100 (Wed, 15 Oct 2008) | 2 lines
Revert [49229], it fixes the same problem as [48674].
........
r49924 | danieljames | 2008-11-24 22:55:14 +0000 (Mon, 24 Nov 2008) | 1 line
Extra tests for equality with different hash functions.
........
r49925 | danieljames | 2008-11-24 22:55:47 +0000 (Mon, 24 Nov 2008) | 1 line
Document operator==/operator!= as undefined if the equality predicates aren't equivalent.
........
r49926 | danieljames | 2008-11-24 22:56:04 +0000 (Mon, 24 Nov 2008) | 1 line
Use a larger prime number list.
........
r49927 | danieljames | 2008-11-24 23:15:55 +0000 (Mon, 24 Nov 2008) | 1 line
Use aligned storage for the value.
........
r49955 | danieljames | 2008-11-27 11:42:13 +0000 (Thu, 27 Nov 2008) | 1 line
Wild stab at getting destruction working on more compilers.
........
r50029 | danieljames | 2008-11-29 21:47:55 +0000 (Sat, 29 Nov 2008) | 1 line
Workaround another in-place destruction.
........
r50118 | danieljames | 2008-12-04 21:30:19 +0000 (Thu, 04 Dec 2008) | 1 line
Add support for initializer lists to config and the unordered containers.
........
[SVN r50451]
2009-01-03 23:18:33 +00:00
|
|
|
#if !defined(BOOST_NO_INITIALIZER_LISTS)
|
|
|
|
|
|
|
|
UNORDERED_AUTO_TEST(assign_initializer_list)
|
|
|
|
{
|
|
|
|
std::cerr<<"Initializer List Tests\n";
|
|
|
|
|
|
|
|
boost::unordered_set<int> x;
|
|
|
|
x.insert(10);
|
|
|
|
x.insert(20);
|
|
|
|
x = { 1, 2, -10 };
|
|
|
|
BOOST_CHECK(x.find(10) == x.end());
|
|
|
|
BOOST_CHECK(x.find(-10) != x.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-05-17 17:19:16 +00:00
|
|
|
}
|
2008-03-24 17:03:15 +00:00
|
|
|
|
|
|
|
RUN_TESTS()
|