summaryrefslogtreecommitdiff
path: root/boost/unordered/unordered_map.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/unordered/unordered_map.hpp')
-rw-r--r--boost/unordered/unordered_map.hpp308
1 files changed, 250 insertions, 58 deletions
diff --git a/boost/unordered/unordered_map.hpp b/boost/unordered/unordered_map.hpp
index 3904e56ead..101b1c1c91 100644
--- a/boost/unordered/unordered_map.hpp
+++ b/boost/unordered/unordered_map.hpp
@@ -82,12 +82,23 @@ namespace unordered
// constructors
+ unordered_map();
+
explicit unordered_map(
- size_type = boost::unordered::detail::default_bucket_count,
+ size_type,
const hasher& = hasher(),
const key_equal& = key_equal(),
const allocator_type& = allocator_type());
+ explicit unordered_map(
+ size_type,
+ const allocator_type&);
+
+ explicit unordered_map(
+ size_type,
+ const hasher&,
+ const allocator_type&);
+
explicit unordered_map(allocator_type const&);
template <class InputIt>
@@ -108,11 +119,25 @@ namespace unordered
const key_equal&,
const allocator_type&);
+ template <class InputIt>
+ unordered_map(
+ InputIt, InputIt,
+ size_type,
+ const hasher&,
+ const allocator_type&);
+
+ template <class InputIt>
+ unordered_map(
+ InputIt, InputIt,
+ size_type,
+ const allocator_type&);
+
// copy/move constructors
unordered_map(unordered_map const&);
unordered_map(unordered_map const&, allocator_type const&);
+ unordered_map(BOOST_RV_REF(unordered_map), allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map(BOOST_RV_REF(unordered_map) other)
@@ -128,10 +153,6 @@ namespace unordered
}
#endif
-#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- unordered_map(unordered_map&&, allocator_type const&);
-#endif
-
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
unordered_map(
std::initializer_list<value_type>,
@@ -139,6 +160,15 @@ namespace unordered
const hasher& = hasher(),
const key_equal&l = key_equal(),
const allocator_type& = allocator_type());
+ unordered_map(
+ std::initializer_list<value_type>,
+ size_type,
+ const hasher&,
+ const allocator_type&);
+ unordered_map(
+ std::initializer_list<value_type>,
+ size_type,
+ const allocator_type&);
#endif
// Destructor
@@ -202,12 +232,12 @@ namespace unordered
iterator begin() BOOST_NOEXCEPT
{
- return table_.begin();
+ return iterator(table_.begin());
}
const_iterator begin() const BOOST_NOEXCEPT
{
- return table_.begin();
+ return const_iterator(table_.begin());
}
iterator end() BOOST_NOEXCEPT
@@ -222,7 +252,7 @@ namespace unordered
const_iterator cbegin() const BOOST_NOEXCEPT
{
- return table_.begin();
+ return const_iterator(table_.begin());
}
const_iterator cend() const BOOST_NOEXCEPT
@@ -240,9 +270,9 @@ namespace unordered
}
template <class... Args>
- iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
+ iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
- return table_.emplace(boost::forward<Args>(args)...).first;
+ return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
@@ -281,12 +311,12 @@ namespace unordered
}
template <typename A0>
- iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0))
- ).first;
+ );
}
template <typename A0, typename A1>
@@ -302,15 +332,15 @@ namespace unordered
}
template <typename A0, typename A1>
- iterator emplace_hint(const_iterator,
+ iterator emplace_hint(const_iterator hint,
BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0),
boost::forward<A1>(a1))
- ).first;
+ );
}
template <typename A0, typename A1, typename A2>
@@ -328,17 +358,17 @@ namespace unordered
}
template <typename A0, typename A1, typename A2>
- iterator emplace_hint(const_iterator,
+ iterator emplace_hint(const_iterator hint,
BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1,
BOOST_FWD_REF(A2) a2)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0),
boost::forward<A1>(a1),
boost::forward<A2>(a2))
- ).first;
+ );
}
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
@@ -360,15 +390,15 @@ namespace unordered
BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
> \
iterator emplace_hint( \
- const_iterator, \
+ const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
) \
{ \
- return table_.emplace( \
+ return table_.emplace_hint(hint, \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
a) \
- )).first; \
+ )); \
}
BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
@@ -565,12 +595,23 @@ namespace unordered
// constructors
+ unordered_multimap();
+
explicit unordered_multimap(
- size_type = boost::unordered::detail::default_bucket_count,
+ size_type,
const hasher& = hasher(),
const key_equal& = key_equal(),
const allocator_type& = allocator_type());
+ explicit unordered_multimap(
+ size_type,
+ const allocator_type&);
+
+ explicit unordered_multimap(
+ size_type,
+ const hasher&,
+ const allocator_type&);
+
explicit unordered_multimap(allocator_type const&);
template <class InputIt>
@@ -591,11 +632,25 @@ namespace unordered
const key_equal&,
const allocator_type&);
+ template <class InputIt>
+ unordered_multimap(
+ InputIt, InputIt,
+ size_type,
+ const hasher&,
+ const allocator_type&);
+
+ template <class InputIt>
+ unordered_multimap(
+ InputIt, InputIt,
+ size_type,
+ const allocator_type&);
+
// copy/move constructors
unordered_multimap(unordered_multimap const&);
unordered_multimap(unordered_multimap const&, allocator_type const&);
+ unordered_multimap(BOOST_RV_REF(unordered_multimap), allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
@@ -611,10 +666,6 @@ namespace unordered
}
#endif
-#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
- unordered_multimap(unordered_multimap&&, allocator_type const&);
-#endif
-
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
unordered_multimap(
std::initializer_list<value_type>,
@@ -622,6 +673,15 @@ namespace unordered
const hasher& = hasher(),
const key_equal&l = key_equal(),
const allocator_type& = allocator_type());
+ unordered_multimap(
+ std::initializer_list<value_type>,
+ size_type,
+ const hasher&,
+ const allocator_type&);
+ unordered_multimap(
+ std::initializer_list<value_type>,
+ size_type,
+ const allocator_type&);
#endif
// Destructor
@@ -686,12 +746,12 @@ namespace unordered
iterator begin() BOOST_NOEXCEPT
{
- return table_.begin();
+ return iterator(table_.begin());
}
const_iterator begin() const BOOST_NOEXCEPT
{
- return table_.begin();
+ return const_iterator(table_.begin());
}
iterator end() BOOST_NOEXCEPT
@@ -706,7 +766,7 @@ namespace unordered
const_iterator cbegin() const BOOST_NOEXCEPT
{
- return table_.begin();
+ return const_iterator(table_.begin());
}
const_iterator cend() const BOOST_NOEXCEPT
@@ -724,9 +784,9 @@ namespace unordered
}
template <class... Args>
- iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
+ iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(Args)... args)
{
- return table_.emplace(boost::forward<Args>(args)...);
+ return table_.emplace_hint(hint, boost::forward<Args>(args)...);
}
#else
@@ -765,9 +825,9 @@ namespace unordered
}
template <typename A0>
- iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
+ iterator emplace_hint(const_iterator hint, BOOST_FWD_REF(A0) a0)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0))
);
@@ -786,11 +846,11 @@ namespace unordered
}
template <typename A0, typename A1>
- iterator emplace_hint(const_iterator,
+ iterator emplace_hint(const_iterator hint,
BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0),
boost::forward<A1>(a1))
@@ -812,12 +872,12 @@ namespace unordered
}
template <typename A0, typename A1, typename A2>
- iterator emplace_hint(const_iterator,
+ iterator emplace_hint(const_iterator hint,
BOOST_FWD_REF(A0) a0,
BOOST_FWD_REF(A1) a1,
BOOST_FWD_REF(A2) a2)
{
- return table_.emplace(
+ return table_.emplace_hint(hint,
boost::unordered::detail::create_emplace_args(
boost::forward<A0>(a0),
boost::forward<A1>(a1),
@@ -844,11 +904,11 @@ namespace unordered
BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
> \
iterator emplace_hint( \
- const_iterator, \
+ const_iterator hint, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
) \
{ \
- return table_.emplace( \
+ return table_.emplace_hint(hint, \
boost::unordered::detail::create_emplace_args( \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
a) \
@@ -1003,6 +1063,13 @@ namespace unordered
////////////////////////////////////////////////////////////////////////////////
template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map()
+ : table_(boost::unordered::detail::default_bucket_count, hasher(),
+ key_equal(), allocator_type())
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_map<K,T,H,P,A>::unordered_map(
size_type n, const hasher &hf, const key_equal &eql,
const allocator_type &a)
@@ -1011,6 +1078,20 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ size_type n, const allocator_type &a)
+ : table_(n, hasher(), key_equal(), a)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ size_type n, const hasher &hf, const allocator_type &a)
+ : table_(n, hf, key_equal(), a)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_map<K,T,H,P,A>::unordered_map(allocator_type const& a)
: table_(boost::unordered::detail::default_bucket_count,
hasher(), key_equal(), a)
@@ -1060,6 +1141,31 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ InputIt f, InputIt l,
+ size_type n,
+ const hasher &hf,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hf, key_equal(), a)
+ {
+ table_.insert_range(f, l);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ InputIt f, InputIt l,
+ size_type n,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hasher(), key_equal(), a)
+ {
+ table_.insert_range(f, l);
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_map<K,T,H,P,A>::~unordered_map() BOOST_NOEXCEPT {}
template <class K, class T, class H, class P, class A>
@@ -1069,17 +1175,13 @@ namespace unordered
{
}
-#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
-
template <class K, class T, class H, class P, class A>
unordered_map<K,T,H,P,A>::unordered_map(
- unordered_map&& other, allocator_type const& a)
+ BOOST_RV_REF(unordered_map) other, allocator_type const& a)
: table_(other.table_, a, boost::unordered::detail::move_tag())
{
}
-#endif
-
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
template <class K, class T, class H, class P, class A>
@@ -1095,6 +1197,30 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ std::initializer_list<value_type> list, size_type n,
+ const hasher &hf, const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hf, key_equal(), a)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ std::initializer_list<value_type> list, size_type n,
+ const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hasher(), key_equal(), a)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_map<K,T,H,P,A>& unordered_map<K,T,H,P,A>::operator=(
std::initializer_list<value_type> list)
{
@@ -1208,14 +1334,14 @@ namespace unordered
typename unordered_map<K,T,H,P,A>::iterator
unordered_map<K,T,H,P,A>::find(const key_type& k)
{
- return table_.find_node(k);
+ return iterator(table_.find_node(k));
}
template <class K, class T, class H, class P, class A>
typename unordered_map<K,T,H,P,A>::const_iterator
unordered_map<K,T,H,P,A>::find(const key_type& k) const
{
- return table_.find_node(k);
+ return const_iterator(table_.find_node(k));
}
template <class K, class T, class H, class P, class A>
@@ -1227,7 +1353,7 @@ namespace unordered
CompatibleHash const& hash,
CompatiblePredicate const& eq)
{
- return table_.generic_find_node(k, hash, eq);
+ return iterator(table_.generic_find_node(k, hash, eq));
}
template <class K, class T, class H, class P, class A>
@@ -1239,7 +1365,7 @@ namespace unordered
CompatibleHash const& hash,
CompatiblePredicate const& eq) const
{
- return table_.generic_find_node(k, hash, eq);
+ return const_iterator(table_.generic_find_node(k, hash, eq));
}
template <class K, class T, class H, class P, class A>
@@ -1336,6 +1462,13 @@ namespace unordered
////////////////////////////////////////////////////////////////////////////////
template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap()
+ : table_(boost::unordered::detail::default_bucket_count, hasher(),
+ key_equal(), allocator_type())
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_multimap<K,T,H,P,A>::unordered_multimap(
size_type n, const hasher &hf, const key_equal &eql,
const allocator_type &a)
@@ -1344,6 +1477,20 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ size_type n, const allocator_type &a)
+ : table_(n, hasher(), key_equal(), a)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ size_type n, const hasher &hf, const allocator_type &a)
+ : table_(n, hf, key_equal(), a)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_multimap<K,T,H,P,A>::unordered_multimap(allocator_type const& a)
: table_(boost::unordered::detail::default_bucket_count,
hasher(), key_equal(), a)
@@ -1393,6 +1540,31 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ InputIt f, InputIt l,
+ size_type n,
+ const hasher &hf,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hf, key_equal(), a)
+ {
+ table_.insert_range(f, l);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ InputIt f, InputIt l,
+ size_type n,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hasher(), key_equal(), a)
+ {
+ table_.insert_range(f, l);
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_multimap<K,T,H,P,A>::~unordered_multimap() BOOST_NOEXCEPT {}
template <class K, class T, class H, class P, class A>
@@ -1402,17 +1574,13 @@ namespace unordered
{
}
-#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
-
template <class K, class T, class H, class P, class A>
unordered_multimap<K,T,H,P,A>::unordered_multimap(
- unordered_multimap&& other, allocator_type const& a)
+ BOOST_RV_REF(unordered_multimap) other, allocator_type const& a)
: table_(other.table_, a, boost::unordered::detail::move_tag())
{
}
-#endif
-
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
template <class K, class T, class H, class P, class A>
@@ -1428,6 +1596,30 @@ namespace unordered
}
template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ std::initializer_list<value_type> list, size_type n,
+ const hasher &hf, const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hf, key_equal(), a)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ std::initializer_list<value_type> list, size_type n,
+ const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hasher(), key_equal(), a)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+
+ template <class K, class T, class H, class P, class A>
unordered_multimap<K,T,H,P,A>& unordered_multimap<K,T,H,P,A>::operator=(
std::initializer_list<value_type> list)
{
@@ -1520,14 +1712,14 @@ namespace unordered
typename unordered_multimap<K,T,H,P,A>::iterator
unordered_multimap<K,T,H,P,A>::find(const key_type& k)
{
- return table_.find_node(k);
+ return iterator(table_.find_node(k));
}
template <class K, class T, class H, class P, class A>
typename unordered_multimap<K,T,H,P,A>::const_iterator
unordered_multimap<K,T,H,P,A>::find(const key_type& k) const
{
- return table_.find_node(k);
+ return const_iterator(table_.find_node(k));
}
template <class K, class T, class H, class P, class A>
@@ -1539,7 +1731,7 @@ namespace unordered
CompatibleHash const& hash,
CompatiblePredicate const& eq)
{
- return table_.generic_find_node(k, hash, eq);
+ return iterator(table_.generic_find_node(k, hash, eq));
}
template <class K, class T, class H, class P, class A>
@@ -1551,7 +1743,7 @@ namespace unordered
CompatibleHash const& hash,
CompatiblePredicate const& eq) const
{
- return table_.generic_find_node(k, hash, eq);
+ return const_iterator(table_.generic_find_node(k, hash, eq));
}
template <class K, class T, class H, class P, class A>