xref: /dflybsd-src/contrib/gcc-4.7/libstdc++-v3/include/bits/unordered_map.h (revision e4b17023d31ea40e02fa06b141db27753ecc6934)
1*e4b17023SJohn Marino // unordered_map implementation -*- C++ -*-
2*e4b17023SJohn Marino 
3*e4b17023SJohn Marino // Copyright (C) 2010, 2011 Free Software Foundation, Inc.
4*e4b17023SJohn Marino //
5*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library.  This library is free
6*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the
7*e4b17023SJohn Marino // terms of the GNU General Public License as published by the
8*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option)
9*e4b17023SJohn Marino // any later version.
10*e4b17023SJohn Marino 
11*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful,
12*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*e4b17023SJohn Marino // GNU General Public License for more details.
15*e4b17023SJohn Marino 
16*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional
17*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version
18*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation.
19*e4b17023SJohn Marino 
20*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and
21*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program;
22*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>.
24*e4b17023SJohn Marino 
25*e4b17023SJohn Marino /** @file bits/unordered_map.h
26*e4b17023SJohn Marino  *  This is an internal header file, included by other library headers.
27*e4b17023SJohn Marino  *  Do not attempt to use it directly. @headername{unordered_map}
28*e4b17023SJohn Marino  */
29*e4b17023SJohn Marino 
30*e4b17023SJohn Marino #ifndef _UNORDERED_MAP_H
31*e4b17023SJohn Marino #define _UNORDERED_MAP_H
32*e4b17023SJohn Marino 
33*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
34*e4b17023SJohn Marino {
35*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
36*e4b17023SJohn Marino 
37*e4b17023SJohn Marino   // NB: When we get typedef templates these class definitions
38*e4b17023SJohn Marino   // will be unnecessary.
39*e4b17023SJohn Marino   template<class _Key, class _Tp,
40*e4b17023SJohn Marino 	   class _Hash = hash<_Key>,
41*e4b17023SJohn Marino 	   class _Pred = std::equal_to<_Key>,
42*e4b17023SJohn Marino 	   class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
43*e4b17023SJohn Marino 	   bool __cache_hash_code =
44*e4b17023SJohn Marino 	     __not_<__and_<is_integral<_Key>, is_empty<_Hash>,
45*e4b17023SJohn Marino 			   integral_constant<bool, !__is_final(_Hash)>,
46*e4b17023SJohn Marino 			   __detail::__is_noexcept_hash<_Key, _Hash>>>::value>
47*e4b17023SJohn Marino     class __unordered_map
48*e4b17023SJohn Marino     : public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
49*e4b17023SJohn Marino 			std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
50*e4b17023SJohn Marino 			_Hash, __detail::_Mod_range_hashing,
51*e4b17023SJohn Marino 			__detail::_Default_ranged_hash,
52*e4b17023SJohn Marino 			__detail::_Prime_rehash_policy,
53*e4b17023SJohn Marino 			__cache_hash_code, false, true>
54*e4b17023SJohn Marino     {
55*e4b17023SJohn Marino       typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
56*e4b17023SJohn Marino 			 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
57*e4b17023SJohn Marino 			 _Hash, __detail::_Mod_range_hashing,
58*e4b17023SJohn Marino 			 __detail::_Default_ranged_hash,
59*e4b17023SJohn Marino 			 __detail::_Prime_rehash_policy,
60*e4b17023SJohn Marino 			 __cache_hash_code, false, true>
61*e4b17023SJohn Marino         _Base;
62*e4b17023SJohn Marino 
63*e4b17023SJohn Marino     public:
64*e4b17023SJohn Marino       typedef typename _Base::value_type      value_type;
65*e4b17023SJohn Marino       typedef typename _Base::size_type       size_type;
66*e4b17023SJohn Marino       typedef typename _Base::hasher          hasher;
67*e4b17023SJohn Marino       typedef typename _Base::key_equal       key_equal;
68*e4b17023SJohn Marino       typedef typename _Base::allocator_type  allocator_type;
69*e4b17023SJohn Marino 
70*e4b17023SJohn Marino       explicit
71*e4b17023SJohn Marino       __unordered_map(size_type __n = 10,
72*e4b17023SJohn Marino 		      const hasher& __hf = hasher(),
73*e4b17023SJohn Marino 		      const key_equal& __eql = key_equal(),
74*e4b17023SJohn Marino 		      const allocator_type& __a = allocator_type())
75*e4b17023SJohn Marino       : _Base(__n, __hf, __detail::_Mod_range_hashing(),
76*e4b17023SJohn Marino 	      __detail::_Default_ranged_hash(),
77*e4b17023SJohn Marino 	      __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
78*e4b17023SJohn Marino       { }
79*e4b17023SJohn Marino 
80*e4b17023SJohn Marino       template<typename _InputIterator>
81*e4b17023SJohn Marino         __unordered_map(_InputIterator __f, _InputIterator __l,
82*e4b17023SJohn Marino 			size_type __n = 0,
83*e4b17023SJohn Marino 			const hasher& __hf = hasher(),
84*e4b17023SJohn Marino 			const key_equal& __eql = key_equal(),
85*e4b17023SJohn Marino 			const allocator_type& __a = allocator_type())
86*e4b17023SJohn Marino 	: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
87*e4b17023SJohn Marino 		__detail::_Default_ranged_hash(),
88*e4b17023SJohn Marino 		__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
89*e4b17023SJohn Marino 	{ }
90*e4b17023SJohn Marino 
91*e4b17023SJohn Marino       __unordered_map(initializer_list<value_type> __l,
92*e4b17023SJohn Marino 		      size_type __n = 0,
93*e4b17023SJohn Marino 		      const hasher& __hf = hasher(),
94*e4b17023SJohn Marino 		      const key_equal& __eql = key_equal(),
95*e4b17023SJohn Marino 		      const allocator_type& __a = allocator_type())
96*e4b17023SJohn Marino       : _Base(__l.begin(), __l.end(), __n, __hf,
97*e4b17023SJohn Marino 	      __detail::_Mod_range_hashing(),
98*e4b17023SJohn Marino 	      __detail::_Default_ranged_hash(),
99*e4b17023SJohn Marino 	      __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
100*e4b17023SJohn Marino       { }
101*e4b17023SJohn Marino 
102*e4b17023SJohn Marino       __unordered_map&
103*e4b17023SJohn Marino       operator=(initializer_list<value_type> __l)
104*e4b17023SJohn Marino       {
105*e4b17023SJohn Marino 	this->clear();
106*e4b17023SJohn Marino 	this->insert(__l.begin(), __l.end());
107*e4b17023SJohn Marino 	return *this;
108*e4b17023SJohn Marino       }
109*e4b17023SJohn Marino     };
110*e4b17023SJohn Marino 
111*e4b17023SJohn Marino   template<class _Key, class _Tp,
112*e4b17023SJohn Marino 	   class _Hash = hash<_Key>,
113*e4b17023SJohn Marino 	   class _Pred = std::equal_to<_Key>,
114*e4b17023SJohn Marino 	   class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
115*e4b17023SJohn Marino 	   bool __cache_hash_code =
116*e4b17023SJohn Marino 	     __not_<__and_<is_integral<_Key>, is_empty<_Hash>,
117*e4b17023SJohn Marino 			   integral_constant<bool, !__is_final(_Hash)>,
118*e4b17023SJohn Marino 			   __detail::__is_noexcept_hash<_Key, _Hash>>>::value>
119*e4b17023SJohn Marino     class __unordered_multimap
120*e4b17023SJohn Marino     : public _Hashtable<_Key, std::pair<const _Key, _Tp>,
121*e4b17023SJohn Marino 			_Alloc,
122*e4b17023SJohn Marino 			std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
123*e4b17023SJohn Marino 			_Hash, __detail::_Mod_range_hashing,
124*e4b17023SJohn Marino 			__detail::_Default_ranged_hash,
125*e4b17023SJohn Marino 			__detail::_Prime_rehash_policy,
126*e4b17023SJohn Marino 			__cache_hash_code, false, false>
127*e4b17023SJohn Marino     {
128*e4b17023SJohn Marino       typedef _Hashtable<_Key, std::pair<const _Key, _Tp>,
129*e4b17023SJohn Marino 			 _Alloc,
130*e4b17023SJohn Marino 			 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
131*e4b17023SJohn Marino 			 _Hash, __detail::_Mod_range_hashing,
132*e4b17023SJohn Marino 			 __detail::_Default_ranged_hash,
133*e4b17023SJohn Marino 			 __detail::_Prime_rehash_policy,
134*e4b17023SJohn Marino 			 __cache_hash_code, false, false>
135*e4b17023SJohn Marino         _Base;
136*e4b17023SJohn Marino 
137*e4b17023SJohn Marino     public:
138*e4b17023SJohn Marino       typedef typename _Base::value_type      value_type;
139*e4b17023SJohn Marino       typedef typename _Base::size_type       size_type;
140*e4b17023SJohn Marino       typedef typename _Base::hasher          hasher;
141*e4b17023SJohn Marino       typedef typename _Base::key_equal       key_equal;
142*e4b17023SJohn Marino       typedef typename _Base::allocator_type  allocator_type;
143*e4b17023SJohn Marino 
144*e4b17023SJohn Marino       explicit
145*e4b17023SJohn Marino       __unordered_multimap(size_type __n = 10,
146*e4b17023SJohn Marino 			   const hasher& __hf = hasher(),
147*e4b17023SJohn Marino 			   const key_equal& __eql = key_equal(),
148*e4b17023SJohn Marino 			   const allocator_type& __a = allocator_type())
149*e4b17023SJohn Marino       : _Base(__n, __hf, __detail::_Mod_range_hashing(),
150*e4b17023SJohn Marino 	      __detail::_Default_ranged_hash(),
151*e4b17023SJohn Marino 	      __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
152*e4b17023SJohn Marino       { }
153*e4b17023SJohn Marino 
154*e4b17023SJohn Marino 
155*e4b17023SJohn Marino       template<typename _InputIterator>
156*e4b17023SJohn Marino         __unordered_multimap(_InputIterator __f, _InputIterator __l,
157*e4b17023SJohn Marino 			     size_type __n = 0,
158*e4b17023SJohn Marino 			     const hasher& __hf = hasher(),
159*e4b17023SJohn Marino 			     const key_equal& __eql = key_equal(),
160*e4b17023SJohn Marino 			     const allocator_type& __a = allocator_type())
161*e4b17023SJohn Marino 	: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
162*e4b17023SJohn Marino 		__detail::_Default_ranged_hash(),
163*e4b17023SJohn Marino 		__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
164*e4b17023SJohn Marino         { }
165*e4b17023SJohn Marino 
166*e4b17023SJohn Marino       __unordered_multimap(initializer_list<value_type> __l,
167*e4b17023SJohn Marino 			   size_type __n = 0,
168*e4b17023SJohn Marino 			   const hasher& __hf = hasher(),
169*e4b17023SJohn Marino 			   const key_equal& __eql = key_equal(),
170*e4b17023SJohn Marino 			   const allocator_type& __a = allocator_type())
171*e4b17023SJohn Marino       : _Base(__l.begin(), __l.end(), __n, __hf,
172*e4b17023SJohn Marino 	      __detail::_Mod_range_hashing(),
173*e4b17023SJohn Marino 	      __detail::_Default_ranged_hash(),
174*e4b17023SJohn Marino 	      __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
175*e4b17023SJohn Marino       { }
176*e4b17023SJohn Marino 
177*e4b17023SJohn Marino       __unordered_multimap&
178*e4b17023SJohn Marino       operator=(initializer_list<value_type> __l)
179*e4b17023SJohn Marino       {
180*e4b17023SJohn Marino 	this->clear();
181*e4b17023SJohn Marino 	this->insert(__l.begin(), __l.end());
182*e4b17023SJohn Marino 	return *this;
183*e4b17023SJohn Marino       }
184*e4b17023SJohn Marino     };
185*e4b17023SJohn Marino 
186*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
187*e4b17023SJohn Marino 	   bool __cache_hash_code>
188*e4b17023SJohn Marino     inline void
189*e4b17023SJohn Marino     swap(__unordered_map<_Key, _Tp, _Hash, _Pred,
190*e4b17023SJohn Marino 	 _Alloc, __cache_hash_code>& __x,
191*e4b17023SJohn Marino 	 __unordered_map<_Key, _Tp, _Hash, _Pred,
192*e4b17023SJohn Marino 	 _Alloc, __cache_hash_code>& __y)
193*e4b17023SJohn Marino     { __x.swap(__y); }
194*e4b17023SJohn Marino 
195*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
196*e4b17023SJohn Marino 	   bool __cache_hash_code>
197*e4b17023SJohn Marino     inline void
198*e4b17023SJohn Marino     swap(__unordered_multimap<_Key, _Tp, _Hash, _Pred,
199*e4b17023SJohn Marino 	 _Alloc, __cache_hash_code>& __x,
200*e4b17023SJohn Marino 	 __unordered_multimap<_Key, _Tp, _Hash, _Pred,
201*e4b17023SJohn Marino 	 _Alloc, __cache_hash_code>& __y)
202*e4b17023SJohn Marino     { __x.swap(__y); }
203*e4b17023SJohn Marino 
204*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
205*e4b17023SJohn Marino 	   bool __cache_hash_code>
206*e4b17023SJohn Marino     inline bool
207*e4b17023SJohn Marino     operator==(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
208*e4b17023SJohn Marino 	       __cache_hash_code>& __x,
209*e4b17023SJohn Marino 	       const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
210*e4b17023SJohn Marino 	       __cache_hash_code>& __y)
211*e4b17023SJohn Marino     { return __x._M_equal(__y); }
212*e4b17023SJohn Marino 
213*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
214*e4b17023SJohn Marino 	   bool __cache_hash_code>
215*e4b17023SJohn Marino     inline bool
216*e4b17023SJohn Marino     operator!=(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
217*e4b17023SJohn Marino 	       __cache_hash_code>& __x,
218*e4b17023SJohn Marino 	       const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
219*e4b17023SJohn Marino 	       __cache_hash_code>& __y)
220*e4b17023SJohn Marino     { return !(__x == __y); }
221*e4b17023SJohn Marino 
222*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
223*e4b17023SJohn Marino 	   bool __cache_hash_code>
224*e4b17023SJohn Marino     inline bool
225*e4b17023SJohn Marino     operator==(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
226*e4b17023SJohn Marino 	       __cache_hash_code>& __x,
227*e4b17023SJohn Marino 	       const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
228*e4b17023SJohn Marino 	       __cache_hash_code>& __y)
229*e4b17023SJohn Marino     { return __x._M_equal(__y); }
230*e4b17023SJohn Marino 
231*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
232*e4b17023SJohn Marino 	   bool __cache_hash_code>
233*e4b17023SJohn Marino     inline bool
234*e4b17023SJohn Marino     operator!=(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
235*e4b17023SJohn Marino 	       __cache_hash_code>& __x,
236*e4b17023SJohn Marino 	       const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
237*e4b17023SJohn Marino 	       __cache_hash_code>& __y)
238*e4b17023SJohn Marino     { return !(__x == __y); }
239*e4b17023SJohn Marino 
240*e4b17023SJohn Marino   /**
241*e4b17023SJohn Marino    *  @brief A standard container composed of unique keys (containing
242*e4b17023SJohn Marino    *  at most one of each key value) that associates values of another type
243*e4b17023SJohn Marino    *  with the keys.
244*e4b17023SJohn Marino    *
245*e4b17023SJohn Marino    *  @ingroup unordered_associative_containers
246*e4b17023SJohn Marino    *
247*e4b17023SJohn Marino    *  Meets the requirements of a <a href="tables.html#65">container</a>, and
248*e4b17023SJohn Marino    *  <a href="tables.html#xx">unordered associative container</a>
249*e4b17023SJohn Marino    *
250*e4b17023SJohn Marino    *  @param  Key  Type of key objects.
251*e4b17023SJohn Marino    *  @param  Tp  Type of mapped objects.
252*e4b17023SJohn Marino    *  @param  Hash  Hashing function object type, defaults to hash<Value>.
253*e4b17023SJohn Marino    *  @param  Pred  Predicate function object type, defaults to equal_to<Value>.
254*e4b17023SJohn Marino    *  @param  Alloc  Allocator type, defaults to allocator<Key>.
255*e4b17023SJohn Marino    *
256*e4b17023SJohn Marino    * The resulting value type of the container is std::pair<const Key, Tp>.
257*e4b17023SJohn Marino    */
258*e4b17023SJohn Marino   template<class _Key, class _Tp,
259*e4b17023SJohn Marino 	   class _Hash = hash<_Key>,
260*e4b17023SJohn Marino 	   class _Pred = std::equal_to<_Key>,
261*e4b17023SJohn Marino 	   class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
262*e4b17023SJohn Marino     class unordered_map
263*e4b17023SJohn Marino     : public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
264*e4b17023SJohn Marino     {
265*e4b17023SJohn Marino       typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>  _Base;
266*e4b17023SJohn Marino 
267*e4b17023SJohn Marino     public:
268*e4b17023SJohn Marino       typedef typename _Base::value_type      value_type;
269*e4b17023SJohn Marino       typedef typename _Base::size_type       size_type;
270*e4b17023SJohn Marino       typedef typename _Base::hasher          hasher;
271*e4b17023SJohn Marino       typedef typename _Base::key_equal       key_equal;
272*e4b17023SJohn Marino       typedef typename _Base::allocator_type  allocator_type;
273*e4b17023SJohn Marino 
274*e4b17023SJohn Marino       explicit
275*e4b17023SJohn Marino       unordered_map(size_type __n = 10,
276*e4b17023SJohn Marino 		    const hasher& __hf = hasher(),
277*e4b17023SJohn Marino 		    const key_equal& __eql = key_equal(),
278*e4b17023SJohn Marino 		    const allocator_type& __a = allocator_type())
279*e4b17023SJohn Marino       : _Base(__n, __hf, __eql, __a)
280*e4b17023SJohn Marino       { }
281*e4b17023SJohn Marino 
282*e4b17023SJohn Marino       template<typename _InputIterator>
283*e4b17023SJohn Marino         unordered_map(_InputIterator __f, _InputIterator __l,
284*e4b17023SJohn Marino 		      size_type __n = 0,
285*e4b17023SJohn Marino 		      const hasher& __hf = hasher(),
286*e4b17023SJohn Marino 		      const key_equal& __eql = key_equal(),
287*e4b17023SJohn Marino 		      const allocator_type& __a = allocator_type())
288*e4b17023SJohn Marino 	: _Base(__f, __l, __n, __hf, __eql, __a)
289*e4b17023SJohn Marino         { }
290*e4b17023SJohn Marino 
291*e4b17023SJohn Marino       unordered_map(initializer_list<value_type> __l,
292*e4b17023SJohn Marino 		    size_type __n = 0,
293*e4b17023SJohn Marino 		    const hasher& __hf = hasher(),
294*e4b17023SJohn Marino 		    const key_equal& __eql = key_equal(),
295*e4b17023SJohn Marino 		    const allocator_type& __a = allocator_type())
296*e4b17023SJohn Marino       : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
297*e4b17023SJohn Marino       { }
298*e4b17023SJohn Marino 
299*e4b17023SJohn Marino       unordered_map&
300*e4b17023SJohn Marino       operator=(initializer_list<value_type> __l)
301*e4b17023SJohn Marino       {
302*e4b17023SJohn Marino 	this->clear();
303*e4b17023SJohn Marino 	this->insert(__l.begin(), __l.end());
304*e4b17023SJohn Marino 	return *this;
305*e4b17023SJohn Marino       }
306*e4b17023SJohn Marino     };
307*e4b17023SJohn Marino 
308*e4b17023SJohn Marino   /**
309*e4b17023SJohn Marino    *  @brief A standard container composed of equivalent keys
310*e4b17023SJohn Marino    *  (possibly containing multiple of each key value) that associates
311*e4b17023SJohn Marino    *  values of another type with the keys.
312*e4b17023SJohn Marino    *
313*e4b17023SJohn Marino    *  @ingroup unordered_associative_containers
314*e4b17023SJohn Marino    *
315*e4b17023SJohn Marino    *  Meets the requirements of a <a href="tables.html#65">container</a>, and
316*e4b17023SJohn Marino    *  <a href="tables.html#xx">unordered associative container</a>
317*e4b17023SJohn Marino    *
318*e4b17023SJohn Marino    *  @param  Key  Type of key objects.
319*e4b17023SJohn Marino    *  @param  Tp  Type of mapped objects.
320*e4b17023SJohn Marino    *  @param  Hash  Hashing function object type, defaults to hash<Value>.
321*e4b17023SJohn Marino    *  @param  Pred  Predicate function object type, defaults to equal_to<Value>.
322*e4b17023SJohn Marino    *  @param  Alloc  Allocator type, defaults to allocator<Key>.
323*e4b17023SJohn Marino    *
324*e4b17023SJohn Marino    * The resulting value type of the container is std::pair<const Key, Tp>.
325*e4b17023SJohn Marino    */
326*e4b17023SJohn Marino   template<class _Key, class _Tp,
327*e4b17023SJohn Marino 	   class _Hash = hash<_Key>,
328*e4b17023SJohn Marino 	   class _Pred = std::equal_to<_Key>,
329*e4b17023SJohn Marino 	   class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
330*e4b17023SJohn Marino     class unordered_multimap
331*e4b17023SJohn Marino     : public __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
332*e4b17023SJohn Marino     {
333*e4b17023SJohn Marino       typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>  _Base;
334*e4b17023SJohn Marino 
335*e4b17023SJohn Marino     public:
336*e4b17023SJohn Marino       typedef typename _Base::value_type      value_type;
337*e4b17023SJohn Marino       typedef typename _Base::size_type       size_type;
338*e4b17023SJohn Marino       typedef typename _Base::hasher          hasher;
339*e4b17023SJohn Marino       typedef typename _Base::key_equal       key_equal;
340*e4b17023SJohn Marino       typedef typename _Base::allocator_type  allocator_type;
341*e4b17023SJohn Marino 
342*e4b17023SJohn Marino       explicit
343*e4b17023SJohn Marino       unordered_multimap(size_type __n = 10,
344*e4b17023SJohn Marino 			 const hasher& __hf = hasher(),
345*e4b17023SJohn Marino 			 const key_equal& __eql = key_equal(),
346*e4b17023SJohn Marino 			 const allocator_type& __a = allocator_type())
347*e4b17023SJohn Marino       : _Base(__n, __hf, __eql, __a)
348*e4b17023SJohn Marino       { }
349*e4b17023SJohn Marino 
350*e4b17023SJohn Marino       template<typename _InputIterator>
351*e4b17023SJohn Marino         unordered_multimap(_InputIterator __f, _InputIterator __l,
352*e4b17023SJohn Marino 			   size_type __n = 0,
353*e4b17023SJohn Marino 			   const hasher& __hf = hasher(),
354*e4b17023SJohn Marino 			   const key_equal& __eql = key_equal(),
355*e4b17023SJohn Marino 			   const allocator_type& __a = allocator_type())
356*e4b17023SJohn Marino 	: _Base(__f, __l, __n, __hf, __eql, __a)
357*e4b17023SJohn Marino         { }
358*e4b17023SJohn Marino 
359*e4b17023SJohn Marino       unordered_multimap(initializer_list<value_type> __l,
360*e4b17023SJohn Marino 			 size_type __n = 0,
361*e4b17023SJohn Marino 			 const hasher& __hf = hasher(),
362*e4b17023SJohn Marino 			 const key_equal& __eql = key_equal(),
363*e4b17023SJohn Marino 			 const allocator_type& __a = allocator_type())
364*e4b17023SJohn Marino       : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
365*e4b17023SJohn Marino       { }
366*e4b17023SJohn Marino 
367*e4b17023SJohn Marino       unordered_multimap&
368*e4b17023SJohn Marino       operator=(initializer_list<value_type> __l)
369*e4b17023SJohn Marino       {
370*e4b17023SJohn Marino 	this->clear();
371*e4b17023SJohn Marino 	this->insert(__l.begin(), __l.end());
372*e4b17023SJohn Marino 	return *this;
373*e4b17023SJohn Marino       }
374*e4b17023SJohn Marino     };
375*e4b17023SJohn Marino 
376*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
377*e4b17023SJohn Marino     inline void
378*e4b17023SJohn Marino     swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
379*e4b17023SJohn Marino 	 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
380*e4b17023SJohn Marino     { __x.swap(__y); }
381*e4b17023SJohn Marino 
382*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
383*e4b17023SJohn Marino     inline void
384*e4b17023SJohn Marino     swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
385*e4b17023SJohn Marino 	 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
386*e4b17023SJohn Marino     { __x.swap(__y); }
387*e4b17023SJohn Marino 
388*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
389*e4b17023SJohn Marino     inline bool
390*e4b17023SJohn Marino     operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
391*e4b17023SJohn Marino 	       const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
392*e4b17023SJohn Marino     { return __x._M_equal(__y); }
393*e4b17023SJohn Marino 
394*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
395*e4b17023SJohn Marino     inline bool
396*e4b17023SJohn Marino     operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
397*e4b17023SJohn Marino 	       const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
398*e4b17023SJohn Marino     { return !(__x == __y); }
399*e4b17023SJohn Marino 
400*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
401*e4b17023SJohn Marino     inline bool
402*e4b17023SJohn Marino     operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
403*e4b17023SJohn Marino 	       const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
404*e4b17023SJohn Marino     { return __x._M_equal(__y); }
405*e4b17023SJohn Marino 
406*e4b17023SJohn Marino   template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
407*e4b17023SJohn Marino     inline bool
408*e4b17023SJohn Marino     operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
409*e4b17023SJohn Marino 	       const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
410*e4b17023SJohn Marino     { return !(__x == __y); }
411*e4b17023SJohn Marino 
412*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_CONTAINER
413*e4b17023SJohn Marino } // namespace std
414*e4b17023SJohn Marino 
415*e4b17023SJohn Marino #endif /* _UNORDERED_MAP_H */
416