On second thoughts, I'll just completely remove hash_value for ordered

containers. It's low quality and not very generic (it uses boost::hash for
mapped values). Should be a painless change.


[SVN r47465]
This commit is contained in:
Daniel James
2008-07-15 22:03:15 +00:00
parent d5b38b01fc
commit 4305d10264
6 changed files with 0 additions and 182 deletions

View File

@ -104,8 +104,6 @@ implemented. They are specified
differently to the standard associative containers, comparing keys
using the equality predicate rather than `operator==`. This is inconsistent
with the other containers but it is probably closer to user's expectations.
I have also added a `hash_value` free function so that the containers can be
hashed by [classref boost::hash].
[h2 Active Issues and Proposals]

View File

@ -702,25 +702,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
<para>This is a boost extension.</para>
</notes>
</function>
<function name="hash_value">
<template>
<template-type-parameter name="Value">
</template-type-parameter>
<template-type-parameter name="Hash">
</template-type-parameter>
<template-type-parameter name="Pred">
</template-type-parameter>
<template-type-parameter name="Alloc">
</template-type-parameter>
</template>
<parameter name="x">
<paramtype>unordered_set&lt;Value, Hash, Pred, Alloc&gt; const&amp;</paramtype>
</parameter>
<type>std::size_t</type>
<notes>
<para>This is a boost extension.</para>
</notes>
</function>
</free-function-group>
<free-function-group name="swap">
<function name="swap">
@ -1449,25 +1430,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
<para>This is a boost extension.</para>
</notes>
</function>
<function name="hash_value">
<template>
<template-type-parameter name="Value">
</template-type-parameter>
<template-type-parameter name="Hash">
</template-type-parameter>
<template-type-parameter name="Pred">
</template-type-parameter>
<template-type-parameter name="Alloc">
</template-type-parameter>
</template>
<parameter name="x">
<paramtype>unordered_multiset&lt;Value, Hash, Pred, Alloc&gt; const&amp;</paramtype>
</parameter>
<type>std::size_t</type>
<notes>
<para>This is a boost extension.</para>
</notes>
</function>
</free-function-group>
<free-function-group name="swap">
<function name="swap">
@ -2249,27 +2211,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
<para>This is a boost extension.</para>
</notes>
</function>
<function name="hash_value">
<template>
<template-type-parameter name="Key">
</template-type-parameter>
<template-type-parameter name="Mapped">
</template-type-parameter>
<template-type-parameter name="Hash">
</template-type-parameter>
<template-type-parameter name="Pred">
</template-type-parameter>
<template-type-parameter name="Alloc">
</template-type-parameter>
</template>
<parameter name="x">
<paramtype>unordered_map&lt;Key, Mapped, Hash, Pred, Alloc&gt; const&amp;</paramtype>
</parameter>
<type>std::size_t</type>
<notes>
<para>This is a boost extension.</para>
</notes>
</function>
</free-function-group>
<free-function-group name="swap">
<function name="swap">
@ -3012,27 +2953,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
<para>This is a boost extension.</para>
</notes>
</function>
<function name="hash_value">
<template>
<template-type-parameter name="Key">
</template-type-parameter>
<template-type-parameter name="Mapped">
</template-type-parameter>
<template-type-parameter name="Hash">
</template-type-parameter>
<template-type-parameter name="Pred">
</template-type-parameter>
<template-type-parameter name="Alloc">
</template-type-parameter>
</template>
<parameter name="x">
<paramtype>unordered_multimap&lt;Key, Mapped, Hash, Pred, Alloc&gt; const&amp;</paramtype>
</parameter>
<type>std::size_t</type>
<notes>
<para>This is a boost extension.</para>
</notes>
</function>
</free-function-group>
<free-function-group name="swap">
<function name="swap">

View File

@ -2245,61 +2245,6 @@ namespace boost {
return true;
}
//
// hash_value - unordered container hash function.
//
template <typename V, typename K, typename H, typename P, typename A>
std::size_t group_hash(BOOST_UNORDERED_TABLE<V, K, H, P, A> const& t,
typename BOOST_UNORDERED_TABLE_DATA<A>::link_ptr it,
type_wrapper<K>*)
{
typedef BOOST_UNORDERED_TABLE_DATA<A> data;
std::size_t seed = data::group_count(it);
std::size_t hashed_key = t.hash_function()(data::get_value(it));
boost::hash_combine(seed, hashed_key);
return seed;
}
template <typename V, typename K, typename H, typename P, typename A>
std::size_t group_hash(BOOST_UNORDERED_TABLE<V, K, H, P, A> const& t,
typename BOOST_UNORDERED_TABLE_DATA<A>::link_ptr it,
void*)
{
typedef BOOST_UNORDERED_TABLE_DATA<A> data;
typedef typename data::link_ptr link_ptr;
std::size_t seed = t.hash_function()(data::get_value(it).first);
link_ptr end = data::next_group(it);
do {
boost::hash_combine(seed, data::get_value(it).second);
it = it->next_;
} while(it != end);
return seed;
}
template <typename V, typename K, typename H, typename P, typename A>
std::size_t hash_value(BOOST_UNORDERED_TABLE<V, K, H, P, A> const& t)
{
typedef BOOST_UNORDERED_TABLE_DATA<A> data;
typedef typename data::link_ptr link_ptr;
typedef typename data::bucket_ptr bucket_ptr;
std::size_t seed = 0;
for(bucket_ptr i = t.data_.cached_begin_bucket_,
j = t.data_.buckets_end(); i != j; ++i)
{
for(link_ptr it(i->next_); BOOST_UNORDERED_BORLAND_BOOL(it); it = data::next_group(it))
seed += group_hash(t, it, (type_wrapper<V>*)0);
}
return seed;
}
// Iterators
template <typename Alloc> class BOOST_UNORDERED_ITERATOR;

View File

@ -40,8 +40,6 @@ namespace boost
bool operator!=(unordered_map<K, T, H, P, A> const&,
unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
std::size_t hash_value(unordered_map<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
void swap(unordered_map<K, T, H, P, A>&,
unordered_map<K, T, H, P, A>&);
@ -58,8 +56,6 @@ namespace boost
bool operator!=(unordered_multimap<K, T, H, P, A> const&,
unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
std::size_t hash_value(unordered_multimap<K, T, H, P, A> const&);
template <class K, class T, class H, class P, class A>
void swap(unordered_multimap<K, T, H, P, A>&,
unordered_multimap<K, T, H, P, A>&);
@ -424,11 +420,9 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
friend bool operator==(unordered_map const&, unordered_map const&);
friend bool operator!=(unordered_map const&, unordered_map const&);
friend std::size_t hash_value(unordered_map const&);
#else
friend bool operator==<>(unordered_map const&, unordered_map const&);
friend bool operator!=<>(unordered_map const&, unordered_map const&);
friend std::size_t hash_value<>(unordered_map const&);
#endif
}; // class template unordered_map
@ -446,12 +440,6 @@ namespace boost
return !boost::unordered_detail::equals(m1.base, m2.base);
}
template <class K, class T, class H, class P, class A>
inline std::size_t hash_value(unordered_map<K, T, H, P, A> const& m)
{
return boost::unordered_detail::hash_value(m.base);
}
template <class K, class T, class H, class P, class A>
inline void swap(unordered_map<K, T, H, P, A> &m1,
unordered_map<K, T, H, P, A> &m2)
@ -804,11 +792,9 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
friend bool operator==(unordered_multimap const&, unordered_multimap const&);
friend bool operator!=(unordered_multimap const&, unordered_multimap const&);
friend std::size_t hash_value(unordered_multimap const&);
#else
friend bool operator==<>(unordered_multimap const&, unordered_multimap const&);
friend bool operator!=<>(unordered_multimap const&, unordered_multimap const&);
friend std::size_t hash_value<>(unordered_multimap const&);
#endif
}; // class template unordered_multimap
@ -826,12 +812,6 @@ namespace boost
return !boost::unordered_detail::equals(m1.base, m2.base);
}
template <class K, class T, class H, class P, class A>
inline std::size_t hash_value(unordered_multimap<K, T, H, P, A> const& m)
{
return boost::unordered_detail::hash_value(m.base);
}
template <class K, class T, class H, class P, class A>
inline void swap(unordered_multimap<K, T, H, P, A> &m1,
unordered_multimap<K, T, H, P, A> &m2)

View File

@ -39,8 +39,6 @@ namespace boost
bool operator!=(unordered_set<T, H, P, A> const&,
unordered_set<T, H, P, A> const&);
template <class T, class H, class P, class A>
std::size_t hash_value(unordered_set<T, H, P, A> const& m);
template <class T, class H, class P, class A>
void swap(unordered_set<T, H, P, A> &m1,
unordered_set<T, H, P, A> &m2);
@ -56,8 +54,6 @@ namespace boost
bool operator!=(unordered_multiset<T, H, P, A> const&,
unordered_multiset<T, H, P, A> const&);
template <class T, class H, class P, class A>
std::size_t hash_value(unordered_multiset<T, H, P, A> const& m);
template <class T, class H, class P, class A>
void swap(unordered_multiset<T, H, P, A> &m1,
unordered_multiset<T, H, P, A> &m2);
@ -394,11 +390,9 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
friend bool operator==(unordered_set const&, unordered_set const&);
friend bool operator!=(unordered_set const&, unordered_set const&);
friend std::size_t hash_value(unordered_set const&);
#else
friend bool operator==<>(unordered_set const&, unordered_set const&);
friend bool operator!=<>(unordered_set const&, unordered_set const&);
friend std::size_t hash_value<>(unordered_set const&);
#endif
}; // class template unordered_set
@ -416,12 +410,6 @@ namespace boost
return !boost::unordered_detail::equals(m1.base, m2.base);
}
template <class T, class H, class P, class A>
inline std::size_t hash_value(unordered_set<T, H, P, A> const& m)
{
return boost::unordered_detail::hash_value(m.base);
}
template <class T, class H, class P, class A>
inline void swap(unordered_set<T, H, P, A> &m1,
unordered_set<T, H, P, A> &m2)
@ -759,11 +747,9 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
friend bool operator==(unordered_multiset const&, unordered_multiset const&);
friend bool operator!=(unordered_multiset const&, unordered_multiset const&);
friend std::size_t hash_value(unordered_multiset const&);
#else
friend bool operator==<>(unordered_multiset const&, unordered_multiset const&);
friend bool operator!=<>(unordered_multiset const&, unordered_multiset const&);
friend std::size_t hash_value<>(unordered_multiset const&);
#endif
}; // class template unordered_multiset
@ -781,12 +767,6 @@ namespace boost
return !boost::unordered_detail::equals(m1.base, m2.base);
}
template <class T, class H, class P, class A>
inline std::size_t hash_value(unordered_multiset<T, H, P, A> const& m)
{
return boost::unordered_detail::hash_value(m.base);
}
template <class T, class H, class P, class A>
inline void swap(unordered_multiset<T, H, P, A> &m1,
unordered_multiset<T, H, P, A> &m2)

View File

@ -168,11 +168,6 @@ void equality_test(X& r)
test::check_return_type<bool>::equals(a == b);
test::check_return_type<bool>::equals(a != b);
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
test::check_return_type<std::size_t>::equals(boost::hash_value(a));
#else
test::check_return_type<std::size_t>::equals(hash_value(a));
#endif
}
template <class X, class T>