57 #ifndef _BACKWARD_HASH_MAP
58 #define _BACKWARD_HASH_MAP 1
60 #include "backward_warning.h"
65 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
70 using std::_Select1st;
77 template<class _Key, class _Tp, class _HashFn = hash<_Key>,
78 class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> >
82 typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFn,
83 _Select1st<pair<const _Key, _Tp> >,
84 _EqualKey, _Alloc> _Ht;
89 typedef typename _Ht::key_type key_type;
90 typedef _Tp data_type;
91 typedef _Tp mapped_type;
93 typedef typename _Ht::hasher hasher;
94 typedef typename _Ht::key_equal key_equal;
96 typedef typename _Ht::size_type size_type;
97 typedef typename _Ht::difference_type difference_type;
103 typedef typename _Ht::iterator iterator;
104 typedef typename _Ht::const_iterator const_iterator;
106 typedef typename _Ht::allocator_type allocator_type;
110 {
return _M_ht.hash_funct(); }
114 {
return _M_ht.key_eq(); }
117 get_allocator()
const
118 {
return _M_ht.get_allocator(); }
121 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
124 hash_map(size_type __n)
125 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
127 hash_map(size_type __n,
const hasher& __hf)
128 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
130 hash_map(size_type __n,
const hasher& __hf,
const key_equal& __eql,
131 const allocator_type& __a = allocator_type())
132 : _M_ht(__n, __hf, __eql, __a) {}
134 template<
class _InputIterator>
135 hash_map(_InputIterator __f, _InputIterator __l)
136 : _M_ht(100, hasher(), key_equal(), allocator_type())
137 { _M_ht.insert_unique(__f, __l); }
139 template<
class _InputIterator>
140 hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
141 : _M_ht(__n, hasher(), key_equal(), allocator_type())
142 { _M_ht.insert_unique(__f, __l); }
144 template<
class _InputIterator>
145 hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
147 : _M_ht(__n, __hf, key_equal(), allocator_type())
148 { _M_ht.insert_unique(__f, __l); }
150 template<
class _InputIterator>
151 hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
152 const hasher& __hf,
const key_equal& __eql,
153 const allocator_type& __a = allocator_type())
154 : _M_ht(__n, __hf, __eql, __a)
155 { _M_ht.insert_unique(__f, __l); }
159 {
return _M_ht.size(); }
163 {
return _M_ht.max_size(); }
167 {
return _M_ht.empty(); }
171 { _M_ht.swap(__hs._M_ht); }
173 template<
class _K1,
class _T1,
class _HF,
class _EqK,
class _Al>
180 {
return _M_ht.begin(); }
184 {
return _M_ht.end(); }
188 {
return _M_ht.begin(); }
192 {
return _M_ht.end(); }
195 insert(
const value_type& __obj)
196 {
return _M_ht.insert_unique(__obj); }
198 template<
class _InputIterator>
200 insert(_InputIterator __f, _InputIterator __l)
201 { _M_ht.insert_unique(__f, __l); }
204 insert_noresize(
const value_type& __obj)
205 {
return _M_ht.insert_unique_noresize(__obj); }
208 find(
const key_type& __key)
209 {
return _M_ht.find(__key); }
212 find(
const key_type& __key)
const
213 {
return _M_ht.find(__key); }
216 operator[](
const key_type& __key)
217 {
return _M_ht.find_or_insert(value_type(__key, _Tp())).second; }
220 count(
const key_type& __key)
const
221 {
return _M_ht.count(__key); }
224 equal_range(
const key_type& __key)
225 {
return _M_ht.equal_range(__key); }
228 equal_range(
const key_type& __key)
const
229 {
return _M_ht.equal_range(__key); }
232 erase(
const key_type& __key)
233 {
return _M_ht.erase(__key); }
237 { _M_ht.erase(__it); }
240 erase(iterator __f, iterator __l)
241 { _M_ht.erase(__f, __l); }
248 resize(size_type __hint)
249 { _M_ht.resize(__hint); }
253 {
return _M_ht.bucket_count(); }
256 max_bucket_count()
const
257 {
return _M_ht.max_bucket_count(); }
260 elems_in_bucket(size_type __n)
const
261 {
return _M_ht.elems_in_bucket(__n); }
264 template<
class _Key,
class _Tp,
class _HashFn,
class _EqlKey,
class _Alloc>
268 {
return __hm1._M_ht == __hm2._M_ht; }
270 template<
class _Key,
class _Tp,
class _HashFn,
class _EqlKey,
class _Alloc>
272 operator!=(
const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
273 const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
274 {
return !(__hm1 == __hm2); }
276 template<
class _Key,
class _Tp,
class _HashFn,
class _EqlKey,
class _Alloc>
278 swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
279 hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
280 { __hm1.swap(__hm2); }
288 template<
class _Key,
class _Tp,
289 class _HashFn = hash<_Key>,
290 class _EqualKey = equal_to<_Key>,
291 class _Alloc = allocator<_Tp> >
295 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
296 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
297 __glibcxx_class_requires3(_HashFn,
size_t, _Key, _UnaryFunctionConcept)
298 __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
301 typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFn,
302 _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
308 typedef typename _Ht::key_type key_type;
309 typedef _Tp data_type;
310 typedef _Tp mapped_type;
312 typedef typename _Ht::hasher hasher;
313 typedef typename _Ht::key_equal key_equal;
315 typedef typename _Ht::size_type size_type;
316 typedef typename _Ht::difference_type difference_type;
322 typedef typename _Ht::iterator iterator;
323 typedef typename _Ht::const_iterator const_iterator;
325 typedef typename _Ht::allocator_type allocator_type;
329 {
return _M_ht.hash_funct(); }
333 {
return _M_ht.key_eq(); }
336 get_allocator()
const
337 {
return _M_ht.get_allocator(); }
340 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
344 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
347 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
349 hash_multimap(size_type __n,
const hasher& __hf,
const key_equal& __eql,
350 const allocator_type& __a = allocator_type())
351 : _M_ht(__n, __hf, __eql, __a) {}
353 template<
class _InputIterator>
355 : _M_ht(100, hasher(), key_equal(), allocator_type())
356 { _M_ht.insert_equal(__f, __l); }
358 template<
class _InputIterator>
359 hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
360 : _M_ht(__n, hasher(), key_equal(), allocator_type())
361 { _M_ht.insert_equal(__f, __l); }
363 template<
class _InputIterator>
364 hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
366 : _M_ht(__n, __hf, key_equal(), allocator_type())
367 { _M_ht.insert_equal(__f, __l); }
369 template<
class _InputIterator>
370 hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
371 const hasher& __hf,
const key_equal& __eql,
372 const allocator_type& __a = allocator_type())
373 : _M_ht(__n, __hf, __eql, __a)
374 { _M_ht.insert_equal(__f, __l); }
378 {
return _M_ht.size(); }
382 {
return _M_ht.max_size(); }
386 {
return _M_ht.empty(); }
390 { _M_ht.swap(__hs._M_ht); }
392 template<
class _K1,
class _T1,
class _HF,
class _EqK,
class _Al>
399 {
return _M_ht.begin(); }
403 {
return _M_ht.end(); }
407 {
return _M_ht.begin(); }
411 {
return _M_ht.end(); }
415 {
return _M_ht.insert_equal(__obj); }
417 template<
class _InputIterator>
419 insert(_InputIterator __f, _InputIterator __l)
420 { _M_ht.insert_equal(__f,__l); }
424 {
return _M_ht.insert_equal_noresize(__obj); }
427 find(
const key_type& __key)
428 {
return _M_ht.find(__key); }
431 find(
const key_type& __key)
const
432 {
return _M_ht.find(__key); }
435 count(
const key_type& __key)
const
436 {
return _M_ht.count(__key); }
439 equal_range(
const key_type& __key)
440 {
return _M_ht.equal_range(__key); }
443 equal_range(
const key_type& __key)
const
444 {
return _M_ht.equal_range(__key); }
447 erase(
const key_type& __key)
448 {
return _M_ht.erase(__key); }
452 { _M_ht.erase(__it); }
455 erase(iterator __f, iterator __l)
456 { _M_ht.erase(__f, __l); }
463 resize(size_type __hint)
464 { _M_ht.resize(__hint); }
468 {
return _M_ht.bucket_count(); }
471 max_bucket_count()
const
472 {
return _M_ht.max_bucket_count(); }
475 elems_in_bucket(size_type __n)
const
476 {
return _M_ht.elems_in_bucket(__n); }
479 template<
class _Key,
class _Tp,
class _HF,
class _EqKey,
class _Alloc>
483 {
return __hm1._M_ht == __hm2._M_ht; }
485 template<
class _Key,
class _Tp,
class _HF,
class _EqKey,
class _Alloc>
487 operator!=(
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
488 const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
489 {
return !(__hm1 == __hm2); }
491 template<
class _Key,
class _Tp,
class _HashFn,
class _EqlKey,
class _Alloc>
493 swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
494 hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
495 { __hm1.swap(__hm2); }
497 _GLIBCXX_END_NAMESPACE
499 _GLIBCXX_BEGIN_NAMESPACE(std)
503 template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
504 class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn,
510 _Container* container;
513 typedef _Container container_type;
514 typedef output_iterator_tag iterator_category;
515 typedef void value_type;
516 typedef void difference_type;
517 typedef void pointer;
518 typedef void reference;
520 insert_iterator(_Container& __x)
523 insert_iterator(_Container& __x,
typename _Container::iterator)
526 insert_iterator<_Container>&
527 operator=(
const typename _Container::value_type& __value)
529 container->insert(__value);
533 insert_iterator<_Container>&
537 insert_iterator<_Container>&
538 operator++() {
return *
this; }
540 insert_iterator<_Container>&
545 template<
class _Key,
class _Tp,
class _HashFn,
class _EqKey,
class _Alloc>
546 class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn,
552 _Container* container;
553 typename _Container::iterator iter;
556 typedef _Container container_type;
557 typedef output_iterator_tag iterator_category;
558 typedef void value_type;
559 typedef void difference_type;
560 typedef void pointer;
561 typedef void reference;
563 insert_iterator(_Container& __x)
566 insert_iterator(_Container& __x,
typename _Container::iterator)
569 insert_iterator<_Container>&
570 operator=(
const typename _Container::value_type& __value)
572 container->insert(__value);
576 insert_iterator<_Container>&
580 insert_iterator<_Container>&
584 insert_iterator<_Container>&
589 _GLIBCXX_END_NAMESPACE
pair holds two objects of arbitrary type.