summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/unordered/unordered_map.hpp')
-rw-r--r--3rdParty/Boost/src/boost/unordered/unordered_map.hpp1752
1 files changed, 1133 insertions, 619 deletions
diff --git a/3rdParty/Boost/src/boost/unordered/unordered_map.hpp b/3rdParty/Boost/src/boost/unordered/unordered_map.hpp
index 86a6fc6..d606739 100644
--- a/3rdParty/Boost/src/boost/unordered/unordered_map.hpp
+++ b/3rdParty/Boost/src/boost/unordered/unordered_map.hpp
@@ -1,6 +1,6 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
-// Copyright (C) 2005-2009 Daniel James.
+// Copyright (C) 2005-2011 Daniel James.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -14,16 +14,13 @@
#endif
#include <boost/unordered/unordered_map_fwd.hpp>
-#include <boost/functional/hash.hpp>
-#include <boost/unordered/detail/allocator_helpers.hpp>
#include <boost/unordered/detail/equivalent.hpp>
#include <boost/unordered/detail/unique.hpp>
+#include <boost/unordered/detail/util.hpp>
+#include <boost/functional/hash.hpp>
+#include <boost/move/move.hpp>
-#if defined(BOOST_NO_RVALUE_REFERENCES)
-#include <boost/unordered/detail/move.hpp>
-#endif
-
-#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
@@ -38,10 +35,17 @@
namespace boost
{
+namespace unordered
+{
template <class K, class T, class H, class P, class A>
class unordered_map
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ BOOST_COPYABLE_AND_MOVABLE(unordered_map)
+#endif
+
public:
+
typedef K key_type;
typedef std::pair<const K, T> value_type;
typedef T mapped_type;
@@ -49,179 +53,129 @@ namespace boost
typedef P key_equal;
typedef A allocator_type;
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
private:
-#endif
-
- typedef BOOST_DEDUCED_TYPENAME
- boost::unordered_detail::rebind_wrap<
- allocator_type, value_type>::type
- value_allocator;
- typedef boost::unordered_detail::map<K, H, P,
- value_allocator> types;
- typedef BOOST_DEDUCED_TYPENAME types::impl table;
-
- typedef BOOST_DEDUCED_TYPENAME types::iterator_base iterator_base;
+ typedef boost::unordered::detail::map<A, K, T, H, P> types;
+ typedef typename types::traits allocator_traits;
+ typedef typename types::table table;
public:
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::pointer pointer;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::const_pointer const_pointer;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::reference reference;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::const_reference const_reference;
+ typedef typename allocator_traits::pointer pointer;
+ typedef typename allocator_traits::const_pointer const_pointer;
+
+ typedef value_type& reference;
+ typedef value_type const& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
- typedef boost::unordered_detail::hash_const_local_iterator<
- value_allocator, boost::unordered_detail::ungrouped>
- const_local_iterator;
- typedef boost::unordered_detail::hash_local_iterator<
- value_allocator, boost::unordered_detail::ungrouped>
- local_iterator;
- typedef boost::unordered_detail::hash_const_iterator<
- value_allocator, boost::unordered_detail::ungrouped>
- const_iterator;
- typedef boost::unordered_detail::hash_iterator<
- value_allocator, boost::unordered_detail::ungrouped>
- iterator;
+ typedef typename table::cl_iterator const_local_iterator;
+ typedef typename table::l_iterator local_iterator;
+ typedef typename table::c_iterator const_iterator;
+ typedef typename table::iterator iterator;
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
private:
-#endif
table table_;
-
- BOOST_DEDUCED_TYPENAME types::iterator_base const&
- get(const_iterator const& it)
- {
- return boost::unordered_detail::iterator_access::get(it);
- }
public:
- // construct/destroy/copy
+ // constructors
explicit unordered_map(
- size_type n = boost::unordered_detail::default_bucket_count,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
- : table_(n, hf, eql, a)
- {
- }
+ size_type = boost::unordered::detail::default_bucket_count,
+ const hasher& = hasher(),
+ const key_equal& = key_equal(),
+ const allocator_type& = allocator_type());
- explicit unordered_map(allocator_type const& a)
- : table_(boost::unordered_detail::default_bucket_count,
- hasher(), key_equal(), a)
- {
- }
-
- unordered_map(unordered_map const& other, allocator_type const& a)
- : table_(other.table_, a)
- {
- }
+ explicit unordered_map(allocator_type const&);
template <class InputIt>
- unordered_map(InputIt f, InputIt l)
- : table_(boost::unordered_detail::initial_size(f, l),
- hasher(), key_equal(), allocator_type())
- {
- table_.insert_range(f, l);
- }
+ unordered_map(InputIt, InputIt);
template <class InputIt>
- unordered_map(InputIt f, InputIt l,
- size_type n,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal())
- : table_(boost::unordered_detail::initial_size(f, l, n),
- hf, eql, allocator_type())
- {
- table_.insert_range(f, l);
- }
+ unordered_map(
+ InputIt, InputIt,
+ size_type,
+ const hasher& = hasher(),
+ const key_equal& = key_equal());
template <class InputIt>
- unordered_map(InputIt f, InputIt l,
- size_type n,
- const hasher &hf,
- const key_equal &eql,
- const allocator_type &a)
- : table_(boost::unordered_detail::initial_size(f, l, n), hf, eql, a)
- {
- table_.insert_range(f, l);
- }
+ unordered_map(
+ InputIt, InputIt,
+ size_type,
+ const hasher&,
+ const key_equal&,
+ const allocator_type&);
- ~unordered_map() {}
+ // copy/move constructors
-#if !defined(BOOST_NO_RVALUE_REFERENCES)
- unordered_map(unordered_map const& other)
- : table_(other.table_)
+ unordered_map(unordered_map const&);
+
+ unordered_map(unordered_map const&, allocator_type const&);
+
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ unordered_map(BOOST_RV_REF(unordered_map) other)
+ : table_(other.table_, boost::unordered::detail::move_tag())
{
}
-
+#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_map(unordered_map&& other)
- : table_(other.table_, boost::unordered_detail::move_tag())
+ : table_(other.table_, boost::unordered::detail::move_tag())
{
}
+#endif
- unordered_map(unordered_map&& other, allocator_type const& a)
- : table_(other.table_, a, boost::unordered_detail::move_tag())
- {
- }
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+ unordered_map(unordered_map&&, allocator_type const&);
+#endif
- unordered_map& operator=(unordered_map const& x)
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ unordered_map(
+ std::initializer_list<value_type>,
+ size_type = boost::unordered::detail::default_bucket_count,
+ const hasher& = hasher(),
+ const key_equal&l = key_equal(),
+ const allocator_type& = allocator_type());
+#endif
+
+ // Destructor
+
+ ~unordered_map();
+
+ // Assign
+
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
{
- table_ = x.table_;
+ table_.assign(x.table_);
return *this;
}
- unordered_map& operator=(unordered_map&& x)
+ unordered_map& operator=(BOOST_RV_REF(unordered_map) x)
{
- table_.move(x.table_);
+ table_.move_assign(x.table_);
return *this;
}
#else
- unordered_map(boost::unordered_detail::move_from<
- unordered_map<K, T, H, P, A>
- > other)
- : table_(other.source.table_, boost::unordered_detail::move_tag())
+ unordered_map& operator=(unordered_map const& x)
{
+ table_.assign(x.table_);
+ return *this;
}
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
- unordered_map& operator=(unordered_map x)
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+ unordered_map& operator=(unordered_map&& x)
{
- table_.move(x.table_);
+ table_.move_assign(x.table_);
return *this;
}
#endif
#endif
-#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
- unordered_map(std::initializer_list<value_type> list,
- size_type n = boost::unordered_detail::default_bucket_count,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
- : table_(boost::unordered_detail::initial_size(
- list.begin(), list.end(), n),
- hf, eql, a)
- {
- table_.insert_range(list.begin(), list.end());
- }
-
- unordered_map& operator=(std::initializer_list<value_type> list)
- {
- table_.clear();
- table_.insert_range(list.begin(), list.end());
- return *this;
- }
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ unordered_map& operator=(std::initializer_list<value_type>);
#endif
allocator_type get_allocator() const
@@ -241,244 +195,257 @@ namespace boost
return table_.size_;
}
- size_type max_size() const
- {
- return table_.max_size();
- }
+ size_type max_size() const;
// iterators
iterator begin()
{
- return iterator(table_.begin());
+ return table_.begin();
}
const_iterator begin() const
{
- return const_iterator(table_.begin());
+ return table_.begin();
}
iterator end()
{
- return iterator(table_.end());
+ return iterator();
}
const_iterator end() const
{
- return const_iterator(table_.end());
+ return const_iterator();
}
const_iterator cbegin() const
{
- return const_iterator(table_.begin());
+ return table_.begin();
}
const_iterator cend() const
{
- return const_iterator(table_.end());
+ return const_iterator();
}
- // modifiers
+ // emplace
-#if defined(BOOST_UNORDERED_STD_FORWARD)
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
template <class... Args>
- std::pair<iterator, bool> emplace(Args&&... args)
+ std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
{
- return boost::unordered_detail::pair_cast<iterator, bool>(
- table_.emplace(std::forward<Args>(args)...));
+ return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
- iterator emplace_hint(const_iterator, Args&&... args)
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
{
- return iterator(table_.emplace(std::forward<Args>(args)...).first);
+ return table_.emplace(boost::forward<Args>(args)...).first;
}
#else
- #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
- std::pair<iterator, bool> emplace(value_type const& v = value_type())
- {
- return boost::unordered_detail::pair_cast<iterator, bool>(
- table_.emplace(v));
- }
-
- iterator emplace_hint(const_iterator,
- value_type const& v = value_type())
- {
- return iterator(table_.emplace(v).first);
- }
- #endif
-
-#define BOOST_UNORDERED_EMPLACE(z, n, _) \
- template < \
- BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
- > \
- std::pair<iterator, bool> emplace( \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
- ) \
- { \
- return boost::unordered_detail::pair_cast<iterator, bool>( \
- table_.emplace( \
- BOOST_UNORDERED_CALL_PARAMS(z, n) \
- )); \
- } \
- \
- template < \
- BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
- > \
- iterator emplace_hint(const_iterator, \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
- ) \
- { \
- return iterator(table_.emplace( \
- BOOST_UNORDERED_CALL_PARAMS(z, n)).first); \
- }
-
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
- BOOST_UNORDERED_EMPLACE, _)
+#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
-#undef BOOST_UNORDERED_EMPLACE
+ // 0 argument emplace requires special treatment in case
+ // the container is instantiated with a value type that
+ // doesn't have a default constructor.
-#endif
-
- std::pair<iterator, bool> insert(const value_type& obj)
+ std::pair<iterator, bool> emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type())
{
- return boost::unordered_detail::pair_cast<iterator, bool>(
- table_.emplace(obj));
+ return this->emplace(boost::move(v));
}
- iterator insert(const_iterator, const value_type& obj)
- {
- return iterator(table_.emplace(obj).first);
- }
-
- template <class InputIt>
- void insert(InputIt first, InputIt last)
+ iterator emplace_hint(const_iterator hint,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ )
{
- table_.insert_range(first, last);
+ return this->emplace_hint(hint, boost::move(v));
}
-#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
- void insert(std::initializer_list<value_type> list)
- {
- table_.insert_range(list.begin(), list.end());
- }
#endif
- iterator erase(const_iterator position)
+ template <typename A0>
+ std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
{
- return iterator(table_.erase_return_iterator(get(position)));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0))
+ );
}
- size_type erase(const key_type& k)
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
{
- return table_.erase_key(k);
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0))
+ ).first;
}
- iterator erase(const_iterator first, const_iterator last)
+ template <typename A0, typename A1>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
{
- return iterator(table_.erase_range(get(first), get(last)));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1))
+ );
}
- void quick_erase(const_iterator position)
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
{
- table_.erase(get(position));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1))
+ ).first;
}
- void erase_return_void(const_iterator position)
+ template <typename A0, typename A1, typename A2>
+ std::pair<iterator, bool> emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
{
- table_.erase(get(position));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1),
+ boost::forward<A2>(a2))
+ );
}
- void clear()
- {
- table_.clear();
- }
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ 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, _) \
+ template < \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
+ > \
+ std::pair<iterator, bool> emplace( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
+ ) \
+ { \
+ return table_.emplace( \
+ boost::unordered::detail::create_emplace_args( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
+ a) \
+ )); \
+ } \
+ \
+ template < \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
+ > \
+ iterator emplace_hint( \
+ const_iterator, \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
+ ) \
+ { \
+ return table_.emplace( \
+ boost::unordered::detail::create_emplace_args( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
+ a) \
+ )).first; \
+ }
- void swap(unordered_map& other)
- {
- table_.swap(other.table_);
- }
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_UNORDERED_EMPLACE, _)
- // observers
+#undef BOOST_UNORDERED_EMPLACE
- hasher hash_function() const
- {
- return table_.hash_function();
- }
+#endif
- key_equal key_eq() const
+ std::pair<iterator, bool> insert(value_type const& x)
{
- return table_.key_eq();
+ return this->emplace(x);
}
- mapped_type& operator[](const key_type &k)
+ std::pair<iterator, bool> insert(BOOST_RV_REF(value_type) x)
{
- return table_[k].second;
+ return this->emplace(boost::move(x));
}
- mapped_type& at(const key_type& k)
+ iterator insert(const_iterator hint, value_type const& x)
{
- return table_.at(k).second;
+ return this->emplace_hint(hint, x);
}
- mapped_type const& at(const key_type& k) const
+ iterator insert(const_iterator hint, BOOST_RV_REF(value_type) x)
{
- return table_.at(k).second;
+ return this->emplace_hint(hint, boost::move(x));
}
- // lookup
+ template <class InputIt> void insert(InputIt, InputIt);
- iterator find(const key_type& k)
- {
- return iterator(table_.find(k));
- }
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ void insert(std::initializer_list<value_type>);
+#endif
- const_iterator find(const key_type& k) const
- {
- return const_iterator(table_.find(k));
- }
+ iterator erase(const_iterator);
+ size_type erase(const key_type&);
+ iterator erase(const_iterator, const_iterator);
+ void quick_erase(const_iterator it) { erase(it); }
+ void erase_return_void(const_iterator it) { erase(it); }
+
+ void clear();
+ void swap(unordered_map&);
+
+ // observers
+
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ mapped_type& operator[](const key_type&);
+ mapped_type& at(const key_type&);
+ mapped_type const& at(const key_type&) const;
+
+ // lookup
+
+ iterator find(const key_type&);
+ const_iterator find(const key_type&) const;
template <class CompatibleKey, class CompatibleHash,
class CompatiblePredicate>
iterator find(
- CompatibleKey const& k,
- CompatibleHash const& hash,
- CompatiblePredicate const& eq)
- {
- return iterator(table_.find(k, hash, eq));
- }
+ CompatibleKey const&,
+ CompatibleHash const&,
+ CompatiblePredicate const&);
template <class CompatibleKey, class CompatibleHash,
class CompatiblePredicate>
const_iterator find(
- CompatibleKey const& k,
- CompatibleHash const& hash,
- CompatiblePredicate const& eq) const
- {
- return iterator(table_.find(k, hash, eq));
- }
+ CompatibleKey const&,
+ CompatibleHash const&,
+ CompatiblePredicate const&) const;
- size_type count(const key_type& k) const
- {
- return table_.count(k);
- }
+ size_type count(const key_type&) const;
std::pair<iterator, iterator>
- equal_range(const key_type& k)
- {
- return boost::unordered_detail::pair_cast<
- iterator, iterator>(
- table_.equal_range(k));
- }
-
+ equal_range(const key_type&);
std::pair<const_iterator, const_iterator>
- equal_range(const key_type& k) const
- {
- return boost::unordered_detail::pair_cast<
- const_iterator, const_iterator>(
- table_.equal_range(k));
- }
+ equal_range(const key_type&) const;
// bucket interface
@@ -492,24 +459,24 @@ namespace boost
return table_.max_bucket_count();
}
- size_type bucket_size(size_type n) const
- {
- return table_.bucket_size(n);
- }
+ size_type bucket_size(size_type) const;
size_type bucket(const key_type& k) const
{
- return table_.bucket_index(k);
+ return table::to_bucket(table_.bucket_count_,
+ table_.hash(k));
}
local_iterator begin(size_type n)
{
- return local_iterator(table_.bucket_begin(n));
+ return local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
const_local_iterator begin(size_type n) const
{
- return const_local_iterator(table_.bucket_begin(n));
+ return const_local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
local_iterator end(size_type)
@@ -524,7 +491,8 @@ namespace boost
const_local_iterator cbegin(size_type n) const
{
- return const_local_iterator(table_.bucket_begin(n));
+ return const_local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
const_local_iterator cend(size_type) const
@@ -534,67 +502,30 @@ namespace boost
// hash policy
- float load_factor() const
- {
- return table_.load_factor();
- }
-
float max_load_factor() const
{
return table_.mlf_;
}
- void max_load_factor(float m)
- {
- table_.max_load_factor(m);
- }
+ float load_factor() const;
+ void max_load_factor(float);
+ void rehash(size_type);
+ void reserve(size_type);
- void rehash(size_type n)
- {
- table_.rehash(n);
- }
-
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
- friend bool operator==<K, T, H, P, A>(
- unordered_map const&, unordered_map const&);
- friend bool operator!=<K, T, H, P, A>(
- unordered_map const&, unordered_map const&);
+ friend bool operator==<K,T,H,P,A>(
+ unordered_map const&, unordered_map const&);
+ friend bool operator!=<K,T,H,P,A>(
+ unordered_map const&, unordered_map const&);
#endif
}; // class template unordered_map
template <class K, class T, class H, class P, class A>
- inline bool operator==(unordered_map<K, T, H, P, A> const& m1,
- unordered_map<K, T, H, P, A> const& m2)
- {
-#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
- struct dummy { unordered_map<K,T,H,P,A> x; };
-#endif
- return m1.table_.equals(m2.table_);
- }
-
- template <class K, class T, class H, class P, class A>
- inline bool operator!=(unordered_map<K, T, H, P, A> const& m1,
- unordered_map<K, T, H, P, A> const& m2)
- {
-#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
- struct dummy { unordered_map<K,T,H,P,A> x; };
-#endif
- return !m1.table_.equals(m2.table_);
- }
-
- 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)
- {
-#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
- struct dummy { unordered_map<K,T,H,P,A> x; };
-#endif
- m1.swap(m2);
- }
-
- template <class K, class T, class H, class P, class A>
class unordered_multimap
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ BOOST_COPYABLE_AND_MOVABLE(unordered_multimap)
+#endif
public:
typedef K key_type;
@@ -604,180 +535,130 @@ namespace boost
typedef P key_equal;
typedef A allocator_type;
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
private:
-#endif
-
- typedef BOOST_DEDUCED_TYPENAME
- boost::unordered_detail::rebind_wrap<
- allocator_type, value_type>::type
- value_allocator;
- typedef boost::unordered_detail::multimap<K, H, P,
- value_allocator> types;
- typedef BOOST_DEDUCED_TYPENAME types::impl table;
-
- typedef BOOST_DEDUCED_TYPENAME types::iterator_base iterator_base;
+ typedef boost::unordered::detail::multimap<A, K, T, H, P> types;
+ typedef typename types::traits allocator_traits;
+ typedef typename types::table table;
public:
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::pointer pointer;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::const_pointer const_pointer;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::reference reference;
- typedef BOOST_DEDUCED_TYPENAME
- value_allocator::const_reference const_reference;
+ typedef typename allocator_traits::pointer pointer;
+ typedef typename allocator_traits::const_pointer const_pointer;
+
+ typedef value_type& reference;
+ typedef value_type const& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
- typedef boost::unordered_detail::hash_const_local_iterator<
- value_allocator, boost::unordered_detail::grouped>
- const_local_iterator;
- typedef boost::unordered_detail::hash_local_iterator<
- value_allocator, boost::unordered_detail::grouped>
- local_iterator;
- typedef boost::unordered_detail::hash_const_iterator<
- value_allocator, boost::unordered_detail::grouped>
- const_iterator;
- typedef boost::unordered_detail::hash_iterator<
- value_allocator, boost::unordered_detail::grouped>
- iterator;
+ typedef typename table::cl_iterator const_local_iterator;
+ typedef typename table::l_iterator local_iterator;
+ typedef typename table::c_iterator const_iterator;
+ typedef typename table::iterator iterator;
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
private:
-#endif
table table_;
- BOOST_DEDUCED_TYPENAME types::iterator_base const&
- get(const_iterator const& it)
- {
- return boost::unordered_detail::iterator_access::get(it);
- }
-
public:
- // construct/destroy/copy
+ // constructors
explicit unordered_multimap(
- size_type n = boost::unordered_detail::default_bucket_count,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
- : table_(n, hf, eql, a)
- {
- }
+ size_type = boost::unordered::detail::default_bucket_count,
+ const hasher& = hasher(),
+ const key_equal& = key_equal(),
+ const allocator_type& = allocator_type());
- explicit unordered_multimap(allocator_type const& a)
- : table_(boost::unordered_detail::default_bucket_count,
- hasher(), key_equal(), a)
- {
- }
-
- unordered_multimap(unordered_multimap const& other,
- allocator_type const& a)
- : table_(other.table_, a)
- {
- }
+ explicit unordered_multimap(allocator_type const&);
template <class InputIt>
- unordered_multimap(InputIt f, InputIt l)
- : table_(boost::unordered_detail::initial_size(f, l),
- hasher(), key_equal(), allocator_type())
- {
- table_.insert_range(f, l);
- }
+ unordered_multimap(InputIt, InputIt);
template <class InputIt>
- unordered_multimap(InputIt f, InputIt l,
- size_type n,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal())
- : table_(boost::unordered_detail::initial_size(f, l, n),
- hf, eql, allocator_type())
- {
- table_.insert_range(f, l);
- }
+ unordered_multimap(
+ InputIt, InputIt,
+ size_type,
+ const hasher& = hasher(),
+ const key_equal& = key_equal());
template <class InputIt>
- unordered_multimap(InputIt f, InputIt l,
- size_type n,
- const hasher &hf,
- const key_equal &eql,
- const allocator_type &a)
- : table_(boost::unordered_detail::initial_size(f, l, n), hf, eql, a)
- {
- table_.insert_range(f, l);
- }
+ unordered_multimap(
+ InputIt, InputIt,
+ size_type,
+ const hasher&,
+ const key_equal&,
+ const allocator_type&);
- ~unordered_multimap() {}
+ // copy/move constructors
-#if !defined(BOOST_NO_RVALUE_REFERENCES)
- unordered_multimap(unordered_multimap const& other)
- : table_(other.table_)
+ unordered_multimap(unordered_multimap const&);
+
+ unordered_multimap(unordered_multimap const&, allocator_type const&);
+
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
+ : table_(other.table_, boost::unordered::detail::move_tag())
{
}
-
+#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multimap(unordered_multimap&& other)
- : table_(other.table_, boost::unordered_detail::move_tag())
+ : table_(other.table_, boost::unordered::detail::move_tag())
{
}
+#endif
- unordered_multimap(unordered_multimap&& other, allocator_type const& a)
- : table_(other.table_, a, boost::unordered_detail::move_tag())
- {
- }
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+ unordered_multimap(unordered_multimap&&, allocator_type const&);
+#endif
- unordered_multimap& operator=(unordered_multimap const& x)
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ unordered_multimap(
+ std::initializer_list<value_type>,
+ size_type = boost::unordered::detail::default_bucket_count,
+ const hasher& = hasher(),
+ const key_equal&l = key_equal(),
+ const allocator_type& = allocator_type());
+#endif
+
+ // Destructor
+
+ ~unordered_multimap();
+
+ // Assign
+
+#if defined(BOOST_UNORDERED_USE_MOVE)
+ unordered_multimap& operator=(
+ BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
{
- table_ = x.table_;
+ table_.assign(x.table_);
return *this;
}
- unordered_multimap& operator=(unordered_multimap&& x)
+ unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
{
- table_.move(x.table_);
+ table_.move_assign(x.table_);
return *this;
}
#else
- unordered_multimap(boost::unordered_detail::move_from<
- unordered_multimap<K, T, H, P, A>
- > other)
- : table_(other.source.table_, boost::unordered_detail::move_tag())
+ unordered_multimap& operator=(unordered_multimap const& x)
{
+ table_.assign(x.table_);
+ return *this;
}
-#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0593)
- unordered_multimap& operator=(unordered_multimap x)
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+ unordered_multimap& operator=(unordered_multimap&& x)
{
- table_.move(x.table_);
+ table_.move_assign(x.table_);
return *this;
}
#endif
#endif
-#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
- unordered_multimap(std::initializer_list<value_type> list,
- size_type n = boost::unordered_detail::default_bucket_count,
- const hasher &hf = hasher(),
- const key_equal &eql = key_equal(),
- const allocator_type &a = allocator_type())
- : table_(boost::unordered_detail::initial_size(
- list.begin(), list.end(), n),
- hf, eql, a)
- {
- table_.insert_range(list.begin(), list.end());
- }
-
- unordered_multimap& operator=(std::initializer_list<value_type> list)
- {
- table_.clear();
- table_.insert_range(list.begin(), list.end());
- return *this;
- }
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ unordered_multimap& operator=(std::initializer_list<value_type>);
#endif
allocator_type get_allocator() const
@@ -797,227 +678,253 @@ namespace boost
return table_.size_;
}
- size_type max_size() const
- {
- return table_.max_size();
- }
+ size_type max_size() const;
// iterators
iterator begin()
{
- return iterator(table_.begin());
+ return table_.begin();
}
const_iterator begin() const
{
- return const_iterator(table_.begin());
+ return table_.begin();
}
iterator end()
{
- return iterator(table_.end());
+ return iterator();
}
const_iterator end() const
{
- return const_iterator(table_.end());
+ return const_iterator();
}
const_iterator cbegin() const
{
- return const_iterator(table_.begin());
+ return table_.begin();
}
const_iterator cend() const
{
- return const_iterator(table_.end());
+ return const_iterator();
}
- // modifiers
+ // emplace
-#if defined(BOOST_UNORDERED_STD_FORWARD)
+#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
template <class... Args>
- iterator emplace(Args&&... args)
+ iterator emplace(BOOST_FWD_REF(Args)... args)
{
- return iterator(table_.emplace(std::forward<Args>(args)...));
+ return table_.emplace(boost::forward<Args>(args)...);
}
template <class... Args>
- iterator emplace_hint(const_iterator, Args&&... args)
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
{
- return iterator(table_.emplace(std::forward<Args>(args)...));
+ return table_.emplace(boost::forward<Args>(args)...);
}
#else
- #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
- iterator emplace(value_type const& v = value_type())
- {
- return iterator(table_.emplace(v));
- }
-
- iterator emplace_hint(const_iterator,
- value_type const& v = value_type())
- {
- return iterator(table_.emplace(v));
- }
- #endif
-
-#define BOOST_UNORDERED_EMPLACE(z, n, _) \
- template < \
- BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
- > \
- iterator emplace( \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
- ) \
- { \
- return iterator( \
- table_.emplace( \
- BOOST_UNORDERED_CALL_PARAMS(z, n) \
- )); \
- } \
- \
- template < \
- BOOST_UNORDERED_TEMPLATE_ARGS(z, n) \
- > \
- iterator emplace_hint(const_iterator, \
- BOOST_UNORDERED_FUNCTION_PARAMS(z, n) \
- ) \
- { \
- return iterator(table_.emplace( \
- BOOST_UNORDERED_CALL_PARAMS(z, n) \
- )); \
- }
+#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
- BOOST_UNORDERED_EMPLACE, _)
+ // 0 argument emplace requires special treatment in case
+ // the container is instantiated with a value type that
+ // doesn't have a default constructor.
-#undef BOOST_UNORDERED_EMPLACE
-
-#endif
-
- iterator insert(const value_type& obj)
+ iterator emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type())
{
- return iterator(table_.emplace(obj));
+ return this->emplace(boost::move(v));
}
- iterator insert(const_iterator, const value_type& obj)
+ iterator emplace_hint(const_iterator hint,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ )
{
- return iterator(table_.emplace(obj));
+ return this->emplace_hint(hint, boost::move(v));
}
- template <class InputIt>
- void insert(InputIt first, InputIt last)
+#endif
+
+ template <typename A0>
+ iterator emplace(BOOST_FWD_REF(A0) a0)
{
- table_.insert_range(first, last);
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0))
+ );
}
-#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
- void insert(std::initializer_list<value_type> list)
+ template <typename A0>
+ iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
{
- table_.insert_range(list.begin(), list.end());
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0))
+ );
}
-#endif
- iterator erase(const_iterator position)
+ template <typename A0, typename A1>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
{
- return iterator(table_.erase_return_iterator(get(position)));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1))
+ );
}
- size_type erase(const key_type& k)
+ template <typename A0, typename A1>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1)
{
- return table_.erase_key(k);
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1))
+ );
}
- iterator erase(const_iterator first, const_iterator last)
+ template <typename A0, typename A1, typename A2>
+ iterator emplace(
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
{
- return iterator(table_.erase_range(get(first), get(last)));
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1),
+ boost::forward<A2>(a2))
+ );
}
- void quick_erase(const_iterator position)
+ template <typename A0, typename A1, typename A2>
+ iterator emplace_hint(const_iterator,
+ BOOST_FWD_REF(A0) a0,
+ BOOST_FWD_REF(A1) a1,
+ BOOST_FWD_REF(A2) a2)
+ {
+ return table_.emplace(
+ boost::unordered::detail::create_emplace_args(
+ boost::forward<A0>(a0),
+ boost::forward<A1>(a1),
+ boost::forward<A2>(a2))
+ );
+ }
+
+#define BOOST_UNORDERED_EMPLACE(z, n, _) \
+ template < \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
+ > \
+ iterator emplace( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
+ ) \
+ { \
+ return table_.emplace( \
+ boost::unordered::detail::create_emplace_args( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
+ a) \
+ )); \
+ } \
+ \
+ template < \
+ BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
+ > \
+ iterator emplace_hint( \
+ const_iterator, \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
+ ) \
+ { \
+ return table_.emplace( \
+ boost::unordered::detail::create_emplace_args( \
+ BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
+ a) \
+ )); \
+ }
+
+ BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
+ BOOST_UNORDERED_EMPLACE, _)
+
+#undef BOOST_UNORDERED_EMPLACE
+
+#endif
+
+ iterator insert(value_type const& x)
{
- table_.erase(get(position));
+ return this->emplace(x);
}
- void erase_return_void(const_iterator position)
+ iterator insert(BOOST_RV_REF(value_type) x)
{
- table_.erase(get(position));
+ return this->emplace(boost::move(x));
}
- void clear()
+ iterator insert(const_iterator hint, value_type const& x)
{
- table_.clear();
+ return this->emplace_hint(hint, x);
}
- void swap(unordered_multimap& other)
+ iterator insert(const_iterator hint, BOOST_RV_REF(value_type) x)
{
- table_.swap(other.table_);
+ return this->emplace_hint(hint, boost::move(x));
}
- // observers
+ template <class InputIt> void insert(InputIt, InputIt);
- hasher hash_function() const
- {
- return table_.hash_function();
- }
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ void insert(std::initializer_list<value_type>);
+#endif
- key_equal key_eq() const
- {
- return table_.key_eq();
- }
+ iterator erase(const_iterator);
+ size_type erase(const key_type&);
+ iterator erase(const_iterator, const_iterator);
+ void quick_erase(const_iterator it) { erase(it); }
+ void erase_return_void(const_iterator it) { erase(it); }
- // lookup
+ void clear();
+ void swap(unordered_multimap&);
- iterator find(const key_type& k)
- {
- return iterator(table_.find(k));
- }
+ // observers
- const_iterator find(const key_type& k) const
- {
- return const_iterator(table_.find(k));
- }
+ hasher hash_function() const;
+ key_equal key_eq() const;
+
+ // lookup
+
+ iterator find(const key_type&);
+ const_iterator find(const key_type&) const;
template <class CompatibleKey, class CompatibleHash,
class CompatiblePredicate>
iterator find(
- CompatibleKey const& k,
- CompatibleHash const& hash,
- CompatiblePredicate const& eq)
- {
- return iterator(table_.find(k, hash, eq));
- }
+ CompatibleKey const&,
+ CompatibleHash const&,
+ CompatiblePredicate const&);
template <class CompatibleKey, class CompatibleHash,
class CompatiblePredicate>
const_iterator find(
- CompatibleKey const& k,
- CompatibleHash const& hash,
- CompatiblePredicate const& eq) const
- {
- return iterator(table_.find(k, hash, eq));
- }
+ CompatibleKey const&,
+ CompatibleHash const&,
+ CompatiblePredicate const&) const;
- size_type count(const key_type& k) const
- {
- return table_.count(k);
- }
+ size_type count(const key_type&) const;
std::pair<iterator, iterator>
- equal_range(const key_type& k)
- {
- return boost::unordered_detail::pair_cast<
- iterator, iterator>(
- table_.equal_range(k));
- }
-
+ equal_range(const key_type&);
std::pair<const_iterator, const_iterator>
- equal_range(const key_type& k) const
- {
- return boost::unordered_detail::pair_cast<
- const_iterator, const_iterator>(
- table_.equal_range(k));
- }
+ equal_range(const key_type&) const;
// bucket interface
@@ -1031,24 +938,24 @@ namespace boost
return table_.max_bucket_count();
}
- size_type bucket_size(size_type n) const
- {
- return table_.bucket_size(n);
- }
+ size_type bucket_size(size_type) const;
size_type bucket(const key_type& k) const
{
- return table_.bucket_index(k);
+ return table::to_bucket(table_.bucket_count_,
+ table_.hash(k));
}
local_iterator begin(size_type n)
{
- return local_iterator(table_.bucket_begin(n));
+ return local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
const_local_iterator begin(size_type n) const
{
- return const_local_iterator(table_.bucket_begin(n));
+ return const_local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
local_iterator end(size_type)
@@ -1063,7 +970,8 @@ namespace boost
const_local_iterator cbegin(size_type n) const
{
- return const_local_iterator(table_.bucket_begin(n));
+ return const_local_iterator(
+ table_.begin(n), n, table_.bucket_count_);
}
const_local_iterator cend(size_type) const
@@ -1073,37 +981,640 @@ namespace boost
// hash policy
- float load_factor() const
- {
- return table_.load_factor();
- }
-
float max_load_factor() const
{
return table_.mlf_;
}
- void max_load_factor(float m)
- {
- table_.max_load_factor(m);
- }
-
- void rehash(size_type n)
- {
- table_.rehash(n);
- }
+ float load_factor() const;
+ void max_load_factor(float);
+ void rehash(size_type);
+ void reserve(size_type);
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
- friend bool operator==<K, T, H, P, A>(
- unordered_multimap const&, unordered_multimap const&);
- friend bool operator!=<K, T, H, P, A>(
- unordered_multimap const&, unordered_multimap const&);
+ friend bool operator==<K,T,H,P,A>(
+ unordered_multimap const&, unordered_multimap const&);
+ friend bool operator!=<K,T,H,P,A>(
+ unordered_multimap const&, unordered_multimap const&);
#endif
}; // class template unordered_multimap
+////////////////////////////////////////////////////////////////////////////////
+
+ 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)
+ : table_(n, hf, eql, 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)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ unordered_map const& other, allocator_type const& a)
+ : table_(other.table_, a)
+ {
+ }
+
+ 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)
+ : table_(boost::unordered::detail::initial_size(f, l),
+ hasher(), key_equal(), allocator_type())
+ {
+ 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 hasher &hf,
+ const key_equal &eql)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hf, eql, allocator_type())
+ {
+ 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 hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, 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() {}
+
+ template <class K, class T, class H, class P, class A>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ unordered_map const& other)
+ : table_(other.table_)
+ {
+ }
+
+#if !defined(BOOST_NO_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)
+ : 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>
+ unordered_map<K,T,H,P,A>::unordered_map(
+ std::initializer_list<value_type> list, size_type n,
+ const hasher &hf, const key_equal &eql, const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hf, eql, 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)
+ {
+ table_.clear();
+ table_.insert_range(list.begin(), list.end());
+ return *this;
+ }
+
+#endif
+
+ // size and capacity
+
+ template <class K, class T, class H, class P, class A>
+ std::size_t unordered_map<K,T,H,P,A>::max_size() const
+ {
+ return table_.max_size();
+ }
+
+ // modifiers
+
+ template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ void unordered_map<K,T,H,P,A>::insert(InputIt first, InputIt last)
+ {
+ table_.insert_range(first, last);
+ }
+
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::insert(
+ std::initializer_list<value_type> list)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+#endif
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::iterator
+ unordered_map<K,T,H,P,A>::erase(const_iterator position)
+ {
+ return table_.erase(position);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::size_type
+ unordered_map<K,T,H,P,A>::erase(const key_type& k)
+ {
+ return table_.erase_key(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::iterator
+ unordered_map<K,T,H,P,A>::erase(
+ const_iterator first, const_iterator last)
+ {
+ return table_.erase_range(first, last);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::clear()
+ {
+ table_.clear();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::swap(unordered_map& other)
+ {
+ table_.swap(other.table_);
+ }
+
+ // observers
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::hasher
+ unordered_map<K,T,H,P,A>::hash_function() const
+ {
+ return table_.hash_function();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::key_equal
+ unordered_map<K,T,H,P,A>::key_eq() const
+ {
+ return table_.key_eq();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::mapped_type&
+ unordered_map<K,T,H,P,A>::operator[](const key_type &k)
+ {
+ return table_[k].second;
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::mapped_type&
+ unordered_map<K,T,H,P,A>::at(const key_type& k)
+ {
+ return table_.at(k).second;
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::mapped_type const&
+ unordered_map<K,T,H,P,A>::at(const key_type& k) const
+ {
+ return table_.at(k).second;
+ }
+
+ // lookup
+
+ template <class K, class T, class H, class P, class A>
+ 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);
+ }
+
+ 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);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class CompatibleKey, class CompatibleHash,
+ class CompatiblePredicate>
+ typename unordered_map<K,T,H,P,A>::iterator
+ unordered_map<K,T,H,P,A>::find(
+ CompatibleKey const& k,
+ CompatibleHash const& hash,
+ CompatiblePredicate const& eq)
+ {
+ return table_.generic_find_node(k, hash, eq);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class CompatibleKey, class CompatibleHash,
+ class CompatiblePredicate>
+ typename unordered_map<K,T,H,P,A>::const_iterator
+ unordered_map<K,T,H,P,A>::find(
+ CompatibleKey const& k,
+ CompatibleHash const& hash,
+ CompatiblePredicate const& eq) const
+ {
+ return table_.generic_find_node(k, hash, eq);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::size_type
+ unordered_map<K,T,H,P,A>::count(const key_type& k) const
+ {
+ return table_.count(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ std::pair<
+ typename unordered_map<K,T,H,P,A>::iterator,
+ typename unordered_map<K,T,H,P,A>::iterator>
+ unordered_map<K,T,H,P,A>::equal_range(const key_type& k)
+ {
+ return table_.equal_range(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ std::pair<
+ typename unordered_map<K,T,H,P,A>::const_iterator,
+ typename unordered_map<K,T,H,P,A>::const_iterator>
+ unordered_map<K,T,H,P,A>::equal_range(const key_type& k) const
+ {
+ return table_.equal_range(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_map<K,T,H,P,A>::size_type
+ unordered_map<K,T,H,P,A>::bucket_size(size_type n) const
+ {
+ return table_.bucket_size(n);
+ }
+
+ // hash policy
+
+ template <class K, class T, class H, class P, class A>
+ float unordered_map<K,T,H,P,A>::load_factor() const
+ {
+ return table_.load_factor();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::max_load_factor(float m)
+ {
+ table_.max_load_factor(m);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::rehash(size_type n)
+ {
+ table_.rehash(n);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_map<K,T,H,P,A>::reserve(size_type n)
+ {
+ table_.reserve(n);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ inline bool operator==(
+ unordered_map<K,T,H,P,A> const& m1,
+ unordered_map<K,T,H,P,A> const& m2)
+ {
+#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
+ struct dummy { unordered_map<K,T,H,P,A> x; };
+#endif
+ return m1.table_.equals(m2.table_);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ inline bool operator!=(
+ unordered_map<K,T,H,P,A> const& m1,
+ unordered_map<K,T,H,P,A> const& m2)
+ {
+#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
+ struct dummy { unordered_map<K,T,H,P,A> x; };
+#endif
+ return !m1.table_.equals(m2.table_);
+ }
+
+ 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)
+ {
+#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
+ struct dummy { unordered_map<K,T,H,P,A> x; };
+#endif
+ m1.swap(m2);
+ }
+
+////////////////////////////////////////////////////////////////////////////////
+
+ 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)
+ : table_(n, hf, eql, 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)
+ {
+ }
+
+ template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ unordered_multimap const& other, allocator_type const& a)
+ : table_(other.table_, a)
+ {
+ }
+
+ 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)
+ : table_(boost::unordered::detail::initial_size(f, l),
+ hasher(), key_equal(), allocator_type())
+ {
+ 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 hasher &hf,
+ const key_equal &eql)
+ : table_(boost::unordered::detail::initial_size(f, l, n),
+ hf, eql, allocator_type())
+ {
+ 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 hasher &hf,
+ const key_equal &eql,
+ const allocator_type &a)
+ : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, 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() {}
+
+ template <class K, class T, class H, class P, class A>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ unordered_multimap const& other)
+ : table_(other.table_)
+ {
+ }
+
+#if !defined(BOOST_NO_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)
+ : 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>
+ unordered_multimap<K,T,H,P,A>::unordered_multimap(
+ std::initializer_list<value_type> list, size_type n,
+ const hasher &hf, const key_equal &eql, const allocator_type &a)
+ : table_(
+ boost::unordered::detail::initial_size(
+ list.begin(), list.end(), n),
+ hf, eql, 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)
+ {
+ table_.clear();
+ table_.insert_range(list.begin(), list.end());
+ return *this;
+ }
+
+#endif
+
+ // size and capacity
+
+ template <class K, class T, class H, class P, class A>
+ std::size_t unordered_multimap<K,T,H,P,A>::max_size() const
+ {
+ return table_.max_size();
+ }
+
+ // modifiers
+
+ template <class K, class T, class H, class P, class A>
+ template <class InputIt>
+ void unordered_multimap<K,T,H,P,A>::insert(InputIt first, InputIt last)
+ {
+ table_.insert_range(first, last);
+ }
+
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::insert(
+ std::initializer_list<value_type> list)
+ {
+ table_.insert_range(list.begin(), list.end());
+ }
+#endif
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::iterator
+ unordered_multimap<K,T,H,P,A>::erase(const_iterator position)
+ {
+ return table_.erase(position);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::size_type
+ unordered_multimap<K,T,H,P,A>::erase(const key_type& k)
+ {
+ return table_.erase_key(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::iterator
+ unordered_multimap<K,T,H,P,A>::erase(
+ const_iterator first, const_iterator last)
+ {
+ return table_.erase_range(first, last);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::clear()
+ {
+ table_.clear();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::swap(unordered_multimap& other)
+ {
+ table_.swap(other.table_);
+ }
+
+ // observers
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::hasher
+ unordered_multimap<K,T,H,P,A>::hash_function() const
+ {
+ return table_.hash_function();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::key_equal
+ unordered_multimap<K,T,H,P,A>::key_eq() const
+ {
+ return table_.key_eq();
+ }
+
+ // lookup
+
+ template <class K, class T, class H, class P, class A>
+ 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);
+ }
+
+ 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);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class CompatibleKey, class CompatibleHash,
+ class CompatiblePredicate>
+ typename unordered_multimap<K,T,H,P,A>::iterator
+ unordered_multimap<K,T,H,P,A>::find(
+ CompatibleKey const& k,
+ CompatibleHash const& hash,
+ CompatiblePredicate const& eq)
+ {
+ return table_.generic_find_node(k, hash, eq);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ template <class CompatibleKey, class CompatibleHash,
+ class CompatiblePredicate>
+ typename unordered_multimap<K,T,H,P,A>::const_iterator
+ unordered_multimap<K,T,H,P,A>::find(
+ CompatibleKey const& k,
+ CompatibleHash const& hash,
+ CompatiblePredicate const& eq) const
+ {
+ return table_.generic_find_node(k, hash, eq);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::size_type
+ unordered_multimap<K,T,H,P,A>::count(const key_type& k) const
+ {
+ return table_.count(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ std::pair<
+ typename unordered_multimap<K,T,H,P,A>::iterator,
+ typename unordered_multimap<K,T,H,P,A>::iterator>
+ unordered_multimap<K,T,H,P,A>::equal_range(const key_type& k)
+ {
+ return table_.equal_range(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ std::pair<
+ typename unordered_multimap<K,T,H,P,A>::const_iterator,
+ typename unordered_multimap<K,T,H,P,A>::const_iterator>
+ unordered_multimap<K,T,H,P,A>::equal_range(const key_type& k) const
+ {
+ return table_.equal_range(k);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ typename unordered_multimap<K,T,H,P,A>::size_type
+ unordered_multimap<K,T,H,P,A>::bucket_size(size_type n) const
+ {
+ return table_.bucket_size(n);
+ }
+
+ // hash policy
+
+ template <class K, class T, class H, class P, class A>
+ float unordered_multimap<K,T,H,P,A>::load_factor() const
+ {
+ return table_.load_factor();
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::max_load_factor(float m)
+ {
+ table_.max_load_factor(m);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::rehash(size_type n)
+ {
+ table_.rehash(n);
+ }
+
+ template <class K, class T, class H, class P, class A>
+ void unordered_multimap<K,T,H,P,A>::reserve(size_type n)
+ {
+ table_.reserve(n);
+ }
+
template <class K, class T, class H, class P, class A>
- inline bool operator==(unordered_multimap<K, T, H, P, A> const& m1,
- unordered_multimap<K, T, H, P, A> const& m2)
+ inline bool operator==(
+ unordered_multimap<K,T,H,P,A> const& m1,
+ unordered_multimap<K,T,H,P,A> const& m2)
{
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
struct dummy { unordered_multimap<K,T,H,P,A> x; };
@@ -1112,8 +1623,9 @@ namespace boost
}
template <class K, class T, class H, class P, class A>
- inline bool operator!=(unordered_multimap<K, T, H, P, A> const& m1,
- unordered_multimap<K, T, H, P, A> const& m2)
+ inline bool operator!=(
+ unordered_multimap<K,T,H,P,A> const& m1,
+ unordered_multimap<K,T,H,P,A> const& m2)
{
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
struct dummy { unordered_multimap<K,T,H,P,A> x; };
@@ -1122,8 +1634,9 @@ namespace boost
}
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)
+ inline void swap(
+ unordered_multimap<K,T,H,P,A> &m1,
+ unordered_multimap<K,T,H,P,A> &m2)
{
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
struct dummy { unordered_multimap<K,T,H,P,A> x; };
@@ -1131,6 +1644,7 @@ namespace boost
m1.swap(m2);
}
+} // namespace unordered
} // namespace boost
#if defined(BOOST_MSVC)