1     // unordered_map standard header
2 #pragma once
3 #ifndef _UNORDERED_MAP_
4 #define _UNORDERED_MAP_
5 #ifndef RC_INVOKED
6 #include <xhash>
7
8  #pragma pack(push,_CRT_PACKING)
9  #pragma warning(push,3)
10
11 _STD_BEGIN
12     namespace tr1 {    // TR1 additions
13
14         // TEMPLATE CLASS _Umap_traits
15 template<class _Kty,    // key type
16     class _Ty,    // mapped type
17     class _Tr,    // comparator predicate type
18     class _Alloc,    // actual allocator type (should be value allocator)
19     bool _Mfl>    // true if multiple equivalent keys are permitted
20     class _Umap_traits
21         : public _Container_base
22     {    // traits required to make _Hash behave like a map
23 public:
24     typedef _Kty key_type;
25     typedef pair<const _Kty, _Ty> value_type;
26     typedef _Tr key_compare;
27
28     typedef typename _Alloc::template rebind<value_type>::other
29         allocator_type;
30
31     typedef typename allocator_type::pointer _ITptr;
32     typedef typename allocator_type::reference _IReft;
33
34     enum
35         {    // make multi parameter visible as an enum constant
36         _Multi = _Mfl};
37
38     _Umap_traits()
39         : comp()
40         {    // construct with default comparator
41         }
42
43     _Umap_traits(const _Tr& _Traits)
44         : comp(_Traits)
45         {    // construct with specified comparator
46         }
47
48     class value_compare
49         : public binary_function<value_type, value_type, bool>
50         {    // functor for comparing two element values
51         friend class _Umap_traits<_Kty, _Ty, _Tr, _Alloc, _Mfl>;
52
53     public:
54         bool operator()(const value_type& _Left,
55             const value_type& _Right) const
Lines 56 ... 322 are skipped.
323             _Mybase::insert(*_First);
324         }
325
326     template<class _Iter>
327         unordered_multimap(_Iter _First, _Iter _Last,
328             size_type _Buckets, const hasher& _Hasharg,
329             const _Keyeq& _Keyeqarg)
330         : _Mybase(key_compare(_Hasharg, _Keyeqarg), allocator_type())
331         {    // construct map from sequence, comparator, and allocator
332         this->rehash(_Buckets);
333         for (; _First != _Last; ++_First)
334             _Mybase::insert(*_First);
335         }
336
337     template<class _Iter>
338         unordered_multimap(_Iter _First, _Iter _Last,
339             size_type _Buckets, const hasher& _Hasharg,
340             const _Keyeq& _Keyeqarg, const allocator_type _Al)
341         : _Mybase(key_compare(_Hasharg, _Keyeqarg), _Al)
342         {    // construct map from sequence, comparator, and allocator
343         this->rehash(_Buckets);
344         for (; _First != _Last; ++_First)
345             _Mybase::insert(*_First);
346         }
347
348     hasher hash_function() const
349         {    // return hasher object
350         return (this->comp._Hashobj);
351         }
352
353     key_equal key_eq() const
354         {    // return equality comparator object
355         return (this->comp._Keyeqobj);
356         }
357
358     iterator insert(const value_type& _Val)
359         {    // insert a {key, mapped} value
360         return (_Mybase::insert(_Val).first);
361         }
362
363     iterator insert(const_iterator _Where, const value_type& _Val)
364         {    // insert a {key, mapped} value, with hint
365         return (_Mybase::insert(_Where, _Val));
366         }
367
368     template<class _Iter>
369         void insert(_Iter _First, _Iter _Last)
370         {    // insert [_First, _Last), arbitrary iterators
371
372  #if _HAS_ITERATOR_DEBUGGING
373         _DEBUG_RANGE(_First, _Last);
374  #endif /* _HAS_ITERATOR_DEBUGGING */
375
376         _Mybase::insert(_First, _Last);
377         }
378     };
379
380 template<class _Kty,
381     class _Ty,
382     class _Hasher,
383     class _Keyeq,
384     class _Alloc>
385     void swap(unordered_multimap<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>& _Left,
386         unordered_multimap<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>& _Right)
387     {    // swap _Left and _Right unordered_multimaps
388     _Left.swap(_Right);
389     }
390
391     }    // namespace tr1
392
393     // unordered_map implements a performant swap
394 template<class _Kty,
395     class _Ty,
396     class _Hasher,
397     class _Keyeq,
398     class _Alloc>
399     class _Move_operation_category<tr1::unordered_map<_Kty, _Ty, _Hasher,
400         _Keyeq, _Alloc> >
401     {
402 public:
403     typedef _Swap_move_tag _Move_cat;
404     };
405
406     // unordered_multimap implements a performant swap
407 template<class _Kty,
408     class _Ty,
409     class _Hasher,
410     class _Keyeq,
411     class _Alloc>
412     class _Move_operation_category<tr1::unordered_multimap<_Kty, _Ty, _Hasher,
413         _Keyeq, _Alloc> >
414     {
415 public:
416     typedef _Swap_move_tag _Move_cat;
417     };
418 _STD_END
419  #pragma warning(pop)
420  #pragma pack(pop)
421
422 #endif /* RC_INVOKED */
423 #endif /* _UNORDERED_MAP_ */
424
425 /*
426  * Copyright (c) 1992-2008 by P.J. Plauger.  ALL RIGHTS RESERVED.
427  * Consult your license regarding permissions and restrictions.
428 V5.05:0009 */
429