Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ class unordered_associative_container_adaptor :

// bucket interface:

hasher hash_function() const
{
return this->base().hash_function();
}

key_equal key_eq() const
{
return this->base().key_eq();
}

BOOST_DEDUCED_TYPENAME base_::size_type bucket_count() const
{
return this->base().bucket_count();
Expand Down Expand Up @@ -260,6 +270,11 @@ class unordered_associative_container_adaptor :
return this->base().rehash(n);
}

void reserve(BOOST_DEDUCED_TYPENAME base_::size_type count)
{
return this->base().reserve(count);
}

// We have redefined end and begin so we have to manually route the old ones

BOOST_DEDUCED_TYPENAME base_::iterator begin()
Expand Down
12 changes: 12 additions & 0 deletions test/test_bimap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ template< class Container, class Data >
void test_simple_unordered_associative_container(Container & c, const Data & d)
{
c.clear();
c.reserve( std::distance(d.begin(), d.end()) );
c.insert( d.begin(), d.end() );

BOOST_CHECK( c.bucket_count() * c.max_load_factor() >= d.size() );
Expand All @@ -326,9 +327,13 @@ void test_simple_unordered_associative_container(Container & c, const Data & d)
{
const Container & const_c = c;

// Hash collisions should have no effect on the correctness of an
// unordered simple associative container. -- Cromwell D. Enage
/*
BOOST_CHECK(
const_c.bucket_size(const_c.bucket(*di)) == 1
);
*/

typename Container::size_type nb =
const_c.bucket(*const_c.find(*di));
Expand Down Expand Up @@ -394,6 +399,7 @@ template< class Container, class Data >
void test_pair_unordered_associative_container(Container & c, const Data & d)
{
c.clear();
c.reserve( std::distance(d.begin(), d.end()) );
c.insert( d.begin(), d.end() );

BOOST_CHECK( c.bucket_count() * c.max_load_factor() >= d.size() );
Expand All @@ -414,7 +420,13 @@ void test_pair_unordered_associative_container(Container & c, const Data & d)
{
const Container & const_c = c;

// The test commented out below fails on 32-bit Windows platforms
// but works on 64-bit Windows platforms and others. Regardless,
// hash collisions should have no effect on the correctness of an
// unordered pair associative container. -- Cromwell D. Enage
/*
BOOST_CHECK( const_c.bucket_size(const_c.bucket(di->first)) == 1 );
*/

typename Container::size_type nb =
const_c.bucket(const_c.find(di->first)->first);
Expand Down
31 changes: 31 additions & 0 deletions test/test_bimap_unordered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ void test_bimap()
test_unordered_set_unordered_multiset_bimap(
bm,data,left_data,right_data
);

BOOST_CHECK((
bm.left.hash_function()(' ') == bm.left.hash_function()(' ')
));
BOOST_CHECK((
bm.right.hash_function()(" ") == bm.right.hash_function()(" ")
));
BOOST_CHECK((bm.left.key_eq()(' ', ' ')));
BOOST_CHECK((bm.right.key_eq()(" ", " ")));
}
//--------------------------------------------------------------------

Expand All @@ -103,6 +112,15 @@ void test_bimap()
bm,data,left_data,right_data
);
test_tagged_bimap<left_tag,right_tag>(bm,data);

BOOST_CHECK((
bm.left.hash_function()(' ') == bm.left.hash_function()(' ')
));
BOOST_CHECK((
bm.right.hash_function()(" ") == bm.right.hash_function()(" ")
));
BOOST_CHECK((bm.left.key_eq()(' ', ' ')));
BOOST_CHECK((bm.right.key_eq()(" ", " ")));
}
//--------------------------------------------------------------------

Expand All @@ -128,6 +146,11 @@ void test_bimap()
test_basic_bimap(bm,data,left_data,right_data);
test_associative_container(bm,data);
test_simple_unordered_associative_container(bm,data);

BOOST_CHECK((
bm.right.hash_function()(" ") == bm.right.hash_function()(" ")
));
BOOST_CHECK((bm.right.key_eq()(" ", " ")));
}
//--------------------------------------------------------------------

Expand All @@ -154,6 +177,14 @@ void test_bimap()
test_associative_container(bm,data);
test_simple_unordered_associative_container(bm,data);

BOOST_CHECK((
bm.left.hash_function()(' ') == bm.left.hash_function()(' ')
));
BOOST_CHECK((
bm.right.hash_function()(" ") == bm.right.hash_function()(" ")
));
BOOST_CHECK((bm.left.key_eq()(' ', ' ')));
BOOST_CHECK((bm.right.key_eq()(" ", " ")));
}
//--------------------------------------------------------------------
}
Expand Down