2 // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
3 // Copyright (C) 2005-2011 Daniel James.
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/unordered for documentation
9 #ifndef BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED
10 #define BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED
12 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
16 #include <boost/unordered/unordered_map_fwd.hpp>
17 #include <boost/unordered/detail/allocator_helpers.hpp>
18 #include <boost/unordered/detail/equivalent.hpp>
19 #include <boost/unordered/detail/unique.hpp>
20 #include <boost/unordered/detail/util.hpp>
21 #include <boost/functional/hash.hpp>
22 #include <boost/move/move.hpp>
24 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
25 #include <initializer_list>
28 #if defined(BOOST_MSVC)
30 #if BOOST_MSVC >= 1400
31 #pragma warning(disable:4396) //the inline specifier cannot be used when a
32 // friend declaration refers to a specialization
33 // of a function template
41 template <class K, class T, class H, class P, class A>
44 BOOST_COPYABLE_AND_MOVABLE(unordered_map)
49 typedef std::pair<const K, T> value_type;
50 typedef T mapped_type;
53 typedef A allocator_type;
57 typedef typename boost::unordered::detail::rebind_wrap<
58 allocator_type, value_type>::type
61 typedef boost::unordered::detail::allocator_traits<value_allocator>
64 typedef boost::unordered::detail::map<value_allocator, K, H, P>
66 typedef typename types::table table;
70 typedef typename allocator_traits::pointer pointer;
71 typedef typename allocator_traits::const_pointer const_pointer;
73 typedef value_type& reference;
74 typedef value_type const& const_reference;
76 typedef std::size_t size_type;
77 typedef std::ptrdiff_t difference_type;
79 typedef typename table::cl_iterator const_local_iterator;
80 typedef typename table::l_iterator local_iterator;
81 typedef typename table::c_iterator const_iterator;
82 typedef typename table::iterator iterator;
92 explicit unordered_map(
93 size_type = boost::unordered::detail::default_bucket_count,
94 const hasher& = hasher(),
95 const key_equal& = key_equal(),
96 const allocator_type& = allocator_type());
98 explicit unordered_map(allocator_type const&);
100 template <class InputIt>
101 unordered_map(InputIt, InputIt);
103 template <class InputIt>
107 const hasher& = hasher(),
108 const key_equal& = key_equal());
110 template <class InputIt>
116 const allocator_type&);
118 // copy/move constructors
120 unordered_map(unordered_map const&);
122 unordered_map(unordered_map const&, allocator_type const&);
124 unordered_map(BOOST_RV_REF(unordered_map) other)
125 : table_(other.table_, boost::unordered::detail::move_tag())
129 #if !defined(BOOST_NO_RVALUE_REFERENCES)
130 unordered_map(unordered_map&&, allocator_type const&);
133 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
135 std::initializer_list<value_type>,
136 size_type = boost::unordered::detail::default_bucket_count,
137 const hasher& = hasher(),
138 const key_equal&l = key_equal(),
139 const allocator_type& = allocator_type());
148 unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
150 table_.assign(x.table_);
154 unordered_map& operator=(BOOST_RV_REF(unordered_map) x)
156 table_.move_assign(x.table_);
160 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
161 unordered_map& operator=(std::initializer_list<value_type>);
164 allocator_type get_allocator() const
166 return table_.node_alloc();
173 return table_.size_ == 0;
176 size_type size() const
181 size_type max_size() const;
187 return iterator(table_.begin());
190 const_iterator begin() const
192 return const_iterator(table_.begin());
200 const_iterator end() const
202 return const_iterator();
205 const_iterator cbegin() const
207 return const_iterator(table_.begin());
210 const_iterator cend() const
212 return const_iterator();
217 #if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
218 template <class... Args>
219 std::pair<iterator, bool> emplace(Args&&... args)
221 return table_.emplace(std::forward<Args>(args)...);
224 template <class... Args>
225 iterator emplace_hint(const_iterator, Args&&... args)
227 return iterator(table_.emplace(std::forward<Args>(args)...).first);
231 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
233 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
235 std::pair<iterator, bool> emplace( \
236 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
239 return table_.emplace( \
240 boost::unordered::detail::create_emplace_args( \
241 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
247 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
249 iterator emplace_hint( \
251 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
254 return iterator(table_.emplace( \
255 boost::unordered::detail::create_emplace_args( \
256 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
261 BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
262 BOOST_UNORDERED_EMPLACE, _)
264 #undef BOOST_UNORDERED_EMPLACE
266 #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
268 std::pair<iterator, bool> emplace(
269 boost::unordered::detail::empty_emplace
270 = boost::unordered::detail::empty_emplace(),
271 value_type v = value_type())
273 return this->emplace(boost::move(v));
276 iterator emplace_hint(const_iterator hint,
277 boost::unordered::detail::empty_emplace
278 = boost::unordered::detail::empty_emplace(),
279 value_type v = value_type()
282 return this->emplace_hint(hint, boost::move(v));
289 std::pair<iterator, bool> insert(value_type const& x)
291 return this->emplace(x);
294 std::pair<iterator, bool> insert(BOOST_RV_REF(value_type) x)
296 return this->emplace(boost::move(x));
299 iterator insert(const_iterator hint, value_type const& x)
301 return this->emplace_hint(hint, x);
304 iterator insert(const_iterator hint, BOOST_RV_REF(value_type) x)
306 return this->emplace_hint(hint, boost::move(x));
309 template <class InputIt> void insert(InputIt, InputIt);
311 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
312 void insert(std::initializer_list<value_type>);
315 iterator erase(const_iterator);
316 size_type erase(const key_type&);
317 iterator erase(const_iterator, const_iterator);
318 void quick_erase(const_iterator it) { erase(it); }
319 void erase_return_void(const_iterator it) { erase(it); }
322 void swap(unordered_map&);
326 hasher hash_function() const;
327 key_equal key_eq() const;
329 mapped_type& operator[](const key_type&);
330 mapped_type& at(const key_type&);
331 mapped_type const& at(const key_type&) const;
335 iterator find(const key_type&);
336 const_iterator find(const key_type&) const;
338 template <class CompatibleKey, class CompatibleHash,
339 class CompatiblePredicate>
341 CompatibleKey const&,
342 CompatibleHash const&,
343 CompatiblePredicate const&);
345 template <class CompatibleKey, class CompatibleHash,
346 class CompatiblePredicate>
348 CompatibleKey const&,
349 CompatibleHash const&,
350 CompatiblePredicate const&) const;
352 size_type count(const key_type&) const;
354 std::pair<iterator, iterator>
355 equal_range(const key_type&);
356 std::pair<const_iterator, const_iterator>
357 equal_range(const key_type&) const;
361 size_type bucket_count() const
363 return table_.bucket_count_;
366 size_type max_bucket_count() const
368 return table_.max_bucket_count();
371 size_type bucket_size(size_type) const;
373 size_type bucket(const key_type& k) const
375 return table_.hash_function()(k) % table_.bucket_count_;
378 local_iterator begin(size_type n)
380 return table_.size_ ? local_iterator(
381 table_.get_start(n), n, table_.bucket_count_) :
385 const_local_iterator begin(size_type n) const
387 return table_.size_ ? const_local_iterator(
388 table_.get_start(n), n, table_.bucket_count_) :
389 const_local_iterator();
392 local_iterator end(size_type)
394 return local_iterator();
397 const_local_iterator end(size_type) const
399 return const_local_iterator();
402 const_local_iterator cbegin(size_type n) const
404 return table_.size_ ? const_local_iterator(
405 table_.get_start(n), n, table_.bucket_count_) :
406 const_local_iterator();
409 const_local_iterator cend(size_type) const
411 return const_local_iterator();
416 float max_load_factor() const
421 float load_factor() const;
422 void max_load_factor(float);
423 void rehash(size_type);
425 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
426 friend bool operator==<K,T,H,P,A>(
427 unordered_map const&, unordered_map const&);
428 friend bool operator!=<K,T,H,P,A>(
429 unordered_map const&, unordered_map const&);
431 }; // class template unordered_map
433 template <class K, class T, class H, class P, class A>
434 class unordered_multimap
436 BOOST_COPYABLE_AND_MOVABLE(unordered_multimap)
441 typedef std::pair<const K, T> value_type;
442 typedef T mapped_type;
445 typedef A allocator_type;
449 typedef typename boost::unordered::detail::rebind_wrap<
450 allocator_type, value_type>::type
453 typedef boost::unordered::detail::allocator_traits<value_allocator>
456 typedef boost::unordered::detail::multimap<value_allocator, K, H, P>
458 typedef typename types::table table;
462 typedef typename allocator_traits::pointer pointer;
463 typedef typename allocator_traits::const_pointer const_pointer;
465 typedef value_type& reference;
466 typedef value_type const& const_reference;
468 typedef std::size_t size_type;
469 typedef std::ptrdiff_t difference_type;
471 typedef typename table::cl_iterator const_local_iterator;
472 typedef typename table::l_iterator local_iterator;
473 typedef typename table::c_iterator const_iterator;
474 typedef typename table::iterator iterator;
484 explicit unordered_multimap(
485 size_type = boost::unordered::detail::default_bucket_count,
486 const hasher& = hasher(),
487 const key_equal& = key_equal(),
488 const allocator_type& = allocator_type());
490 explicit unordered_multimap(allocator_type const&);
492 template <class InputIt>
493 unordered_multimap(InputIt, InputIt);
495 template <class InputIt>
499 const hasher& = hasher(),
500 const key_equal& = key_equal());
502 template <class InputIt>
508 const allocator_type&);
510 // copy/move constructors
512 unordered_multimap(unordered_multimap const&);
514 unordered_multimap(unordered_multimap const&, allocator_type const&);
516 unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
517 : table_(other.table_, boost::unordered::detail::move_tag())
521 #if !defined(BOOST_NO_RVALUE_REFERENCES)
522 unordered_multimap(unordered_multimap&&, allocator_type const&);
525 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
527 std::initializer_list<value_type>,
528 size_type = boost::unordered::detail::default_bucket_count,
529 const hasher& = hasher(),
530 const key_equal&l = key_equal(),
531 const allocator_type& = allocator_type());
536 ~unordered_multimap();
540 unordered_multimap& operator=(
541 BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
543 table_.assign(x.table_);
547 unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
549 table_.move_assign(x.table_);
553 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
554 unordered_multimap& operator=(std::initializer_list<value_type>);
557 allocator_type get_allocator() const
559 return table_.node_alloc();
566 return table_.size_ == 0;
569 size_type size() const
574 size_type max_size() const;
580 return iterator(table_.begin());
583 const_iterator begin() const
585 return const_iterator(table_.begin());
593 const_iterator end() const
595 return const_iterator();
598 const_iterator cbegin() const
600 return const_iterator(table_.begin());
603 const_iterator cend() const
605 return const_iterator();
610 #if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
611 template <class... Args>
612 iterator emplace(Args&&... args)
614 return iterator(table_.emplace(std::forward<Args>(args)...));
617 template <class... Args>
618 iterator emplace_hint(const_iterator, Args&&... args)
620 return iterator(table_.emplace(std::forward<Args>(args)...));
624 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
626 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
629 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
632 return iterator(table_.emplace( \
633 boost::unordered::detail::create_emplace_args( \
634 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
640 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
642 iterator emplace_hint( \
644 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
647 return iterator(table_.emplace( \
648 boost::unordered::detail::create_emplace_args( \
649 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
654 BOOST_PP_REPEAT_FROM_TO(1, BOOST_UNORDERED_EMPLACE_LIMIT,
655 BOOST_UNORDERED_EMPLACE, _)
657 #undef BOOST_UNORDERED_EMPLACE
659 #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
662 boost::unordered::detail::empty_emplace
663 = boost::unordered::detail::empty_emplace(),
664 value_type v = value_type())
666 return iterator(this->emplace(boost::move(v)));
669 iterator emplace_hint(const_iterator hint,
670 boost::unordered::detail::empty_emplace
671 = boost::unordered::detail::empty_emplace(),
672 value_type v = value_type()
675 return iterator(this->emplace_hint(hint, boost::move(v)));
682 iterator insert(value_type const& x)
684 return this->emplace(x);
687 iterator insert(BOOST_RV_REF(value_type) x)
689 return this->emplace(boost::move(x));
692 iterator insert(const_iterator hint, value_type const& x)
694 return this->emplace_hint(hint, x);
697 iterator insert(const_iterator hint, BOOST_RV_REF(value_type) x)
699 return this->emplace_hint(hint, boost::move(x));
702 template <class InputIt> void insert(InputIt, InputIt);
704 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
705 void insert(std::initializer_list<value_type>);
708 iterator erase(const_iterator);
709 size_type erase(const key_type&);
710 iterator erase(const_iterator, const_iterator);
711 void quick_erase(const_iterator it) { erase(it); }
712 void erase_return_void(const_iterator it) { erase(it); }
715 void swap(unordered_multimap&);
719 hasher hash_function() const;
720 key_equal key_eq() const;
724 iterator find(const key_type&);
725 const_iterator find(const key_type&) const;
727 template <class CompatibleKey, class CompatibleHash,
728 class CompatiblePredicate>
730 CompatibleKey const&,
731 CompatibleHash const&,
732 CompatiblePredicate const&);
734 template <class CompatibleKey, class CompatibleHash,
735 class CompatiblePredicate>
737 CompatibleKey const&,
738 CompatibleHash const&,
739 CompatiblePredicate const&) const;
741 size_type count(const key_type&) const;
743 std::pair<iterator, iterator>
744 equal_range(const key_type&);
745 std::pair<const_iterator, const_iterator>
746 equal_range(const key_type&) const;
750 size_type bucket_count() const
752 return table_.bucket_count_;
755 size_type max_bucket_count() const
757 return table_.max_bucket_count();
760 size_type bucket_size(size_type) const;
762 size_type bucket(const key_type& k) const
764 return table_.hash_function()(k) % table_.bucket_count_;
767 local_iterator begin(size_type n)
769 return table_.size_ ? local_iterator(
770 table_.get_start(n), n, table_.bucket_count_) :
774 const_local_iterator begin(size_type n) const
776 return table_.size_ ? const_local_iterator(
777 table_.get_start(n), n, table_.bucket_count_) :
778 const_local_iterator();
781 local_iterator end(size_type)
783 return local_iterator();
786 const_local_iterator end(size_type) const
788 return const_local_iterator();
791 const_local_iterator cbegin(size_type n) const
793 return table_.size_ ? const_local_iterator(
794 table_.get_start(n), n, table_.bucket_count_) :
795 const_local_iterator();
798 const_local_iterator cend(size_type) const
800 return const_local_iterator();
805 float max_load_factor() const
810 float load_factor() const;
811 void max_load_factor(float);
812 void rehash(size_type);
814 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
815 friend bool operator==<K,T,H,P,A>(
816 unordered_multimap const&, unordered_multimap const&);
817 friend bool operator!=<K,T,H,P,A>(
818 unordered_multimap const&, unordered_multimap const&);
820 }; // class template unordered_multimap
822 ////////////////////////////////////////////////////////////////////////////////
824 template <class K, class T, class H, class P, class A>
825 unordered_map<K,T,H,P,A>::unordered_map(
826 size_type n, const hasher &hf, const key_equal &eql,
827 const allocator_type &a)
828 : table_(n, hf, eql, a)
832 template <class K, class T, class H, class P, class A>
833 unordered_map<K,T,H,P,A>::unordered_map(allocator_type const& a)
834 : table_(boost::unordered::detail::default_bucket_count,
835 hasher(), key_equal(), a)
839 template <class K, class T, class H, class P, class A>
840 unordered_map<K,T,H,P,A>::unordered_map(
841 unordered_map const& other, allocator_type const& a)
842 : table_(other.table_, a)
846 template <class K, class T, class H, class P, class A>
847 template <class InputIt>
848 unordered_map<K,T,H,P,A>::unordered_map(InputIt f, InputIt l)
849 : table_(boost::unordered::detail::initial_size(f, l),
850 hasher(), key_equal(), allocator_type())
852 table_.insert_range(f, l);
855 template <class K, class T, class H, class P, class A>
856 template <class InputIt>
857 unordered_map<K,T,H,P,A>::unordered_map(
858 InputIt f, InputIt l,
861 const key_equal &eql)
862 : table_(boost::unordered::detail::initial_size(f, l, n),
863 hf, eql, allocator_type())
865 table_.insert_range(f, l);
868 template <class K, class T, class H, class P, class A>
869 template <class InputIt>
870 unordered_map<K,T,H,P,A>::unordered_map(
871 InputIt f, InputIt l,
874 const key_equal &eql,
875 const allocator_type &a)
876 : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
878 table_.insert_range(f, l);
881 template <class K, class T, class H, class P, class A>
882 unordered_map<K,T,H,P,A>::~unordered_map() {}
884 template <class K, class T, class H, class P, class A>
885 unordered_map<K,T,H,P,A>::unordered_map(
886 unordered_map const& other)
887 : table_(other.table_)
891 #if !defined(BOOST_NO_RVALUE_REFERENCES)
893 template <class K, class T, class H, class P, class A>
894 unordered_map<K,T,H,P,A>::unordered_map(
895 unordered_map&& other, allocator_type const& a)
896 : table_(other.table_, a, boost::unordered::detail::move_tag())
902 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
904 template <class K, class T, class H, class P, class A>
905 unordered_map<K,T,H,P,A>::unordered_map(
906 std::initializer_list<value_type> list, size_type n,
907 const hasher &hf, const key_equal &eql, const allocator_type &a)
909 boost::unordered::detail::initial_size(
910 list.begin(), list.end(), n),
913 table_.insert_range(list.begin(), list.end());
916 template <class K, class T, class H, class P, class A>
917 unordered_map<K,T,H,P,A>& unordered_map<K,T,H,P,A>::operator=(
918 std::initializer_list<value_type> list)
921 table_.insert_range(list.begin(), list.end());
929 template <class K, class T, class H, class P, class A>
930 std::size_t unordered_map<K,T,H,P,A>::max_size() const
932 return table_.max_size();
937 template <class K, class T, class H, class P, class A>
938 template <class InputIt>
939 void unordered_map<K,T,H,P,A>::insert(InputIt first, InputIt last)
941 table_.insert_range(first, last);
944 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
945 template <class K, class T, class H, class P, class A>
946 void unordered_map<K,T,H,P,A>::insert(
947 std::initializer_list<value_type> list)
949 table_.insert_range(list.begin(), list.end());
953 template <class K, class T, class H, class P, class A>
954 typename unordered_map<K,T,H,P,A>::iterator
955 unordered_map<K,T,H,P,A>::erase(const_iterator position)
957 return iterator(table_.erase(position.node_));
960 template <class K, class T, class H, class P, class A>
961 typename unordered_map<K,T,H,P,A>::size_type
962 unordered_map<K,T,H,P,A>::erase(const key_type& k)
964 return table_.erase_key(k);
967 template <class K, class T, class H, class P, class A>
968 typename unordered_map<K,T,H,P,A>::iterator
969 unordered_map<K,T,H,P,A>::erase(
970 const_iterator first, const_iterator last)
972 return iterator(table_.erase_range(first.node_, last.node_));
975 template <class K, class T, class H, class P, class A>
976 void unordered_map<K,T,H,P,A>::clear()
981 template <class K, class T, class H, class P, class A>
982 void unordered_map<K,T,H,P,A>::swap(unordered_map& other)
984 table_.swap(other.table_);
989 template <class K, class T, class H, class P, class A>
990 typename unordered_map<K,T,H,P,A>::hasher
991 unordered_map<K,T,H,P,A>::hash_function() const
993 return table_.hash_function();
996 template <class K, class T, class H, class P, class A>
997 typename unordered_map<K,T,H,P,A>::key_equal
998 unordered_map<K,T,H,P,A>::key_eq() const
1000 return table_.key_eq();
1003 template <class K, class T, class H, class P, class A>
1004 typename unordered_map<K,T,H,P,A>::mapped_type&
1005 unordered_map<K,T,H,P,A>::operator[](const key_type &k)
1007 return table_[k].second;
1010 template <class K, class T, class H, class P, class A>
1011 typename unordered_map<K,T,H,P,A>::mapped_type&
1012 unordered_map<K,T,H,P,A>::at(const key_type& k)
1014 return table_.at(k).second;
1017 template <class K, class T, class H, class P, class A>
1018 typename unordered_map<K,T,H,P,A>::mapped_type const&
1019 unordered_map<K,T,H,P,A>::at(const key_type& k) const
1021 return table_.at(k).second;
1026 template <class K, class T, class H, class P, class A>
1027 typename unordered_map<K,T,H,P,A>::iterator
1028 unordered_map<K,T,H,P,A>::find(const key_type& k)
1030 return iterator(table_.find_node(k));
1033 template <class K, class T, class H, class P, class A>
1034 typename unordered_map<K,T,H,P,A>::const_iterator
1035 unordered_map<K,T,H,P,A>::find(const key_type& k) const
1037 return const_iterator(table_.find_node(k));
1040 template <class K, class T, class H, class P, class A>
1041 template <class CompatibleKey, class CompatibleHash,
1042 class CompatiblePredicate>
1043 typename unordered_map<K,T,H,P,A>::iterator
1044 unordered_map<K,T,H,P,A>::find(
1045 CompatibleKey const& k,
1046 CompatibleHash const& hash,
1047 CompatiblePredicate const& eq)
1049 return iterator(table_.generic_find_node(k, hash, eq));
1052 template <class K, class T, class H, class P, class A>
1053 template <class CompatibleKey, class CompatibleHash,
1054 class CompatiblePredicate>
1055 typename unordered_map<K,T,H,P,A>::const_iterator
1056 unordered_map<K,T,H,P,A>::find(
1057 CompatibleKey const& k,
1058 CompatibleHash const& hash,
1059 CompatiblePredicate const& eq) const
1061 return const_iterator(table_.generic_find_node(k, hash, eq));
1064 template <class K, class T, class H, class P, class A>
1065 typename unordered_map<K,T,H,P,A>::size_type
1066 unordered_map<K,T,H,P,A>::count(const key_type& k) const
1068 return table_.count(k);
1071 template <class K, class T, class H, class P, class A>
1073 typename unordered_map<K,T,H,P,A>::iterator,
1074 typename unordered_map<K,T,H,P,A>::iterator>
1075 unordered_map<K,T,H,P,A>::equal_range(const key_type& k)
1077 return table_.equal_range(k);
1080 template <class K, class T, class H, class P, class A>
1082 typename unordered_map<K,T,H,P,A>::const_iterator,
1083 typename unordered_map<K,T,H,P,A>::const_iterator>
1084 unordered_map<K,T,H,P,A>::equal_range(const key_type& k) const
1086 return table_.equal_range(k);
1089 template <class K, class T, class H, class P, class A>
1090 typename unordered_map<K,T,H,P,A>::size_type
1091 unordered_map<K,T,H,P,A>::bucket_size(size_type n) const
1093 return table_.bucket_size(n);
1098 template <class K, class T, class H, class P, class A>
1099 float unordered_map<K,T,H,P,A>::load_factor() const
1101 return table_.load_factor();
1104 template <class K, class T, class H, class P, class A>
1105 void unordered_map<K,T,H,P,A>::max_load_factor(float m)
1107 table_.max_load_factor(m);
1110 template <class K, class T, class H, class P, class A>
1111 void unordered_map<K,T,H,P,A>::rehash(size_type n)
1116 template <class K, class T, class H, class P, class A>
1117 inline bool operator==(
1118 unordered_map<K,T,H,P,A> const& m1,
1119 unordered_map<K,T,H,P,A> const& m2)
1121 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1122 struct dummy { unordered_map<K,T,H,P,A> x; };
1124 return m1.table_.equals(m2.table_);
1127 template <class K, class T, class H, class P, class A>
1128 inline bool operator!=(
1129 unordered_map<K,T,H,P,A> const& m1,
1130 unordered_map<K,T,H,P,A> const& m2)
1132 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1133 struct dummy { unordered_map<K,T,H,P,A> x; };
1135 return !m1.table_.equals(m2.table_);
1138 template <class K, class T, class H, class P, class A>
1140 unordered_map<K,T,H,P,A> &m1,
1141 unordered_map<K,T,H,P,A> &m2)
1143 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1144 struct dummy { unordered_map<K,T,H,P,A> x; };
1149 ////////////////////////////////////////////////////////////////////////////////
1151 template <class K, class T, class H, class P, class A>
1152 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1153 size_type n, const hasher &hf, const key_equal &eql,
1154 const allocator_type &a)
1155 : table_(n, hf, eql, a)
1159 template <class K, class T, class H, class P, class A>
1160 unordered_multimap<K,T,H,P,A>::unordered_multimap(allocator_type const& a)
1161 : table_(boost::unordered::detail::default_bucket_count,
1162 hasher(), key_equal(), a)
1166 template <class K, class T, class H, class P, class A>
1167 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1168 unordered_multimap const& other, allocator_type const& a)
1169 : table_(other.table_, a)
1173 template <class K, class T, class H, class P, class A>
1174 template <class InputIt>
1175 unordered_multimap<K,T,H,P,A>::unordered_multimap(InputIt f, InputIt l)
1176 : table_(boost::unordered::detail::initial_size(f, l),
1177 hasher(), key_equal(), allocator_type())
1179 table_.insert_range(f, l);
1182 template <class K, class T, class H, class P, class A>
1183 template <class InputIt>
1184 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1185 InputIt f, InputIt l,
1188 const key_equal &eql)
1189 : table_(boost::unordered::detail::initial_size(f, l, n),
1190 hf, eql, allocator_type())
1192 table_.insert_range(f, l);
1195 template <class K, class T, class H, class P, class A>
1196 template <class InputIt>
1197 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1198 InputIt f, InputIt l,
1201 const key_equal &eql,
1202 const allocator_type &a)
1203 : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
1205 table_.insert_range(f, l);
1208 template <class K, class T, class H, class P, class A>
1209 unordered_multimap<K,T,H,P,A>::~unordered_multimap() {}
1211 template <class K, class T, class H, class P, class A>
1212 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1213 unordered_multimap const& other)
1214 : table_(other.table_)
1218 #if !defined(BOOST_NO_RVALUE_REFERENCES)
1220 template <class K, class T, class H, class P, class A>
1221 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1222 unordered_multimap&& other, allocator_type const& a)
1223 : table_(other.table_, a, boost::unordered::detail::move_tag())
1229 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
1231 template <class K, class T, class H, class P, class A>
1232 unordered_multimap<K,T,H,P,A>::unordered_multimap(
1233 std::initializer_list<value_type> list, size_type n,
1234 const hasher &hf, const key_equal &eql, const allocator_type &a)
1236 boost::unordered::detail::initial_size(
1237 list.begin(), list.end(), n),
1240 table_.insert_range(list.begin(), list.end());
1243 template <class K, class T, class H, class P, class A>
1244 unordered_multimap<K,T,H,P,A>& unordered_multimap<K,T,H,P,A>::operator=(
1245 std::initializer_list<value_type> list)
1248 table_.insert_range(list.begin(), list.end());
1254 // size and capacity
1256 template <class K, class T, class H, class P, class A>
1257 std::size_t unordered_multimap<K,T,H,P,A>::max_size() const
1259 return table_.max_size();
1264 template <class K, class T, class H, class P, class A>
1265 template <class InputIt>
1266 void unordered_multimap<K,T,H,P,A>::insert(InputIt first, InputIt last)
1268 table_.insert_range(first, last);
1271 #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
1272 template <class K, class T, class H, class P, class A>
1273 void unordered_multimap<K,T,H,P,A>::insert(
1274 std::initializer_list<value_type> list)
1276 table_.insert_range(list.begin(), list.end());
1280 template <class K, class T, class H, class P, class A>
1281 typename unordered_multimap<K,T,H,P,A>::iterator
1282 unordered_multimap<K,T,H,P,A>::erase(const_iterator position)
1284 return iterator(table_.erase(position.node_));
1287 template <class K, class T, class H, class P, class A>
1288 typename unordered_multimap<K,T,H,P,A>::size_type
1289 unordered_multimap<K,T,H,P,A>::erase(const key_type& k)
1291 return table_.erase_key(k);
1294 template <class K, class T, class H, class P, class A>
1295 typename unordered_multimap<K,T,H,P,A>::iterator
1296 unordered_multimap<K,T,H,P,A>::erase(
1297 const_iterator first, const_iterator last)
1299 return iterator(table_.erase_range(first.node_, last.node_));
1302 template <class K, class T, class H, class P, class A>
1303 void unordered_multimap<K,T,H,P,A>::clear()
1308 template <class K, class T, class H, class P, class A>
1309 void unordered_multimap<K,T,H,P,A>::swap(unordered_multimap& other)
1311 table_.swap(other.table_);
1316 template <class K, class T, class H, class P, class A>
1317 typename unordered_multimap<K,T,H,P,A>::hasher
1318 unordered_multimap<K,T,H,P,A>::hash_function() const
1320 return table_.hash_function();
1323 template <class K, class T, class H, class P, class A>
1324 typename unordered_multimap<K,T,H,P,A>::key_equal
1325 unordered_multimap<K,T,H,P,A>::key_eq() const
1327 return table_.key_eq();
1332 template <class K, class T, class H, class P, class A>
1333 typename unordered_multimap<K,T,H,P,A>::iterator
1334 unordered_multimap<K,T,H,P,A>::find(const key_type& k)
1336 return iterator(table_.find_node(k));
1339 template <class K, class T, class H, class P, class A>
1340 typename unordered_multimap<K,T,H,P,A>::const_iterator
1341 unordered_multimap<K,T,H,P,A>::find(const key_type& k) const
1343 return const_iterator(table_.find_node(k));
1346 template <class K, class T, class H, class P, class A>
1347 template <class CompatibleKey, class CompatibleHash,
1348 class CompatiblePredicate>
1349 typename unordered_multimap<K,T,H,P,A>::iterator
1350 unordered_multimap<K,T,H,P,A>::find(
1351 CompatibleKey const& k,
1352 CompatibleHash const& hash,
1353 CompatiblePredicate const& eq)
1355 return iterator(table_.generic_find_node(k, hash, eq));
1358 template <class K, class T, class H, class P, class A>
1359 template <class CompatibleKey, class CompatibleHash,
1360 class CompatiblePredicate>
1361 typename unordered_multimap<K,T,H,P,A>::const_iterator
1362 unordered_multimap<K,T,H,P,A>::find(
1363 CompatibleKey const& k,
1364 CompatibleHash const& hash,
1365 CompatiblePredicate const& eq) const
1367 return const_iterator(table_.generic_find_node(k, hash, eq));
1370 template <class K, class T, class H, class P, class A>
1371 typename unordered_multimap<K,T,H,P,A>::size_type
1372 unordered_multimap<K,T,H,P,A>::count(const key_type& k) const
1374 return table_.count(k);
1377 template <class K, class T, class H, class P, class A>
1379 typename unordered_multimap<K,T,H,P,A>::iterator,
1380 typename unordered_multimap<K,T,H,P,A>::iterator>
1381 unordered_multimap<K,T,H,P,A>::equal_range(const key_type& k)
1383 return table_.equal_range(k);
1386 template <class K, class T, class H, class P, class A>
1388 typename unordered_multimap<K,T,H,P,A>::const_iterator,
1389 typename unordered_multimap<K,T,H,P,A>::const_iterator>
1390 unordered_multimap<K,T,H,P,A>::equal_range(const key_type& k) const
1392 return table_.equal_range(k);
1395 template <class K, class T, class H, class P, class A>
1396 typename unordered_multimap<K,T,H,P,A>::size_type
1397 unordered_multimap<K,T,H,P,A>::bucket_size(size_type n) const
1399 return table_.bucket_size(n);
1404 template <class K, class T, class H, class P, class A>
1405 float unordered_multimap<K,T,H,P,A>::load_factor() const
1407 return table_.load_factor();
1410 template <class K, class T, class H, class P, class A>
1411 void unordered_multimap<K,T,H,P,A>::max_load_factor(float m)
1413 table_.max_load_factor(m);
1416 template <class K, class T, class H, class P, class A>
1417 void unordered_multimap<K,T,H,P,A>::rehash(size_type n)
1422 template <class K, class T, class H, class P, class A>
1423 inline bool operator==(
1424 unordered_multimap<K,T,H,P,A> const& m1,
1425 unordered_multimap<K,T,H,P,A> const& m2)
1427 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1428 struct dummy { unordered_multimap<K,T,H,P,A> x; };
1430 return m1.table_.equals(m2.table_);
1433 template <class K, class T, class H, class P, class A>
1434 inline bool operator!=(
1435 unordered_multimap<K,T,H,P,A> const& m1,
1436 unordered_multimap<K,T,H,P,A> const& m2)
1438 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1439 struct dummy { unordered_multimap<K,T,H,P,A> x; };
1441 return !m1.table_.equals(m2.table_);
1444 template <class K, class T, class H, class P, class A>
1446 unordered_multimap<K,T,H,P,A> &m1,
1447 unordered_multimap<K,T,H,P,A> &m2)
1449 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
1450 struct dummy { unordered_multimap<K,T,H,P,A> x; };
1455 } // namespace unordered
1456 } // namespace boost
1458 #if defined(BOOST_MSVC)
1459 #pragma warning(pop)
1462 #endif // BOOST_UNORDERED_UNORDERED_MAP_HPP_INCLUDED