Rename methods to be different for unique/equiv keys

So that the implementation can be moved into a single class. Still some
other methods to rename. Some methods didn't need to be renamed (e.g.
try_emplace is only used with unique keys), but still renamed for
consistency.
This commit is contained in:
Daniel James
2017-04-24 09:46:05 +01:00
parent 8229aa6b3c
commit 77bf2b5e33
3 changed files with 229 additions and 214 deletions
+43 -43
View File
@@ -220,7 +220,7 @@ template <class T, class H, class P, class A> class unordered_set
template <class... Args>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
{
return table_.emplace_impl(
return table_.emplace_unique(
table::extractor::extract(boost::forward<Args>(args)...),
boost::forward<Args>(args)...);
}
@@ -246,7 +246,7 @@ template <class T, class H, class P, class A> class unordered_set
template <typename A0>
std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
return table_.emplace_impl(
return table_.emplace_unique(
table::extractor::extract(boost::forward<A0>(a0)),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
@@ -256,7 +256,7 @@ template <class T, class H, class P, class A> class unordered_set
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace_impl(
return table_.emplace_unique(
table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
@@ -267,7 +267,7 @@ template <class T, class H, class P, class A> class unordered_set
std::pair<iterator, bool> emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace_impl(
return table_.emplace_unique(
table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
@@ -282,7 +282,7 @@ template <class T, class H, class P, class A> class unordered_set
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return table_.emplace_hint_impl(hint,
return table_.emplace_hint_unique(hint,
table::extractor::extract(boost::forward<Args>(args)...),
boost::forward<Args>(args)...);
}
@@ -304,17 +304,17 @@ template <class T, class H, class P, class A> class unordered_set
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
return table_.emplace_hint_impl(hint,
return table_.emplace_hint_unique(hint,
table::extractor::extract(boost::forward<A0>(a0)),
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0)));
boost::forward<A0>(a0)));
}
template <typename A0, typename A1>
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return table_.emplace_hint_impl(
return table_.emplace_hint_unique(
hint, table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
@@ -325,7 +325,7 @@ template <class T, class H, class P, class A> class unordered_set
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return table_.emplace_hint_impl(
return table_.emplace_hint_unique(
hint, table::extractor::extract(
boost::forward<A0>(a0), boost::forward<A1>(a1)),
boost::unordered::detail::create_emplace_args(
@@ -342,7 +342,7 @@ template <class T, class H, class P, class A> class unordered_set
std::pair<iterator, bool> emplace( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace_impl( \
return table_.emplace_unique( \
table::extractor::extract( \
boost::forward<A0>(a0), boost::forward<A1>(a1)), \
boost::unordered::detail::create_emplace_args( \
@@ -353,7 +353,7 @@ template <class T, class H, class P, class A> class unordered_set
iterator emplace_hint(const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return table_.emplace_hint_impl( \
return table_.emplace_hint_unique( \
hint, table::extractor::extract( \
boost::forward<A0>(a0), boost::forward<A1>(a1)), \
boost::unordered::detail::create_emplace_args( \
@@ -404,7 +404,7 @@ template <class T, class H, class P, class A> class unordered_set
node_type extract(const_iterator position)
{
return node_type(
table_.extract_by_iterator(position), table_.node_alloc());
table_.extract_by_iterator_unique(position), table_.node_alloc());
}
node_type extract(const key_type& k)
@@ -415,13 +415,13 @@ template <class T, class H, class P, class A> class unordered_set
insert_return_type insert(BOOST_RV_REF(node_type) np)
{
insert_return_type result;
table_.move_insert_node_type(np, result);
table_.move_insert_node_type_unique(np, result);
return boost::move(result);
}
iterator insert(const_iterator hint, BOOST_RV_REF(node_type) np)
{
return table_.move_insert_node_type_with_hint(hint, np);
return table_.move_insert_node_type_with_hint_unique(hint, np);
}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -730,7 +730,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <class... Args> iterator emplace(BOOST_FWD_REF(Args)... args)
{
return iterator(table_.emplace_impl(
return iterator(table_.emplace_equiv(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(), boost::forward<Args>(args)...)));
}
@@ -754,7 +754,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <typename A0> iterator emplace(BOOST_FWD_REF(A0) a0)
{
return iterator(table_.emplace_impl(
return iterator(table_.emplace_equiv(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -764,7 +764,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <typename A0, typename A1>
iterator emplace(BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return iterator(table_.emplace_impl(
return iterator(table_.emplace_equiv(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -775,7 +775,7 @@ template <class T, class H, class P, class A> class unordered_multiset
iterator emplace(
BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return iterator(table_.emplace_impl(
return iterator(table_.emplace_equiv(
boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -790,7 +790,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <class... Args>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
return iterator(table_.emplace_hint_impl(
return iterator(table_.emplace_hint_equiv(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(), boost::forward<Args>(args)...)));
}
@@ -812,7 +812,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <typename A0>
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
return iterator(table_.emplace_hint_impl(
return iterator(table_.emplace_hint_equiv(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -823,7 +823,7 @@ template <class T, class H, class P, class A> class unordered_multiset
iterator emplace_hint(
const_iterator hint, BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1)
{
return iterator(table_.emplace_hint_impl(
return iterator(table_.emplace_hint_equiv(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -834,7 +834,7 @@ template <class T, class H, class P, class A> class unordered_multiset
iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
return iterator(table_.emplace_hint_impl(
return iterator(table_.emplace_hint_equiv(
hint, boost::unordered::detail::func::construct_node_from_args(
table_.node_alloc(),
boost::unordered::detail::create_emplace_args(
@@ -850,7 +850,7 @@ template <class T, class H, class P, class A> class unordered_multiset
template <BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
iterator emplace(BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return iterator(table_.emplace_impl( \
return iterator(table_.emplace_equiv( \
boost::unordered::detail::func::construct_node_from_args( \
table_.node_alloc(), \
boost::unordered::detail::create_emplace_args( \
@@ -861,7 +861,7 @@ template <class T, class H, class P, class A> class unordered_multiset
iterator emplace_hint(const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a)) \
{ \
return iterator(table_.emplace_hint_impl( \
return iterator(table_.emplace_hint_equiv( \
hint, \
boost::unordered::detail::func::construct_node_from_args( \
table_.node_alloc(), \
@@ -910,7 +910,7 @@ template <class T, class H, class P, class A> class unordered_multiset
node_type extract(const_iterator position)
{
return node_type(
table_.extract_by_iterator(position), table_.node_alloc());
table_.extract_by_iterator_equiv(position), table_.node_alloc());
}
node_type extract(const key_type& k)
@@ -920,12 +920,12 @@ template <class T, class H, class P, class A> class unordered_multiset
iterator insert(BOOST_RV_REF(node_type) np)
{
return table_.move_insert_node_type(np);
return table_.move_insert_node_type_equiv(np);
}
iterator insert(const_iterator hint, BOOST_RV_REF(node_type) np)
{
return table_.move_insert_node_type_with_hint(hint, np);
return table_.move_insert_node_type_with_hint_equiv(hint, np);
}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -1211,7 +1211,7 @@ template <class InputIt>
void unordered_set<T, H, P, A>::insert(InputIt first, InputIt last)
{
if (first != last) {
table_.insert_range_impl(
table_.insert_range_unique(
table::extractor::extract(*first), first, last);
}
}
@@ -1231,7 +1231,7 @@ typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
node_pointer node = table::get_node(position);
BOOST_ASSERT(node);
node_pointer next = table::node_algo::next_node(node);
table_.erase_nodes(node, next);
table_.erase_nodes_unique(node, next);
return iterator(next);
}
@@ -1239,7 +1239,7 @@ template <class T, class H, class P, class A>
typename unordered_set<T, H, P, A>::size_type unordered_set<T, H, P, A>::erase(
const key_type& k)
{
return table_.erase_key(k);
return table_.erase_key_unique(k);
}
template <class T, class H, class P, class A>
@@ -1249,7 +1249,7 @@ typename unordered_set<T, H, P, A>::iterator unordered_set<T, H, P, A>::erase(
node_pointer last_node = table::get_node(last);
if (first == last)
return iterator(last_node);
table_.erase_nodes(table::get_node(first), last_node);
table_.erase_nodes_unique(table::get_node(first), last_node);
return iterator(last_node);
}
@@ -1293,7 +1293,7 @@ template <typename H2, typename P2>
void unordered_set<T, H, P, A>::merge(
boost::unordered_set<T, H2, P2, A>& source)
{
table_.merge_impl(source.table_);
table_.merge_unique(source.table_);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -1302,7 +1302,7 @@ template <typename H2, typename P2>
void unordered_set<T, H, P, A>::merge(
boost::unordered_set<T, H2, P2, A>&& source)
{
table_.merge_impl(source.table_);
table_.merge_unique(source.table_);
}
#endif
@@ -1312,7 +1312,7 @@ template <typename H2, typename P2>
void unordered_set<T, H, P, A>::merge(
boost::unordered_multiset<T, H2, P2, A>& source)
{
table_.merge_impl(source.table_);
table_.merge_unique(source.table_);
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -1321,7 +1321,7 @@ template <typename H2, typename P2>
void unordered_set<T, H, P, A>::merge(
boost::unordered_multiset<T, H2, P2, A>&& source)
{
table_.merge_impl(source.table_);
table_.merge_unique(source.table_);
}
#endif
#endif
@@ -1408,7 +1408,7 @@ inline bool operator==(
unordered_set<T, H, P, A> x;
};
#endif
return m1.table_.equals(m2.table_);
return m1.table_.equals_unique(m2.table_);
}
template <class T, class H, class P, class A>
@@ -1421,7 +1421,7 @@ inline bool operator!=(
unordered_set<T, H, P, A> x;
};
#endif
return !m1.table_.equals(m2.table_);
return !m1.table_.equals_unique(m2.table_);
}
template <class T, class H, class P, class A>
@@ -1604,7 +1604,7 @@ template <class T, class H, class P, class A>
template <class InputIt>
void unordered_multiset<T, H, P, A>::insert(InputIt first, InputIt last)
{
table_.insert_range(first, last);
table_.insert_range_equiv(first, last);
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1623,7 +1623,7 @@ unordered_multiset<T, H, P, A>::erase(const_iterator position)
node_pointer node = table::get_node(position);
BOOST_ASSERT(node);
node_pointer next = table::node_algo::next_node(node);
table_.erase_nodes(node, next);
table_.erase_nodes_equiv(node, next);
return iterator(next);
}
@@ -1631,7 +1631,7 @@ template <class T, class H, class P, class A>
typename unordered_multiset<T, H, P, A>::size_type
unordered_multiset<T, H, P, A>::erase(const key_type& k)
{
return table_.erase_key(k);
return table_.erase_key_equiv(k);
}
template <class T, class H, class P, class A>
@@ -1641,7 +1641,7 @@ unordered_multiset<T, H, P, A>::erase(const_iterator first, const_iterator last)
node_pointer last_node = table::get_node(last);
if (first == last)
return iterator(last_node);
table_.erase_nodes(table::get_node(first), last_node);
table_.erase_nodes_equiv(table::get_node(first), last_node);
return iterator(last_node);
}
@@ -1809,7 +1809,7 @@ inline bool operator==(unordered_multiset<T, H, P, A> const& m1,
unordered_multiset<T, H, P, A> x;
};
#endif
return m1.table_.equals(m2.table_);
return m1.table_.equals_equiv(m2.table_);
}
template <class T, class H, class P, class A>
@@ -1822,7 +1822,7 @@ inline bool operator!=(unordered_multiset<T, H, P, A> const& m1,
unordered_multiset<T, H, P, A> x;
};
#endif
return !m1.table_.equals(m2.table_);
return !m1.table_.equals_equiv(m2.table_);
}
template <class T, class H, class P, class A>