xref: /aosp_15_r20/external/libcxx/include/ext/hash_map (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===-------------------------- hash_map ----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HASH_MAP
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_HASH_MAP
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker
16*58b9f456SAndroid Build Coastguard Worker    hash_map synopsis
17*58b9f456SAndroid Build Coastguard Worker
18*58b9f456SAndroid Build Coastguard Workernamespace __gnu_cxx
19*58b9f456SAndroid Build Coastguard Worker{
20*58b9f456SAndroid Build Coastguard Worker
21*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
22*58b9f456SAndroid Build Coastguard Worker          class Alloc = allocator<pair<const Key, T>>>
23*58b9f456SAndroid Build Coastguard Workerclass hash_map
24*58b9f456SAndroid Build Coastguard Worker{
25*58b9f456SAndroid Build Coastguard Workerpublic:
26*58b9f456SAndroid Build Coastguard Worker    // types
27*58b9f456SAndroid Build Coastguard Worker    typedef Key                                                        key_type;
28*58b9f456SAndroid Build Coastguard Worker    typedef T                                                          mapped_type;
29*58b9f456SAndroid Build Coastguard Worker    typedef Hash                                                       hasher;
30*58b9f456SAndroid Build Coastguard Worker    typedef Pred                                                       key_equal;
31*58b9f456SAndroid Build Coastguard Worker    typedef Alloc                                                      allocator_type;
32*58b9f456SAndroid Build Coastguard Worker    typedef pair<const key_type, mapped_type>                          value_type;
33*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                                reference;
34*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                                          const_reference;
35*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::pointer         pointer;
36*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
37*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::size_type       size_type;
38*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
39*58b9f456SAndroid Build Coastguard Worker
40*58b9f456SAndroid Build Coastguard Worker    typedef /unspecified/ iterator;
41*58b9f456SAndroid Build Coastguard Worker    typedef /unspecified/ const_iterator;
42*58b9f456SAndroid Build Coastguard Worker
43*58b9f456SAndroid Build Coastguard Worker    explicit hash_map(size_type n = 193, const hasher& hf = hasher(),
44*58b9f456SAndroid Build Coastguard Worker                           const key_equal& eql = key_equal(),
45*58b9f456SAndroid Build Coastguard Worker                           const allocator_type& a = allocator_type());
46*58b9f456SAndroid Build Coastguard Worker    template <class InputIterator>
47*58b9f456SAndroid Build Coastguard Worker        hash_map(InputIterator f, InputIterator l,
48*58b9f456SAndroid Build Coastguard Worker                      size_type n = 193, const hasher& hf = hasher(),
49*58b9f456SAndroid Build Coastguard Worker                      const key_equal& eql = key_equal(),
50*58b9f456SAndroid Build Coastguard Worker                      const allocator_type& a = allocator_type());
51*58b9f456SAndroid Build Coastguard Worker    hash_map(const hash_map&);
52*58b9f456SAndroid Build Coastguard Worker    ~hash_map();
53*58b9f456SAndroid Build Coastguard Worker    hash_map& operator=(const hash_map&);
54*58b9f456SAndroid Build Coastguard Worker
55*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const;
56*58b9f456SAndroid Build Coastguard Worker
57*58b9f456SAndroid Build Coastguard Worker    bool      empty() const;
58*58b9f456SAndroid Build Coastguard Worker    size_type size() const;
59*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const;
60*58b9f456SAndroid Build Coastguard Worker
61*58b9f456SAndroid Build Coastguard Worker    iterator       begin();
62*58b9f456SAndroid Build Coastguard Worker    iterator       end();
63*58b9f456SAndroid Build Coastguard Worker    const_iterator begin()  const;
64*58b9f456SAndroid Build Coastguard Worker    const_iterator end()    const;
65*58b9f456SAndroid Build Coastguard Worker
66*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> insert(const value_type& obj);
67*58b9f456SAndroid Build Coastguard Worker    template <class InputIterator>
68*58b9f456SAndroid Build Coastguard Worker        void insert(InputIterator first, InputIterator last);
69*58b9f456SAndroid Build Coastguard Worker
70*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator position);
71*58b9f456SAndroid Build Coastguard Worker    size_type erase(const key_type& k);
72*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator first, const_iterator last);
73*58b9f456SAndroid Build Coastguard Worker    void clear();
74*58b9f456SAndroid Build Coastguard Worker
75*58b9f456SAndroid Build Coastguard Worker    void swap(hash_map&);
76*58b9f456SAndroid Build Coastguard Worker
77*58b9f456SAndroid Build Coastguard Worker    hasher hash_funct() const;
78*58b9f456SAndroid Build Coastguard Worker    key_equal key_eq() const;
79*58b9f456SAndroid Build Coastguard Worker
80*58b9f456SAndroid Build Coastguard Worker    iterator       find(const key_type& k);
81*58b9f456SAndroid Build Coastguard Worker    const_iterator find(const key_type& k) const;
82*58b9f456SAndroid Build Coastguard Worker    size_type count(const key_type& k) const;
83*58b9f456SAndroid Build Coastguard Worker    pair<iterator, iterator>             equal_range(const key_type& k);
84*58b9f456SAndroid Build Coastguard Worker    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
85*58b9f456SAndroid Build Coastguard Worker
86*58b9f456SAndroid Build Coastguard Worker    mapped_type& operator[](const key_type& k);
87*58b9f456SAndroid Build Coastguard Worker
88*58b9f456SAndroid Build Coastguard Worker    size_type bucket_count() const;
89*58b9f456SAndroid Build Coastguard Worker    size_type max_bucket_count() const;
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker    size_type elems_in_bucket(size_type n) const;
92*58b9f456SAndroid Build Coastguard Worker
93*58b9f456SAndroid Build Coastguard Worker    void resize(size_type n);
94*58b9f456SAndroid Build Coastguard Worker};
95*58b9f456SAndroid Build Coastguard Worker
96*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
97*58b9f456SAndroid Build Coastguard Worker    void swap(hash_map<Key, T, Hash, Pred, Alloc>& x,
98*58b9f456SAndroid Build Coastguard Worker              hash_map<Key, T, Hash, Pred, Alloc>& y);
99*58b9f456SAndroid Build Coastguard Worker
100*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
101*58b9f456SAndroid Build Coastguard Worker    bool
102*58b9f456SAndroid Build Coastguard Worker    operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x,
103*58b9f456SAndroid Build Coastguard Worker               const hash_map<Key, T, Hash, Pred, Alloc>& y);
104*58b9f456SAndroid Build Coastguard Worker
105*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
106*58b9f456SAndroid Build Coastguard Worker    bool
107*58b9f456SAndroid Build Coastguard Worker    operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x,
108*58b9f456SAndroid Build Coastguard Worker               const hash_map<Key, T, Hash, Pred, Alloc>& y);
109*58b9f456SAndroid Build Coastguard Worker
110*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
111*58b9f456SAndroid Build Coastguard Worker          class Alloc = allocator<pair<const Key, T>>>
112*58b9f456SAndroid Build Coastguard Workerclass hash_multimap
113*58b9f456SAndroid Build Coastguard Worker{
114*58b9f456SAndroid Build Coastguard Workerpublic:
115*58b9f456SAndroid Build Coastguard Worker    // types
116*58b9f456SAndroid Build Coastguard Worker    typedef Key                                                        key_type;
117*58b9f456SAndroid Build Coastguard Worker    typedef T                                                          mapped_type;
118*58b9f456SAndroid Build Coastguard Worker    typedef Hash                                                       hasher;
119*58b9f456SAndroid Build Coastguard Worker    typedef Pred                                                       key_equal;
120*58b9f456SAndroid Build Coastguard Worker    typedef Alloc                                                      allocator_type;
121*58b9f456SAndroid Build Coastguard Worker    typedef pair<const key_type, mapped_type>                          value_type;
122*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                                reference;
123*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                                          const_reference;
124*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::pointer         pointer;
125*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
126*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::size_type       size_type;
127*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
128*58b9f456SAndroid Build Coastguard Worker
129*58b9f456SAndroid Build Coastguard Worker    typedef /unspecified/ iterator;
130*58b9f456SAndroid Build Coastguard Worker    typedef /unspecified/ const_iterator;
131*58b9f456SAndroid Build Coastguard Worker
132*58b9f456SAndroid Build Coastguard Worker    explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(),
133*58b9f456SAndroid Build Coastguard Worker                           const key_equal& eql = key_equal(),
134*58b9f456SAndroid Build Coastguard Worker                           const allocator_type& a = allocator_type());
135*58b9f456SAndroid Build Coastguard Worker    template <class InputIterator>
136*58b9f456SAndroid Build Coastguard Worker        hash_multimap(InputIterator f, InputIterator l,
137*58b9f456SAndroid Build Coastguard Worker                      size_type n = 193, const hasher& hf = hasher(),
138*58b9f456SAndroid Build Coastguard Worker                      const key_equal& eql = key_equal(),
139*58b9f456SAndroid Build Coastguard Worker                      const allocator_type& a = allocator_type());
140*58b9f456SAndroid Build Coastguard Worker    explicit hash_multimap(const allocator_type&);
141*58b9f456SAndroid Build Coastguard Worker    hash_multimap(const hash_multimap&);
142*58b9f456SAndroid Build Coastguard Worker    ~hash_multimap();
143*58b9f456SAndroid Build Coastguard Worker    hash_multimap& operator=(const hash_multimap&);
144*58b9f456SAndroid Build Coastguard Worker
145*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const;
146*58b9f456SAndroid Build Coastguard Worker
147*58b9f456SAndroid Build Coastguard Worker    bool      empty() const;
148*58b9f456SAndroid Build Coastguard Worker    size_type size() const;
149*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const;
150*58b9f456SAndroid Build Coastguard Worker
151*58b9f456SAndroid Build Coastguard Worker    iterator       begin();
152*58b9f456SAndroid Build Coastguard Worker    iterator       end();
153*58b9f456SAndroid Build Coastguard Worker    const_iterator begin()  const;
154*58b9f456SAndroid Build Coastguard Worker    const_iterator end()    const;
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Worker    iterator insert(const value_type& obj);
157*58b9f456SAndroid Build Coastguard Worker    template <class InputIterator>
158*58b9f456SAndroid Build Coastguard Worker        void insert(InputIterator first, InputIterator last);
159*58b9f456SAndroid Build Coastguard Worker
160*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator position);
161*58b9f456SAndroid Build Coastguard Worker    size_type erase(const key_type& k);
162*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator first, const_iterator last);
163*58b9f456SAndroid Build Coastguard Worker    void clear();
164*58b9f456SAndroid Build Coastguard Worker
165*58b9f456SAndroid Build Coastguard Worker    void swap(hash_multimap&);
166*58b9f456SAndroid Build Coastguard Worker
167*58b9f456SAndroid Build Coastguard Worker    hasher hash_funct() const;
168*58b9f456SAndroid Build Coastguard Worker    key_equal key_eq() const;
169*58b9f456SAndroid Build Coastguard Worker
170*58b9f456SAndroid Build Coastguard Worker    iterator       find(const key_type& k);
171*58b9f456SAndroid Build Coastguard Worker    const_iterator find(const key_type& k) const;
172*58b9f456SAndroid Build Coastguard Worker    size_type count(const key_type& k) const;
173*58b9f456SAndroid Build Coastguard Worker    pair<iterator, iterator>             equal_range(const key_type& k);
174*58b9f456SAndroid Build Coastguard Worker    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
175*58b9f456SAndroid Build Coastguard Worker
176*58b9f456SAndroid Build Coastguard Worker    size_type bucket_count() const;
177*58b9f456SAndroid Build Coastguard Worker    size_type max_bucket_count() const;
178*58b9f456SAndroid Build Coastguard Worker
179*58b9f456SAndroid Build Coastguard Worker    size_type elems_in_bucket(size_type n) const;
180*58b9f456SAndroid Build Coastguard Worker
181*58b9f456SAndroid Build Coastguard Worker    void resize(size_type n);
182*58b9f456SAndroid Build Coastguard Worker};
183*58b9f456SAndroid Build Coastguard Worker
184*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
185*58b9f456SAndroid Build Coastguard Worker    void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x,
186*58b9f456SAndroid Build Coastguard Worker              hash_multimap<Key, T, Hash, Pred, Alloc>& y);
187*58b9f456SAndroid Build Coastguard Worker
188*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
189*58b9f456SAndroid Build Coastguard Worker    bool
190*58b9f456SAndroid Build Coastguard Worker    operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
191*58b9f456SAndroid Build Coastguard Worker               const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
192*58b9f456SAndroid Build Coastguard Worker
193*58b9f456SAndroid Build Coastguard Workertemplate <class Key, class T, class Hash, class Pred, class Alloc>
194*58b9f456SAndroid Build Coastguard Worker    bool
195*58b9f456SAndroid Build Coastguard Worker    operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
196*58b9f456SAndroid Build Coastguard Worker               const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
197*58b9f456SAndroid Build Coastguard Worker
198*58b9f456SAndroid Build Coastguard Worker}  // __gnu_cxx
199*58b9f456SAndroid Build Coastguard Worker
200*58b9f456SAndroid Build Coastguard Worker*/
201*58b9f456SAndroid Build Coastguard Worker
202*58b9f456SAndroid Build Coastguard Worker#include <__config>
203*58b9f456SAndroid Build Coastguard Worker#include <__hash_table>
204*58b9f456SAndroid Build Coastguard Worker#include <functional>
205*58b9f456SAndroid Build Coastguard Worker#include <stdexcept>
206*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
207*58b9f456SAndroid Build Coastguard Worker#include <ext/__hash>
208*58b9f456SAndroid Build Coastguard Worker
209*58b9f456SAndroid Build Coastguard Worker#if __DEPRECATED
210*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_WARNING)
211*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated.  Migrate to <unordered_map>")
212*58b9f456SAndroid Build Coastguard Worker#else
213*58b9f456SAndroid Build Coastguard Worker#   warning Use of the header <ext/hash_map> is deprecated.  Migrate to <unordered_map>
214*58b9f456SAndroid Build Coastguard Worker#endif
215*58b9f456SAndroid Build Coastguard Worker#endif
216*58b9f456SAndroid Build Coastguard Worker
217*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
218*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
219*58b9f456SAndroid Build Coastguard Worker#endif
220*58b9f456SAndroid Build Coastguard Worker
221*58b9f456SAndroid Build Coastguard Workernamespace __gnu_cxx {
222*58b9f456SAndroid Build Coastguard Worker
223*58b9f456SAndroid Build Coastguard Workerusing namespace std;
224*58b9f456SAndroid Build Coastguard Worker
225*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash,
226*58b9f456SAndroid Build Coastguard Worker          bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
227*58b9f456SAndroid Build Coastguard Worker        >
228*58b9f456SAndroid Build Coastguard Workerclass __hash_map_hasher
229*58b9f456SAndroid Build Coastguard Worker    : private _Hash
230*58b9f456SAndroid Build Coastguard Worker{
231*58b9f456SAndroid Build Coastguard Workerpublic:
232*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {}
233*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {}
234*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;}
235*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
236*58b9f456SAndroid Build Coastguard Worker    size_t operator()(const _Tp& __x) const
237*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Hash&>(*this)(__x.first);}
238*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
239*58b9f456SAndroid Build Coastguard Worker    size_t operator()(const typename _Tp::first_type& __x) const
240*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Hash&>(*this)(__x);}
241*58b9f456SAndroid Build Coastguard Worker};
242*58b9f456SAndroid Build Coastguard Worker
243*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash>
244*58b9f456SAndroid Build Coastguard Workerclass __hash_map_hasher<_Tp, _Hash, false>
245*58b9f456SAndroid Build Coastguard Worker{
246*58b9f456SAndroid Build Coastguard Worker    _Hash __hash_;
247*58b9f456SAndroid Build Coastguard Workerpublic:
248*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {}
249*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {}
250*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;}
251*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
252*58b9f456SAndroid Build Coastguard Worker    size_t operator()(const _Tp& __x) const
253*58b9f456SAndroid Build Coastguard Worker        {return __hash_(__x.first);}
254*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
255*58b9f456SAndroid Build Coastguard Worker    size_t operator()(const typename _Tp::first_type& __x) const
256*58b9f456SAndroid Build Coastguard Worker        {return __hash_(__x);}
257*58b9f456SAndroid Build Coastguard Worker};
258*58b9f456SAndroid Build Coastguard Worker
259*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Pred,
260*58b9f456SAndroid Build Coastguard Worker          bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
261*58b9f456SAndroid Build Coastguard Worker         >
262*58b9f456SAndroid Build Coastguard Workerclass __hash_map_equal
263*58b9f456SAndroid Build Coastguard Worker    : private _Pred
264*58b9f456SAndroid Build Coastguard Worker{
265*58b9f456SAndroid Build Coastguard Workerpublic:
266*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {}
267*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {}
268*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;}
269*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
270*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const _Tp& __y) const
271*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
272*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
273*58b9f456SAndroid Build Coastguard Worker    bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
274*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Pred&>(*this)(__x, __y.first);}
275*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
276*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
277*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Pred&>(*this)(__x.first, __y);}
278*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
279*58b9f456SAndroid Build Coastguard Worker    bool operator()(const typename _Tp::first_type& __x,
280*58b9f456SAndroid Build Coastguard Worker                    const typename _Tp::first_type& __y) const
281*58b9f456SAndroid Build Coastguard Worker        {return static_cast<const _Pred&>(*this)(__x, __y);}
282*58b9f456SAndroid Build Coastguard Worker};
283*58b9f456SAndroid Build Coastguard Worker
284*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Pred>
285*58b9f456SAndroid Build Coastguard Workerclass __hash_map_equal<_Tp, _Pred, false>
286*58b9f456SAndroid Build Coastguard Worker{
287*58b9f456SAndroid Build Coastguard Worker    _Pred __pred_;
288*58b9f456SAndroid Build Coastguard Workerpublic:
289*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {}
290*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {}
291*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;}
292*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
293*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const _Tp& __y) const
294*58b9f456SAndroid Build Coastguard Worker        {return __pred_(__x.first, __y.first);}
295*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
296*58b9f456SAndroid Build Coastguard Worker    bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
297*58b9f456SAndroid Build Coastguard Worker        {return __pred_(__x, __y.first);}
298*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
299*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
300*58b9f456SAndroid Build Coastguard Worker        {return __pred_(__x.first, __y);}
301*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
302*58b9f456SAndroid Build Coastguard Worker    bool operator()(const typename _Tp::first_type& __x,
303*58b9f456SAndroid Build Coastguard Worker                    const typename _Tp::first_type& __y) const
304*58b9f456SAndroid Build Coastguard Worker        {return __pred_(__x, __y);}
305*58b9f456SAndroid Build Coastguard Worker};
306*58b9f456SAndroid Build Coastguard Worker
307*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc>
308*58b9f456SAndroid Build Coastguard Workerclass __hash_map_node_destructor
309*58b9f456SAndroid Build Coastguard Worker{
310*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                              allocator_type;
311*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>    __alloc_traits;
312*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::value_type::__node_value_type value_type;
313*58b9f456SAndroid Build Coastguard Workerpublic:
314*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer    pointer;
315*58b9f456SAndroid Build Coastguard Workerprivate:
316*58b9f456SAndroid Build Coastguard Worker    typedef typename value_type::first_type     first_type;
317*58b9f456SAndroid Build Coastguard Worker    typedef typename value_type::second_type    second_type;
318*58b9f456SAndroid Build Coastguard Worker
319*58b9f456SAndroid Build Coastguard Worker    allocator_type& __na_;
320*58b9f456SAndroid Build Coastguard Worker
321*58b9f456SAndroid Build Coastguard Worker    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
322*58b9f456SAndroid Build Coastguard Worker
323*58b9f456SAndroid Build Coastguard Workerpublic:
324*58b9f456SAndroid Build Coastguard Worker    bool __first_constructed;
325*58b9f456SAndroid Build Coastguard Worker    bool __second_constructed;
326*58b9f456SAndroid Build Coastguard Worker
327*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
328*58b9f456SAndroid Build Coastguard Worker    explicit __hash_map_node_destructor(allocator_type& __na)
329*58b9f456SAndroid Build Coastguard Worker        : __na_(__na),
330*58b9f456SAndroid Build Coastguard Worker          __first_constructed(false),
331*58b9f456SAndroid Build Coastguard Worker          __second_constructed(false)
332*58b9f456SAndroid Build Coastguard Worker        {}
333*58b9f456SAndroid Build Coastguard Worker
334*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
335*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
336*58b9f456SAndroid Build Coastguard Worker    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
337*58b9f456SAndroid Build Coastguard Worker        : __na_(__x.__na_),
338*58b9f456SAndroid Build Coastguard Worker          __first_constructed(__x.__value_constructed),
339*58b9f456SAndroid Build Coastguard Worker          __second_constructed(__x.__value_constructed)
340*58b9f456SAndroid Build Coastguard Worker        {
341*58b9f456SAndroid Build Coastguard Worker            __x.__value_constructed = false;
342*58b9f456SAndroid Build Coastguard Worker        }
343*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_CXX03_LANG
344*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
345*58b9f456SAndroid Build Coastguard Worker    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
346*58b9f456SAndroid Build Coastguard Worker        : __na_(__x.__na_),
347*58b9f456SAndroid Build Coastguard Worker          __first_constructed(__x.__value_constructed),
348*58b9f456SAndroid Build Coastguard Worker          __second_constructed(__x.__value_constructed)
349*58b9f456SAndroid Build Coastguard Worker        {
350*58b9f456SAndroid Build Coastguard Worker            const_cast<bool&>(__x.__value_constructed) = false;
351*58b9f456SAndroid Build Coastguard Worker        }
352*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
355*58b9f456SAndroid Build Coastguard Worker    void operator()(pointer __p)
356*58b9f456SAndroid Build Coastguard Worker    {
357*58b9f456SAndroid Build Coastguard Worker        if (__second_constructed)
358*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
359*58b9f456SAndroid Build Coastguard Worker        if (__first_constructed)
360*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
361*58b9f456SAndroid Build Coastguard Worker        if (__p)
362*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::deallocate(__na_, __p, 1);
363*58b9f456SAndroid Build Coastguard Worker    }
364*58b9f456SAndroid Build Coastguard Worker};
365*58b9f456SAndroid Build Coastguard Worker
366*58b9f456SAndroid Build Coastguard Workertemplate <class _HashIterator>
367*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator
368*58b9f456SAndroid Build Coastguard Worker{
369*58b9f456SAndroid Build Coastguard Worker    _HashIterator __i_;
370*58b9f456SAndroid Build Coastguard Worker
371*58b9f456SAndroid Build Coastguard Worker    typedef const typename _HashIterator::value_type::first_type key_type;
372*58b9f456SAndroid Build Coastguard Worker    typedef typename _HashIterator::value_type::second_type      mapped_type;
373*58b9f456SAndroid Build Coastguard Workerpublic:
374*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                                 iterator_category;
375*58b9f456SAndroid Build Coastguard Worker    typedef pair<key_type, mapped_type>                          value_type;
376*58b9f456SAndroid Build Coastguard Worker    typedef typename _HashIterator::difference_type              difference_type;
377*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                          reference;
378*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<typename _HashIterator::pointer, value_type>::type
379*58b9f456SAndroid Build Coastguard Worker        pointer;
380*58b9f456SAndroid Build Coastguard Worker
381*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
382*58b9f456SAndroid Build Coastguard Worker
383*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {}
384*58b9f456SAndroid Build Coastguard Worker
385*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();}
386*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();}
387*58b9f456SAndroid Build Coastguard Worker
388*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;}
389*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
390*58b9f456SAndroid Build Coastguard Worker    __hash_map_iterator operator++(int)
391*58b9f456SAndroid Build Coastguard Worker    {
392*58b9f456SAndroid Build Coastguard Worker        __hash_map_iterator __t(*this);
393*58b9f456SAndroid Build Coastguard Worker        ++(*this);
394*58b9f456SAndroid Build Coastguard Worker        return __t;
395*58b9f456SAndroid Build Coastguard Worker    }
396*58b9f456SAndroid Build Coastguard Worker
397*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
398*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
399*58b9f456SAndroid Build Coastguard Worker        {return __x.__i_ == __y.__i_;}
400*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
401*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
402*58b9f456SAndroid Build Coastguard Worker        {return __x.__i_ != __y.__i_;}
403*58b9f456SAndroid Build Coastguard Worker
404*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
405*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
406*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
407*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
408*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
409*58b9f456SAndroid Build Coastguard Worker};
410*58b9f456SAndroid Build Coastguard Worker
411*58b9f456SAndroid Build Coastguard Workertemplate <class _HashIterator>
412*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
413*58b9f456SAndroid Build Coastguard Worker{
414*58b9f456SAndroid Build Coastguard Worker    _HashIterator __i_;
415*58b9f456SAndroid Build Coastguard Worker
416*58b9f456SAndroid Build Coastguard Worker    typedef const typename _HashIterator::value_type::first_type key_type;
417*58b9f456SAndroid Build Coastguard Worker    typedef typename _HashIterator::value_type::second_type      mapped_type;
418*58b9f456SAndroid Build Coastguard Workerpublic:
419*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                                 iterator_category;
420*58b9f456SAndroid Build Coastguard Worker    typedef pair<key_type, mapped_type>                          value_type;
421*58b9f456SAndroid Build Coastguard Worker    typedef typename _HashIterator::difference_type              difference_type;
422*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                                    reference;
423*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<typename _HashIterator::pointer, const value_type>::type
424*58b9f456SAndroid Build Coastguard Worker        pointer;
425*58b9f456SAndroid Build Coastguard Worker
426*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
427*58b9f456SAndroid Build Coastguard Worker
428*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
429*58b9f456SAndroid Build Coastguard Worker    __hash_map_const_iterator(_HashIterator __i) : __i_(__i) {}
430*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
431*58b9f456SAndroid Build Coastguard Worker    __hash_map_const_iterator(
432*58b9f456SAndroid Build Coastguard Worker            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
433*58b9f456SAndroid Build Coastguard Worker                : __i_(__i.__i_) {}
434*58b9f456SAndroid Build Coastguard Worker
435*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
436*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {return *operator->();}
437*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
438*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const {return (pointer)__i_.operator->();}
439*58b9f456SAndroid Build Coastguard Worker
440*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
441*58b9f456SAndroid Build Coastguard Worker    __hash_map_const_iterator& operator++() {++__i_; return *this;}
442*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
443*58b9f456SAndroid Build Coastguard Worker    __hash_map_const_iterator operator++(int)
444*58b9f456SAndroid Build Coastguard Worker    {
445*58b9f456SAndroid Build Coastguard Worker        __hash_map_const_iterator __t(*this);
446*58b9f456SAndroid Build Coastguard Worker        ++(*this);
447*58b9f456SAndroid Build Coastguard Worker        return __t;
448*58b9f456SAndroid Build Coastguard Worker    }
449*58b9f456SAndroid Build Coastguard Worker
450*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
451*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
452*58b9f456SAndroid Build Coastguard Worker        {return __x.__i_ == __y.__i_;}
453*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
454*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
455*58b9f456SAndroid Build Coastguard Worker        {return __x.__i_ != __y.__i_;}
456*58b9f456SAndroid Build Coastguard Worker
457*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
458*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
459*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
460*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
461*58b9f456SAndroid Build Coastguard Worker};
462*58b9f456SAndroid Build Coastguard Worker
463*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
464*58b9f456SAndroid Build Coastguard Worker          class _Alloc = allocator<pair<const _Key, _Tp> > >
465*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS hash_map
466*58b9f456SAndroid Build Coastguard Worker{
467*58b9f456SAndroid Build Coastguard Workerpublic:
468*58b9f456SAndroid Build Coastguard Worker    // types
469*58b9f456SAndroid Build Coastguard Worker    typedef _Key                                           key_type;
470*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                            mapped_type;
471*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                            data_type;
472*58b9f456SAndroid Build Coastguard Worker    typedef _Hash                                          hasher;
473*58b9f456SAndroid Build Coastguard Worker    typedef _Pred                                          key_equal;
474*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                         allocator_type;
475*58b9f456SAndroid Build Coastguard Worker    typedef pair<const key_type, mapped_type>              value_type;
476*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                    reference;
477*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                              const_reference;
478*58b9f456SAndroid Build Coastguard Worker
479*58b9f456SAndroid Build Coastguard Workerprivate:
480*58b9f456SAndroid Build Coastguard Worker    typedef pair<key_type, mapped_type>                    __value_type;
481*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_hasher<__value_type, hasher>   __hasher;
482*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_equal<__value_type, key_equal> __key_equal;
483*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
484*58b9f456SAndroid Build Coastguard Worker
485*58b9f456SAndroid Build Coastguard Worker    typedef __hash_table<__value_type, __hasher,
486*58b9f456SAndroid Build Coastguard Worker                         __key_equal,  __allocator_type>   __table;
487*58b9f456SAndroid Build Coastguard Worker
488*58b9f456SAndroid Build Coastguard Worker    __table __table_;
489*58b9f456SAndroid Build Coastguard Worker
490*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_pointer               __node_pointer;
491*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_const_pointer         __node_const_pointer;
492*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_traits                __node_traits;
493*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_allocator             __node_allocator;
494*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node                       __node;
495*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
496*58b9f456SAndroid Build Coastguard Worker    typedef unique_ptr<__node, _Dp>                         __node_holder;
497*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>               __alloc_traits;
498*58b9f456SAndroid Build Coastguard Workerpublic:
499*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer         pointer;
500*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::const_pointer   const_pointer;
501*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type       size_type;
502*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::difference_type difference_type;
503*58b9f456SAndroid Build Coastguard Worker
504*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_iterator<typename __table::iterator>       iterator;
505*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
506*58b9f456SAndroid Build Coastguard Worker
507*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY hash_map() {__table_.rehash(193);}
508*58b9f456SAndroid Build Coastguard Worker    explicit hash_map(size_type __n, const hasher& __hf = hasher(),
509*58b9f456SAndroid Build Coastguard Worker                           const key_equal& __eql = key_equal());
510*58b9f456SAndroid Build Coastguard Worker    hash_map(size_type __n, const hasher& __hf,
511*58b9f456SAndroid Build Coastguard Worker                  const key_equal& __eql,
512*58b9f456SAndroid Build Coastguard Worker                  const allocator_type& __a);
513*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
514*58b9f456SAndroid Build Coastguard Worker        hash_map(_InputIterator __first, _InputIterator __last);
515*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
516*58b9f456SAndroid Build Coastguard Worker        hash_map(_InputIterator __first, _InputIterator __last,
517*58b9f456SAndroid Build Coastguard Worker                      size_type __n, const hasher& __hf = hasher(),
518*58b9f456SAndroid Build Coastguard Worker                      const key_equal& __eql = key_equal());
519*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
520*58b9f456SAndroid Build Coastguard Worker        hash_map(_InputIterator __first, _InputIterator __last,
521*58b9f456SAndroid Build Coastguard Worker                      size_type __n, const hasher& __hf,
522*58b9f456SAndroid Build Coastguard Worker                      const key_equal& __eql,
523*58b9f456SAndroid Build Coastguard Worker                      const allocator_type& __a);
524*58b9f456SAndroid Build Coastguard Worker    hash_map(const hash_map& __u);
525*58b9f456SAndroid Build Coastguard Worker
526*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
527*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const
528*58b9f456SAndroid Build Coastguard Worker        {return allocator_type(__table_.__node_alloc());}
529*58b9f456SAndroid Build Coastguard Worker
530*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
531*58b9f456SAndroid Build Coastguard Worker    bool      empty() const {return __table_.size() == 0;}
532*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
533*58b9f456SAndroid Build Coastguard Worker    size_type size() const  {return __table_.size();}
534*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
535*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const {return __table_.max_size();}
536*58b9f456SAndroid Build Coastguard Worker
537*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
538*58b9f456SAndroid Build Coastguard Worker    iterator       begin()        {return __table_.begin();}
539*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
540*58b9f456SAndroid Build Coastguard Worker    iterator       end()          {return __table_.end();}
541*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
542*58b9f456SAndroid Build Coastguard Worker    const_iterator begin()  const {return __table_.begin();}
543*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
544*58b9f456SAndroid Build Coastguard Worker    const_iterator end()    const {return __table_.end();}
545*58b9f456SAndroid Build Coastguard Worker
546*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
547*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> insert(const value_type& __x)
548*58b9f456SAndroid Build Coastguard Worker        {return __table_.__insert_unique(__x);}
549*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
550*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
551*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
552*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
553*58b9f456SAndroid Build Coastguard Worker        void insert(_InputIterator __first, _InputIterator __last);
554*58b9f456SAndroid Build Coastguard Worker
555*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
556*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator __p) {__table_.erase(__p.__i_);}
557*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
558*58b9f456SAndroid Build Coastguard Worker    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
559*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
560*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator __first, const_iterator __last)
561*58b9f456SAndroid Build Coastguard Worker        {__table_.erase(__first.__i_, __last.__i_);}
562*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
563*58b9f456SAndroid Build Coastguard Worker    void clear() {__table_.clear();}
564*58b9f456SAndroid Build Coastguard Worker
565*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
566*58b9f456SAndroid Build Coastguard Worker    void swap(hash_map& __u) {__table_.swap(__u.__table_);}
567*58b9f456SAndroid Build Coastguard Worker
568*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
569*58b9f456SAndroid Build Coastguard Worker    hasher hash_funct() const
570*58b9f456SAndroid Build Coastguard Worker        {return __table_.hash_function().hash_function();}
571*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
572*58b9f456SAndroid Build Coastguard Worker    key_equal key_eq() const
573*58b9f456SAndroid Build Coastguard Worker        {return __table_.key_eq().key_eq();}
574*58b9f456SAndroid Build Coastguard Worker
575*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
576*58b9f456SAndroid Build Coastguard Worker    iterator       find(const key_type& __k)       {return __table_.find(__k);}
577*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
578*58b9f456SAndroid Build Coastguard Worker    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
579*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
580*58b9f456SAndroid Build Coastguard Worker    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
581*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
582*58b9f456SAndroid Build Coastguard Worker    pair<iterator, iterator>             equal_range(const key_type& __k)
583*58b9f456SAndroid Build Coastguard Worker        {return __table_.__equal_range_unique(__k);}
584*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
585*58b9f456SAndroid Build Coastguard Worker    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
586*58b9f456SAndroid Build Coastguard Worker        {return __table_.__equal_range_unique(__k);}
587*58b9f456SAndroid Build Coastguard Worker
588*58b9f456SAndroid Build Coastguard Worker    mapped_type& operator[](const key_type& __k);
589*58b9f456SAndroid Build Coastguard Worker
590*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
591*58b9f456SAndroid Build Coastguard Worker    size_type bucket_count() const {return __table_.bucket_count();}
592*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
593*58b9f456SAndroid Build Coastguard Worker    size_type max_bucket_count() const {return __table_.max_bucket_count();}
594*58b9f456SAndroid Build Coastguard Worker
595*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
596*58b9f456SAndroid Build Coastguard Worker    size_type elems_in_bucket(size_type __n) const
597*58b9f456SAndroid Build Coastguard Worker        {return __table_.bucket_size(__n);}
598*58b9f456SAndroid Build Coastguard Worker
599*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
600*58b9f456SAndroid Build Coastguard Worker    void resize(size_type __n) {__table_.rehash(__n);}
601*58b9f456SAndroid Build Coastguard Worker
602*58b9f456SAndroid Build Coastguard Workerprivate:
603*58b9f456SAndroid Build Coastguard Worker    __node_holder __construct_node(const key_type& __k);
604*58b9f456SAndroid Build Coastguard Worker};
605*58b9f456SAndroid Build Coastguard Worker
606*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
607*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
608*58b9f456SAndroid Build Coastguard Worker        size_type __n, const hasher& __hf, const key_equal& __eql)
609*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql)
610*58b9f456SAndroid Build Coastguard Worker{
611*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
612*58b9f456SAndroid Build Coastguard Worker}
613*58b9f456SAndroid Build Coastguard Worker
614*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
615*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
616*58b9f456SAndroid Build Coastguard Worker        size_type __n, const hasher& __hf, const key_equal& __eql,
617*58b9f456SAndroid Build Coastguard Worker        const allocator_type& __a)
618*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql, __a)
619*58b9f456SAndroid Build Coastguard Worker{
620*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
621*58b9f456SAndroid Build Coastguard Worker}
622*58b9f456SAndroid Build Coastguard Worker
623*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
624*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
625*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
626*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last)
627*58b9f456SAndroid Build Coastguard Worker{
628*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(193);
629*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
630*58b9f456SAndroid Build Coastguard Worker}
631*58b9f456SAndroid Build Coastguard Worker
632*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
633*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
634*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
635*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last, size_type __n,
636*58b9f456SAndroid Build Coastguard Worker        const hasher& __hf, const key_equal& __eql)
637*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql)
638*58b9f456SAndroid Build Coastguard Worker{
639*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
640*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
641*58b9f456SAndroid Build Coastguard Worker}
642*58b9f456SAndroid Build Coastguard Worker
643*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
644*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
645*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
646*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last, size_type __n,
647*58b9f456SAndroid Build Coastguard Worker        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
648*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql, __a)
649*58b9f456SAndroid Build Coastguard Worker{
650*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
651*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
652*58b9f456SAndroid Build Coastguard Worker}
653*58b9f456SAndroid Build Coastguard Worker
654*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
655*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
656*58b9f456SAndroid Build Coastguard Worker        const hash_map& __u)
657*58b9f456SAndroid Build Coastguard Worker    : __table_(__u.__table_)
658*58b9f456SAndroid Build Coastguard Worker{
659*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__u.bucket_count());
660*58b9f456SAndroid Build Coastguard Worker    insert(__u.begin(), __u.end());
661*58b9f456SAndroid Build Coastguard Worker}
662*58b9f456SAndroid Build Coastguard Worker
663*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
664*58b9f456SAndroid Build Coastguard Workertypename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
665*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
666*58b9f456SAndroid Build Coastguard Worker{
667*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __table_.__node_alloc();
668*58b9f456SAndroid Build Coastguard Worker    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
669*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k);
670*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__first_constructed = true;
671*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
672*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__second_constructed = true;
673*58b9f456SAndroid Build Coastguard Worker    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
674*58b9f456SAndroid Build Coastguard Worker}
675*58b9f456SAndroid Build Coastguard Worker
676*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
677*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
678*58b9f456SAndroid Build Coastguard Workerinline
679*58b9f456SAndroid Build Coastguard Workervoid
680*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
681*58b9f456SAndroid Build Coastguard Worker                                                       _InputIterator __last)
682*58b9f456SAndroid Build Coastguard Worker{
683*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
684*58b9f456SAndroid Build Coastguard Worker        __table_.__insert_unique(*__first);
685*58b9f456SAndroid Build Coastguard Worker}
686*58b9f456SAndroid Build Coastguard Worker
687*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
688*58b9f456SAndroid Build Coastguard Worker_Tp&
689*58b9f456SAndroid Build Coastguard Workerhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
690*58b9f456SAndroid Build Coastguard Worker{
691*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__k);
692*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
693*58b9f456SAndroid Build Coastguard Worker        return __i->second;
694*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(__k);
695*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
696*58b9f456SAndroid Build Coastguard Worker    __h.release();
697*58b9f456SAndroid Build Coastguard Worker    return __r.first->second;
698*58b9f456SAndroid Build Coastguard Worker}
699*58b9f456SAndroid Build Coastguard Worker
700*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
701*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
702*58b9f456SAndroid Build Coastguard Workervoid
703*58b9f456SAndroid Build Coastguard Workerswap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
704*58b9f456SAndroid Build Coastguard Worker     hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
705*58b9f456SAndroid Build Coastguard Worker{
706*58b9f456SAndroid Build Coastguard Worker    __x.swap(__y);
707*58b9f456SAndroid Build Coastguard Worker}
708*58b9f456SAndroid Build Coastguard Worker
709*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
710*58b9f456SAndroid Build Coastguard Workerbool
711*58b9f456SAndroid Build Coastguard Workeroperator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
712*58b9f456SAndroid Build Coastguard Worker           const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
713*58b9f456SAndroid Build Coastguard Worker{
714*58b9f456SAndroid Build Coastguard Worker    if (__x.size() != __y.size())
715*58b9f456SAndroid Build Coastguard Worker        return false;
716*58b9f456SAndroid Build Coastguard Worker    typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
717*58b9f456SAndroid Build Coastguard Worker                                                                 const_iterator;
718*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
719*58b9f456SAndroid Build Coastguard Worker            __i != __ex; ++__i)
720*58b9f456SAndroid Build Coastguard Worker    {
721*58b9f456SAndroid Build Coastguard Worker        const_iterator __j = __y.find(__i->first);
722*58b9f456SAndroid Build Coastguard Worker        if (__j == __ey || !(*__i == *__j))
723*58b9f456SAndroid Build Coastguard Worker            return false;
724*58b9f456SAndroid Build Coastguard Worker    }
725*58b9f456SAndroid Build Coastguard Worker    return true;
726*58b9f456SAndroid Build Coastguard Worker}
727*58b9f456SAndroid Build Coastguard Worker
728*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
729*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
730*58b9f456SAndroid Build Coastguard Workerbool
731*58b9f456SAndroid Build Coastguard Workeroperator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
732*58b9f456SAndroid Build Coastguard Worker           const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
733*58b9f456SAndroid Build Coastguard Worker{
734*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
735*58b9f456SAndroid Build Coastguard Worker}
736*58b9f456SAndroid Build Coastguard Worker
737*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
738*58b9f456SAndroid Build Coastguard Worker          class _Alloc = allocator<pair<const _Key, _Tp> > >
739*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS hash_multimap
740*58b9f456SAndroid Build Coastguard Worker{
741*58b9f456SAndroid Build Coastguard Workerpublic:
742*58b9f456SAndroid Build Coastguard Worker    // types
743*58b9f456SAndroid Build Coastguard Worker    typedef _Key                                           key_type;
744*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                            mapped_type;
745*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                            data_type;
746*58b9f456SAndroid Build Coastguard Worker    typedef _Hash                                          hasher;
747*58b9f456SAndroid Build Coastguard Worker    typedef _Pred                                          key_equal;
748*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                         allocator_type;
749*58b9f456SAndroid Build Coastguard Worker    typedef pair<const key_type, mapped_type>              value_type;
750*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                    reference;
751*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                              const_reference;
752*58b9f456SAndroid Build Coastguard Worker
753*58b9f456SAndroid Build Coastguard Workerprivate:
754*58b9f456SAndroid Build Coastguard Worker    typedef pair<key_type, mapped_type>                    __value_type;
755*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_hasher<__value_type, hasher>   __hasher;
756*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_equal<__value_type, key_equal> __key_equal;
757*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
758*58b9f456SAndroid Build Coastguard Worker
759*58b9f456SAndroid Build Coastguard Worker    typedef __hash_table<__value_type, __hasher,
760*58b9f456SAndroid Build Coastguard Worker                         __key_equal,  __allocator_type>   __table;
761*58b9f456SAndroid Build Coastguard Worker
762*58b9f456SAndroid Build Coastguard Worker    __table __table_;
763*58b9f456SAndroid Build Coastguard Worker
764*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_traits                __node_traits;
765*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node_allocator             __node_allocator;
766*58b9f456SAndroid Build Coastguard Worker    typedef typename __table::__node                       __node;
767*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_node_destructor<__node_allocator>   _Dp;
768*58b9f456SAndroid Build Coastguard Worker    typedef unique_ptr<__node, _Dp>                         __node_holder;
769*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>               __alloc_traits;
770*58b9f456SAndroid Build Coastguard Workerpublic:
771*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer         pointer;
772*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::const_pointer   const_pointer;
773*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type       size_type;
774*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::difference_type difference_type;
775*58b9f456SAndroid Build Coastguard Worker
776*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_iterator<typename __table::iterator>       iterator;
777*58b9f456SAndroid Build Coastguard Worker    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
778*58b9f456SAndroid Build Coastguard Worker
779*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
780*58b9f456SAndroid Build Coastguard Worker    hash_multimap() {__table_.rehash(193);}
781*58b9f456SAndroid Build Coastguard Worker    explicit hash_multimap(size_type __n, const hasher& __hf = hasher(),
782*58b9f456SAndroid Build Coastguard Worker                                const key_equal& __eql = key_equal());
783*58b9f456SAndroid Build Coastguard Worker    hash_multimap(size_type __n, const hasher& __hf,
784*58b9f456SAndroid Build Coastguard Worker                                const key_equal& __eql,
785*58b9f456SAndroid Build Coastguard Worker                                const allocator_type& __a);
786*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
787*58b9f456SAndroid Build Coastguard Worker        hash_multimap(_InputIterator __first, _InputIterator __last);
788*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
789*58b9f456SAndroid Build Coastguard Worker        hash_multimap(_InputIterator __first, _InputIterator __last,
790*58b9f456SAndroid Build Coastguard Worker                      size_type __n, const hasher& __hf = hasher(),
791*58b9f456SAndroid Build Coastguard Worker                      const key_equal& __eql = key_equal());
792*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
793*58b9f456SAndroid Build Coastguard Worker        hash_multimap(_InputIterator __first, _InputIterator __last,
794*58b9f456SAndroid Build Coastguard Worker                      size_type __n, const hasher& __hf,
795*58b9f456SAndroid Build Coastguard Worker                      const key_equal& __eql,
796*58b9f456SAndroid Build Coastguard Worker                      const allocator_type& __a);
797*58b9f456SAndroid Build Coastguard Worker    hash_multimap(const hash_multimap& __u);
798*58b9f456SAndroid Build Coastguard Worker
799*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
800*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const
801*58b9f456SAndroid Build Coastguard Worker        {return allocator_type(__table_.__node_alloc());}
802*58b9f456SAndroid Build Coastguard Worker
803*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
804*58b9f456SAndroid Build Coastguard Worker    bool      empty() const {return __table_.size() == 0;}
805*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
806*58b9f456SAndroid Build Coastguard Worker    size_type size() const  {return __table_.size();}
807*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
808*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const {return __table_.max_size();}
809*58b9f456SAndroid Build Coastguard Worker
810*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
811*58b9f456SAndroid Build Coastguard Worker    iterator       begin()        {return __table_.begin();}
812*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
813*58b9f456SAndroid Build Coastguard Worker    iterator       end()          {return __table_.end();}
814*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
815*58b9f456SAndroid Build Coastguard Worker    const_iterator begin()  const {return __table_.begin();}
816*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
817*58b9f456SAndroid Build Coastguard Worker    const_iterator end()    const {return __table_.end();}
818*58b9f456SAndroid Build Coastguard Worker
819*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
820*58b9f456SAndroid Build Coastguard Worker    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
821*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
822*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
823*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
824*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
825*58b9f456SAndroid Build Coastguard Worker        void insert(_InputIterator __first, _InputIterator __last);
826*58b9f456SAndroid Build Coastguard Worker
827*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
828*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator __p) {__table_.erase(__p.__i_);}
829*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
830*58b9f456SAndroid Build Coastguard Worker    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
831*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
832*58b9f456SAndroid Build Coastguard Worker    void erase(const_iterator __first, const_iterator __last)
833*58b9f456SAndroid Build Coastguard Worker        {__table_.erase(__first.__i_, __last.__i_);}
834*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
835*58b9f456SAndroid Build Coastguard Worker    void clear() {__table_.clear();}
836*58b9f456SAndroid Build Coastguard Worker
837*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
838*58b9f456SAndroid Build Coastguard Worker    void swap(hash_multimap& __u) {__table_.swap(__u.__table_);}
839*58b9f456SAndroid Build Coastguard Worker
840*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
841*58b9f456SAndroid Build Coastguard Worker    hasher hash_funct() const
842*58b9f456SAndroid Build Coastguard Worker        {return __table_.hash_function().hash_function();}
843*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
844*58b9f456SAndroid Build Coastguard Worker    key_equal key_eq() const
845*58b9f456SAndroid Build Coastguard Worker        {return __table_.key_eq().key_eq();}
846*58b9f456SAndroid Build Coastguard Worker
847*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
848*58b9f456SAndroid Build Coastguard Worker    iterator       find(const key_type& __k)       {return __table_.find(__k);}
849*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
850*58b9f456SAndroid Build Coastguard Worker    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
851*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
852*58b9f456SAndroid Build Coastguard Worker    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
853*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
854*58b9f456SAndroid Build Coastguard Worker    pair<iterator, iterator>             equal_range(const key_type& __k)
855*58b9f456SAndroid Build Coastguard Worker        {return __table_.__equal_range_multi(__k);}
856*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
857*58b9f456SAndroid Build Coastguard Worker    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
858*58b9f456SAndroid Build Coastguard Worker        {return __table_.__equal_range_multi(__k);}
859*58b9f456SAndroid Build Coastguard Worker
860*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
861*58b9f456SAndroid Build Coastguard Worker    size_type bucket_count() const {return __table_.bucket_count();}
862*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
863*58b9f456SAndroid Build Coastguard Worker    size_type max_bucket_count() const {return __table_.max_bucket_count();}
864*58b9f456SAndroid Build Coastguard Worker
865*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
866*58b9f456SAndroid Build Coastguard Worker    size_type elems_in_bucket(size_type __n) const
867*58b9f456SAndroid Build Coastguard Worker        {return __table_.bucket_size(__n);}
868*58b9f456SAndroid Build Coastguard Worker
869*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
870*58b9f456SAndroid Build Coastguard Worker    void resize(size_type __n) {__table_.rehash(__n);}
871*58b9f456SAndroid Build Coastguard Worker};
872*58b9f456SAndroid Build Coastguard Worker
873*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
874*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
875*58b9f456SAndroid Build Coastguard Worker        size_type __n, const hasher& __hf, const key_equal& __eql)
876*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql)
877*58b9f456SAndroid Build Coastguard Worker{
878*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
879*58b9f456SAndroid Build Coastguard Worker}
880*58b9f456SAndroid Build Coastguard Worker
881*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
882*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
883*58b9f456SAndroid Build Coastguard Worker        size_type __n, const hasher& __hf, const key_equal& __eql,
884*58b9f456SAndroid Build Coastguard Worker        const allocator_type& __a)
885*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql, __a)
886*58b9f456SAndroid Build Coastguard Worker{
887*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
888*58b9f456SAndroid Build Coastguard Worker}
889*58b9f456SAndroid Build Coastguard Worker
890*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
891*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
892*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
893*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last)
894*58b9f456SAndroid Build Coastguard Worker{
895*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(193);
896*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
897*58b9f456SAndroid Build Coastguard Worker}
898*58b9f456SAndroid Build Coastguard Worker
899*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
900*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
901*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
902*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last, size_type __n,
903*58b9f456SAndroid Build Coastguard Worker        const hasher& __hf, const key_equal& __eql)
904*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql)
905*58b9f456SAndroid Build Coastguard Worker{
906*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
907*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
908*58b9f456SAndroid Build Coastguard Worker}
909*58b9f456SAndroid Build Coastguard Worker
910*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
911*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
912*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
913*58b9f456SAndroid Build Coastguard Worker        _InputIterator __first, _InputIterator __last, size_type __n,
914*58b9f456SAndroid Build Coastguard Worker        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
915*58b9f456SAndroid Build Coastguard Worker    : __table_(__hf, __eql, __a)
916*58b9f456SAndroid Build Coastguard Worker{
917*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__n);
918*58b9f456SAndroid Build Coastguard Worker    insert(__first, __last);
919*58b9f456SAndroid Build Coastguard Worker}
920*58b9f456SAndroid Build Coastguard Worker
921*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
922*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
923*58b9f456SAndroid Build Coastguard Worker        const hash_multimap& __u)
924*58b9f456SAndroid Build Coastguard Worker    : __table_(__u.__table_)
925*58b9f456SAndroid Build Coastguard Worker{
926*58b9f456SAndroid Build Coastguard Worker    __table_.rehash(__u.bucket_count());
927*58b9f456SAndroid Build Coastguard Worker    insert(__u.begin(), __u.end());
928*58b9f456SAndroid Build Coastguard Worker}
929*58b9f456SAndroid Build Coastguard Worker
930*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
931*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
932*58b9f456SAndroid Build Coastguard Workerinline
933*58b9f456SAndroid Build Coastguard Workervoid
934*58b9f456SAndroid Build Coastguard Workerhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
935*58b9f456SAndroid Build Coastguard Worker                                                            _InputIterator __last)
936*58b9f456SAndroid Build Coastguard Worker{
937*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
938*58b9f456SAndroid Build Coastguard Worker        __table_.__insert_multi(*__first);
939*58b9f456SAndroid Build Coastguard Worker}
940*58b9f456SAndroid Build Coastguard Worker
941*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
942*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
943*58b9f456SAndroid Build Coastguard Workervoid
944*58b9f456SAndroid Build Coastguard Workerswap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
945*58b9f456SAndroid Build Coastguard Worker     hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
946*58b9f456SAndroid Build Coastguard Worker{
947*58b9f456SAndroid Build Coastguard Worker    __x.swap(__y);
948*58b9f456SAndroid Build Coastguard Worker}
949*58b9f456SAndroid Build Coastguard Worker
950*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
951*58b9f456SAndroid Build Coastguard Workerbool
952*58b9f456SAndroid Build Coastguard Workeroperator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
953*58b9f456SAndroid Build Coastguard Worker           const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
954*58b9f456SAndroid Build Coastguard Worker{
955*58b9f456SAndroid Build Coastguard Worker    if (__x.size() != __y.size())
956*58b9f456SAndroid Build Coastguard Worker        return false;
957*58b9f456SAndroid Build Coastguard Worker    typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
958*58b9f456SAndroid Build Coastguard Worker                                                                 const_iterator;
959*58b9f456SAndroid Build Coastguard Worker    typedef pair<const_iterator, const_iterator> _EqRng;
960*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
961*58b9f456SAndroid Build Coastguard Worker    {
962*58b9f456SAndroid Build Coastguard Worker        _EqRng __xeq = __x.equal_range(__i->first);
963*58b9f456SAndroid Build Coastguard Worker        _EqRng __yeq = __y.equal_range(__i->first);
964*58b9f456SAndroid Build Coastguard Worker        if (_VSTD::distance(__xeq.first, __xeq.second) !=
965*58b9f456SAndroid Build Coastguard Worker            _VSTD::distance(__yeq.first, __yeq.second) ||
966*58b9f456SAndroid Build Coastguard Worker                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
967*58b9f456SAndroid Build Coastguard Worker            return false;
968*58b9f456SAndroid Build Coastguard Worker        __i = __xeq.second;
969*58b9f456SAndroid Build Coastguard Worker    }
970*58b9f456SAndroid Build Coastguard Worker    return true;
971*58b9f456SAndroid Build Coastguard Worker}
972*58b9f456SAndroid Build Coastguard Worker
973*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
974*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
975*58b9f456SAndroid Build Coastguard Workerbool
976*58b9f456SAndroid Build Coastguard Workeroperator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
977*58b9f456SAndroid Build Coastguard Worker           const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
978*58b9f456SAndroid Build Coastguard Worker{
979*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
980*58b9f456SAndroid Build Coastguard Worker}
981*58b9f456SAndroid Build Coastguard Worker
982*58b9f456SAndroid Build Coastguard Worker} // __gnu_cxx
983*58b9f456SAndroid Build Coastguard Worker
984*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_HASH_MAP
985