forked from boostorg/unordered
Merge pull request #82 from cmazakas/multiset-contains
Implement `unordered_multiset::contains()`
This commit is contained in:
@ -1125,6 +1125,23 @@ namespace boost {
|
||||
const_iterator find(CompatibleKey const&, CompatibleHash const&,
|
||||
CompatiblePredicate const&) const;
|
||||
|
||||
bool contains(const key_type& k) const
|
||||
{
|
||||
return table_.find_node_impl(
|
||||
table::policy::apply_hash(this->hash_function(), k), k,
|
||||
this->key_eq());
|
||||
}
|
||||
|
||||
template <class Key>
|
||||
typename boost::enable_if_c<detail::are_transparent<Key, H, P>::value,
|
||||
bool>::type
|
||||
contains(const Key& k) const
|
||||
{
|
||||
return table_.find_node_impl(
|
||||
table::policy::apply_hash(this->hash_function(), k), k,
|
||||
this->key_eq());
|
||||
}
|
||||
|
||||
size_type count(const key_type&) const;
|
||||
|
||||
template <class Key>
|
||||
|
@ -246,6 +246,25 @@ void test_set()
|
||||
test_set_non_transparent_contains<non_transparent_set3>();
|
||||
}
|
||||
|
||||
void test_multiset()
|
||||
{
|
||||
typedef boost::unordered_multiset<key, transparent_hasher,
|
||||
transparent_key_equal>
|
||||
transparent_multiset;
|
||||
|
||||
typedef boost::unordered_multiset<key, transparent_hasher, key_equal>
|
||||
non_transparent_multiset1;
|
||||
typedef boost::unordered_multiset<key, hasher, transparent_key_equal>
|
||||
non_transparent_multiset2;
|
||||
typedef boost::unordered_multiset<key, hasher, key_equal>
|
||||
non_transparent_multiset3;
|
||||
|
||||
test_set_transparent_contains<transparent_multiset>();
|
||||
test_set_non_transparent_contains<non_transparent_multiset1>();
|
||||
test_set_non_transparent_contains<non_transparent_multiset2>();
|
||||
test_set_non_transparent_contains<non_transparent_multiset3>();
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (contains) {
|
||||
test_map();
|
||||
test_multimap();
|
||||
|
Reference in New Issue
Block a user