diff options
Diffstat (limited to 'boost/unordered/unordered_map.hpp')
-rw-r--r-- | boost/unordered/unordered_map.hpp | 91 |
1 files changed, 53 insertions, 38 deletions
diff --git a/boost/unordered/unordered_map.hpp b/boost/unordered/unordered_map.hpp index 1a7ff151cf..ce52e5becf 100644 --- a/boost/unordered/unordered_map.hpp +++ b/boost/unordered/unordered_map.hpp @@ -14,14 +14,13 @@ #endif #include <boost/unordered/unordered_map_fwd.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_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) #include <initializer_list> #endif @@ -133,7 +132,7 @@ namespace unordered unordered_map(unordered_map&&, allocator_type const&); #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_map( std::initializer_list<value_type>, size_type = boost::unordered::detail::default_bucket_count, @@ -176,7 +175,7 @@ namespace unordered #endif #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_map& operator=(std::initializer_list<value_type>); #endif @@ -203,12 +202,12 @@ namespace unordered iterator begin() { - return iterator(table_.begin()); + return table_.begin(); } const_iterator begin() const { - return const_iterator(table_.begin()); + return table_.begin(); } iterator end() @@ -223,7 +222,7 @@ namespace unordered const_iterator cbegin() const { - return const_iterator(table_.begin()); + return table_.begin(); } const_iterator cend() const @@ -233,15 +232,15 @@ namespace unordered // emplace -#if defined(BOOST_UNORDERED_VARIADIC_MOVE) +#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 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 table_.emplace(boost::forward<Args>(args)...).first; } @@ -401,7 +400,7 @@ namespace unordered template <class InputIt> void insert(InputIt, InputIt); -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) void insert(std::initializer_list<value_type>); #endif @@ -465,7 +464,8 @@ namespace unordered size_type bucket(const key_type& k) const { - return table_.hash_function()(k) % table_.bucket_count_; + return table::to_bucket(table_.bucket_count_, + table_.hash(k)); } local_iterator begin(size_type n) @@ -514,6 +514,7 @@ namespace unordered 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>( @@ -617,7 +618,7 @@ namespace unordered unordered_multimap(unordered_multimap&&, allocator_type const&); #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multimap( std::initializer_list<value_type>, size_type = boost::unordered::detail::default_bucket_count, @@ -661,7 +662,7 @@ namespace unordered #endif #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) unordered_multimap& operator=(std::initializer_list<value_type>); #endif @@ -688,12 +689,12 @@ namespace unordered iterator begin() { - return iterator(table_.begin()); + return table_.begin(); } const_iterator begin() const { - return const_iterator(table_.begin()); + return table_.begin(); } iterator end() @@ -708,7 +709,7 @@ namespace unordered const_iterator cbegin() const { - return const_iterator(table_.begin()); + return table_.begin(); } const_iterator cend() const @@ -718,15 +719,15 @@ namespace unordered // emplace -#if defined(BOOST_UNORDERED_VARIADIC_MOVE) +#if !defined(BOOST_NO_VARIADIC_TEMPLATES) template <class... Args> - iterator emplace(Args&&... args) + iterator emplace(BOOST_FWD_REF(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 table_.emplace(boost::forward<Args>(args)...); } @@ -886,7 +887,7 @@ namespace unordered template <class InputIt> void insert(InputIt, InputIt); -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) void insert(std::initializer_list<value_type>); #endif @@ -946,7 +947,8 @@ namespace unordered size_type bucket(const key_type& k) const { - return table_.hash_function()(k) % table_.bucket_count_; + return table::to_bucket(table_.bucket_count_, + table_.hash(k)); } local_iterator begin(size_type n) @@ -995,6 +997,7 @@ namespace unordered 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>( @@ -1084,7 +1087,7 @@ namespace unordered #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#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( @@ -1126,7 +1129,7 @@ namespace unordered table_.insert_range(first, last); } -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#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) @@ -1139,7 +1142,7 @@ namespace unordered typename unordered_map<K,T,H,P,A>::iterator unordered_map<K,T,H,P,A>::erase(const_iterator position) { - return iterator(table_.erase(position.node_)); + return table_.erase(position); } template <class K, class T, class H, class P, class A> @@ -1154,7 +1157,7 @@ namespace unordered unordered_map<K,T,H,P,A>::erase( const_iterator first, const_iterator last) { - return iterator(table_.erase_range(first.node_, last.node_)); + return table_.erase_range(first, last); } template <class K, class T, class H, class P, class A> @@ -1212,14 +1215,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 iterator(table_.find_node(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 const_iterator(table_.find_node(k)); + return table_.find_node(k); } template <class K, class T, class H, class P, class A> @@ -1231,7 +1234,7 @@ namespace unordered CompatibleHash const& hash, CompatiblePredicate const& eq) { - return iterator(table_.generic_find_node(k, hash, eq)); + return table_.generic_find_node(k, hash, eq); } template <class K, class T, class H, class P, class A> @@ -1243,7 +1246,7 @@ namespace unordered CompatibleHash const& hash, CompatiblePredicate const& eq) const { - return const_iterator(table_.generic_find_node(k, hash, eq)); + return table_.generic_find_node(k, hash, eq); } template <class K, class T, class H, class P, class A> @@ -1299,6 +1302,12 @@ namespace unordered } 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) @@ -1411,7 +1420,7 @@ namespace unordered #endif -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#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( @@ -1453,7 +1462,7 @@ namespace unordered table_.insert_range(first, last); } -#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) +#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) @@ -1466,7 +1475,7 @@ namespace unordered typename unordered_multimap<K,T,H,P,A>::iterator unordered_multimap<K,T,H,P,A>::erase(const_iterator position) { - return iterator(table_.erase(position.node_)); + return table_.erase(position); } template <class K, class T, class H, class P, class A> @@ -1481,7 +1490,7 @@ namespace unordered unordered_multimap<K,T,H,P,A>::erase( const_iterator first, const_iterator last) { - return iterator(table_.erase_range(first.node_, last.node_)); + return table_.erase_range(first, last); } template <class K, class T, class H, class P, class A> @@ -1518,14 +1527,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 iterator(table_.find_node(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 const_iterator(table_.find_node(k)); + return table_.find_node(k); } template <class K, class T, class H, class P, class A> @@ -1537,7 +1546,7 @@ namespace unordered CompatibleHash const& hash, CompatiblePredicate const& eq) { - return iterator(table_.generic_find_node(k, hash, eq)); + return table_.generic_find_node(k, hash, eq); } template <class K, class T, class H, class P, class A> @@ -1549,7 +1558,7 @@ namespace unordered CompatibleHash const& hash, CompatiblePredicate const& eq) const { - return const_iterator(table_.generic_find_node(k, hash, eq)); + return table_.generic_find_node(k, hash, eq); } template <class K, class T, class H, class P, class A> @@ -1605,6 +1614,12 @@ namespace unordered } 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) |