xref: /aosp_15_r20/external/libcxx/include/__hash_table (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
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_TABLE
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP__HASH_TABLE
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker#include <__config>
15*58b9f456SAndroid Build Coastguard Worker#include <initializer_list>
16*58b9f456SAndroid Build Coastguard Worker#include <memory>
17*58b9f456SAndroid Build Coastguard Worker#include <iterator>
18*58b9f456SAndroid Build Coastguard Worker#include <algorithm>
19*58b9f456SAndroid Build Coastguard Worker#include <cmath>
20*58b9f456SAndroid Build Coastguard Worker#include <utility>
21*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
22*58b9f456SAndroid Build Coastguard Worker
23*58b9f456SAndroid Build Coastguard Worker#include <__debug>
24*58b9f456SAndroid Build Coastguard Worker
25*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
27*58b9f456SAndroid Build Coastguard Worker#endif
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
30*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
31*58b9f456SAndroid Build Coastguard Worker
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
34*58b9f456SAndroid Build Coastguard Worker
35*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp>
36*58b9f456SAndroid Build Coastguard Workerstruct __hash_value_type;
37*58b9f456SAndroid Build Coastguard Worker
38*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
39*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
40*58b9f456SAndroid Build Coastguard Workerstruct __is_hash_value_type_imp : false_type {};
41*58b9f456SAndroid Build Coastguard Worker
42*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Value>
43*58b9f456SAndroid Build Coastguard Workerstruct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {};
44*58b9f456SAndroid Build Coastguard Worker
45*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Args>
46*58b9f456SAndroid Build Coastguard Workerstruct __is_hash_value_type : false_type {};
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Workertemplate <class _One>
49*58b9f456SAndroid Build Coastguard Workerstruct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
50*58b9f456SAndroid Build Coastguard Worker#endif
51*58b9f456SAndroid Build Coastguard Worker
52*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS
53*58b9f456SAndroid Build Coastguard Workersize_t __next_prime(size_t __n);
54*58b9f456SAndroid Build Coastguard Worker
55*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
56*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_base
57*58b9f456SAndroid Build Coastguard Worker{
58*58b9f456SAndroid Build Coastguard Worker    typedef typename pointer_traits<_NodePtr>::element_type __node_type;
59*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_base __first_node;
60*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<_NodePtr, __first_node>::type __node_base_pointer;
61*58b9f456SAndroid Build Coastguard Worker    typedef _NodePtr __node_pointer;
62*58b9f456SAndroid Build Coastguard Worker
63*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)
64*58b9f456SAndroid Build Coastguard Worker  typedef __node_base_pointer __next_pointer;
65*58b9f456SAndroid Build Coastguard Worker#else
66*58b9f456SAndroid Build Coastguard Worker  typedef typename conditional<
67*58b9f456SAndroid Build Coastguard Worker      is_pointer<__node_pointer>::value,
68*58b9f456SAndroid Build Coastguard Worker      __node_base_pointer,
69*58b9f456SAndroid Build Coastguard Worker      __node_pointer>::type   __next_pointer;
70*58b9f456SAndroid Build Coastguard Worker#endif
71*58b9f456SAndroid Build Coastguard Worker
72*58b9f456SAndroid Build Coastguard Worker    __next_pointer    __next_;
73*58b9f456SAndroid Build Coastguard Worker
74*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
75*58b9f456SAndroid Build Coastguard Worker    __next_pointer __ptr() _NOEXCEPT {
76*58b9f456SAndroid Build Coastguard Worker        return static_cast<__next_pointer>(
77*58b9f456SAndroid Build Coastguard Worker            pointer_traits<__node_base_pointer>::pointer_to(*this));
78*58b9f456SAndroid Build Coastguard Worker    }
79*58b9f456SAndroid Build Coastguard Worker
80*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
81*58b9f456SAndroid Build Coastguard Worker    __node_pointer __upcast() _NOEXCEPT {
82*58b9f456SAndroid Build Coastguard Worker        return static_cast<__node_pointer>(
83*58b9f456SAndroid Build Coastguard Worker            pointer_traits<__node_base_pointer>::pointer_to(*this));
84*58b9f456SAndroid Build Coastguard Worker    }
85*58b9f456SAndroid Build Coastguard Worker
86*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
87*58b9f456SAndroid Build Coastguard Worker    size_t __hash() const _NOEXCEPT {
88*58b9f456SAndroid Build Coastguard Worker        return static_cast<__node_type const&>(*this).__hash_;
89*58b9f456SAndroid Build Coastguard Worker    }
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {}
92*58b9f456SAndroid Build Coastguard Worker};
93*58b9f456SAndroid Build Coastguard Worker
94*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
95*58b9f456SAndroid Build Coastguard Workerstruct __hash_node
96*58b9f456SAndroid Build Coastguard Worker    : public __hash_node_base
97*58b9f456SAndroid Build Coastguard Worker             <
98*58b9f456SAndroid Build Coastguard Worker                 typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
99*58b9f456SAndroid Build Coastguard Worker             >
100*58b9f456SAndroid Build Coastguard Worker{
101*58b9f456SAndroid Build Coastguard Worker    typedef _Tp __node_value_type;
102*58b9f456SAndroid Build Coastguard Worker
103*58b9f456SAndroid Build Coastguard Worker    size_t            __hash_;
104*58b9f456SAndroid Build Coastguard Worker    __node_value_type __value_;
105*58b9f456SAndroid Build Coastguard Worker};
106*58b9f456SAndroid Build Coastguard Worker
107*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
108*58b9f456SAndroid Build Coastguard Workerbool
109*58b9f456SAndroid Build Coastguard Worker__is_hash_power2(size_t __bc)
110*58b9f456SAndroid Build Coastguard Worker{
111*58b9f456SAndroid Build Coastguard Worker    return __bc > 2 && !(__bc & (__bc - 1));
112*58b9f456SAndroid Build Coastguard Worker}
113*58b9f456SAndroid Build Coastguard Worker
114*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
115*58b9f456SAndroid Build Coastguard Workersize_t
116*58b9f456SAndroid Build Coastguard Worker__constrain_hash(size_t __h, size_t __bc)
117*58b9f456SAndroid Build Coastguard Worker{
118*58b9f456SAndroid Build Coastguard Worker    return !(__bc & (__bc - 1)) ? __h & (__bc - 1) :
119*58b9f456SAndroid Build Coastguard Worker        (__h < __bc ? __h : __h % __bc);
120*58b9f456SAndroid Build Coastguard Worker}
121*58b9f456SAndroid Build Coastguard Worker
122*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
123*58b9f456SAndroid Build Coastguard Workersize_t
124*58b9f456SAndroid Build Coastguard Worker__next_hash_pow2(size_t __n)
125*58b9f456SAndroid Build Coastguard Worker{
126*58b9f456SAndroid Build Coastguard Worker    return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1)));
127*58b9f456SAndroid Build Coastguard Worker}
128*58b9f456SAndroid Build Coastguard Worker
129*58b9f456SAndroid Build Coastguard Worker
130*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table;
131*58b9f456SAndroid Build Coastguard Worker
132*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>      class _LIBCPP_TEMPLATE_VIS __hash_iterator;
133*58b9f456SAndroid Build Coastguard Workertemplate <class _ConstNodePtr> class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
134*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>      class _LIBCPP_TEMPLATE_VIS __hash_local_iterator;
135*58b9f456SAndroid Build Coastguard Workertemplate <class _ConstNodePtr> class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
136*58b9f456SAndroid Build Coastguard Workertemplate <class _HashIterator> class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
137*58b9f456SAndroid Build Coastguard Workertemplate <class _HashIterator> class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
138*58b9f456SAndroid Build Coastguard Worker
139*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
140*58b9f456SAndroid Build Coastguard Workerstruct __hash_key_value_types {
141*58b9f456SAndroid Build Coastguard Worker  static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
142*58b9f456SAndroid Build Coastguard Worker  typedef _Tp key_type;
143*58b9f456SAndroid Build Coastguard Worker  typedef _Tp __node_value_type;
144*58b9f456SAndroid Build Coastguard Worker  typedef _Tp __container_value_type;
145*58b9f456SAndroid Build Coastguard Worker  static const bool __is_map = false;
146*58b9f456SAndroid Build Coastguard Worker
147*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
148*58b9f456SAndroid Build Coastguard Worker  static key_type const& __get_key(_Tp const& __v) {
149*58b9f456SAndroid Build Coastguard Worker    return __v;
150*58b9f456SAndroid Build Coastguard Worker  }
151*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
152*58b9f456SAndroid Build Coastguard Worker  static __container_value_type const& __get_value(__node_value_type const& __v) {
153*58b9f456SAndroid Build Coastguard Worker    return __v;
154*58b9f456SAndroid Build Coastguard Worker  }
155*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
156*58b9f456SAndroid Build Coastguard Worker  static __container_value_type* __get_ptr(__node_value_type& __n) {
157*58b9f456SAndroid Build Coastguard Worker    return _VSTD::addressof(__n);
158*58b9f456SAndroid Build Coastguard Worker  }
159*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
160*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
161*58b9f456SAndroid Build Coastguard Worker  static __container_value_type&& __move(__node_value_type& __v) {
162*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__v);
163*58b9f456SAndroid Build Coastguard Worker  }
164*58b9f456SAndroid Build Coastguard Worker#endif
165*58b9f456SAndroid Build Coastguard Worker};
166*58b9f456SAndroid Build Coastguard Worker
167*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Tp>
168*58b9f456SAndroid Build Coastguard Workerstruct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
169*58b9f456SAndroid Build Coastguard Worker  typedef _Key                                         key_type;
170*58b9f456SAndroid Build Coastguard Worker  typedef _Tp                                          mapped_type;
171*58b9f456SAndroid Build Coastguard Worker  typedef __hash_value_type<_Key, _Tp>                 __node_value_type;
172*58b9f456SAndroid Build Coastguard Worker  typedef pair<const _Key, _Tp>                        __container_value_type;
173*58b9f456SAndroid Build Coastguard Worker  typedef __container_value_type                       __map_value_type;
174*58b9f456SAndroid Build Coastguard Worker  static const bool __is_map = true;
175*58b9f456SAndroid Build Coastguard Worker
176*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
177*58b9f456SAndroid Build Coastguard Worker  static key_type const& __get_key(__container_value_type const& __v) {
178*58b9f456SAndroid Build Coastguard Worker    return __v.first;
179*58b9f456SAndroid Build Coastguard Worker  }
180*58b9f456SAndroid Build Coastguard Worker
181*58b9f456SAndroid Build Coastguard Worker  template <class _Up>
182*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
183*58b9f456SAndroid Build Coastguard Worker  static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
184*58b9f456SAndroid Build Coastguard Worker      __container_value_type const&>::type
185*58b9f456SAndroid Build Coastguard Worker  __get_value(_Up& __t) {
186*58b9f456SAndroid Build Coastguard Worker    return __t.__get_value();
187*58b9f456SAndroid Build Coastguard Worker  }
188*58b9f456SAndroid Build Coastguard Worker
189*58b9f456SAndroid Build Coastguard Worker  template <class _Up>
190*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
191*58b9f456SAndroid Build Coastguard Worker  static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value,
192*58b9f456SAndroid Build Coastguard Worker      __container_value_type const&>::type
193*58b9f456SAndroid Build Coastguard Worker  __get_value(_Up& __t) {
194*58b9f456SAndroid Build Coastguard Worker    return __t;
195*58b9f456SAndroid Build Coastguard Worker  }
196*58b9f456SAndroid Build Coastguard Worker
197*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
198*58b9f456SAndroid Build Coastguard Worker  static __container_value_type* __get_ptr(__node_value_type& __n) {
199*58b9f456SAndroid Build Coastguard Worker    return _VSTD::addressof(__n.__get_value());
200*58b9f456SAndroid Build Coastguard Worker  }
201*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
202*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
203*58b9f456SAndroid Build Coastguard Worker  static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
204*58b9f456SAndroid Build Coastguard Worker    return __v.__move();
205*58b9f456SAndroid Build Coastguard Worker  }
206*58b9f456SAndroid Build Coastguard Worker#endif
207*58b9f456SAndroid Build Coastguard Worker
208*58b9f456SAndroid Build Coastguard Worker};
209*58b9f456SAndroid Build Coastguard Worker
210*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _AllocPtr, class _KVTypes = __hash_key_value_types<_Tp>,
211*58b9f456SAndroid Build Coastguard Worker          bool = _KVTypes::__is_map>
212*58b9f456SAndroid Build Coastguard Workerstruct __hash_map_pointer_types {};
213*58b9f456SAndroid Build Coastguard Worker
214*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _AllocPtr, class _KVTypes>
215*58b9f456SAndroid Build Coastguard Workerstruct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
216*58b9f456SAndroid Build Coastguard Worker  typedef typename _KVTypes::__map_value_type   _Mv;
217*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
218*58b9f456SAndroid Build Coastguard Worker                                                       __map_value_type_pointer;
219*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
220*58b9f456SAndroid Build Coastguard Worker                                                 __const_map_value_type_pointer;
221*58b9f456SAndroid Build Coastguard Worker};
222*58b9f456SAndroid Build Coastguard Worker
223*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
224*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types;
225*58b9f456SAndroid Build Coastguard Worker
226*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr, class _Tp, class _VoidPtr>
227*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> >
228*58b9f456SAndroid Build Coastguard Worker    : public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr>
229*58b9f456SAndroid Build Coastguard Worker
230*58b9f456SAndroid Build Coastguard Worker{
231*58b9f456SAndroid Build Coastguard Worker  typedef __hash_key_value_types<_Tp>           __base;
232*58b9f456SAndroid Build Coastguard Worker
233*58b9f456SAndroid Build Coastguard Workerpublic:
234*58b9f456SAndroid Build Coastguard Worker  typedef ptrdiff_t difference_type;
235*58b9f456SAndroid Build Coastguard Worker  typedef size_t size_type;
236*58b9f456SAndroid Build Coastguard Worker
237*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_NodePtr, void>::type       __void_pointer;
238*58b9f456SAndroid Build Coastguard Worker
239*58b9f456SAndroid Build Coastguard Worker  typedef typename pointer_traits<_NodePtr>::element_type       __node_type;
240*58b9f456SAndroid Build Coastguard Worker  typedef _NodePtr                                              __node_pointer;
241*58b9f456SAndroid Build Coastguard Worker
242*58b9f456SAndroid Build Coastguard Worker  typedef __hash_node_base<__node_pointer>                      __node_base_type;
243*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type
244*58b9f456SAndroid Build Coastguard Worker                                                             __node_base_pointer;
245*58b9f456SAndroid Build Coastguard Worker
246*58b9f456SAndroid Build Coastguard Worker  typedef typename __node_base_type::__next_pointer          __next_pointer;
247*58b9f456SAndroid Build Coastguard Worker
248*58b9f456SAndroid Build Coastguard Worker  typedef _Tp                                                 __node_value_type;
249*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
250*58b9f456SAndroid Build Coastguard Worker                                                      __node_value_type_pointer;
251*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
252*58b9f456SAndroid Build Coastguard Worker                                                __const_node_value_type_pointer;
253*58b9f456SAndroid Build Coastguard Worker
254*58b9f456SAndroid Build Coastguard Workerprivate:
255*58b9f456SAndroid Build Coastguard Worker    static_assert(!is_const<__node_type>::value,
256*58b9f456SAndroid Build Coastguard Worker                "_NodePtr should never be a pointer to const");
257*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
258*58b9f456SAndroid Build Coastguard Worker                  "_VoidPtr does not point to unqualified void type");
259*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
260*58b9f456SAndroid Build Coastguard Worker                          _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
261*58b9f456SAndroid Build Coastguard Worker};
262*58b9f456SAndroid Build Coastguard Worker
263*58b9f456SAndroid Build Coastguard Workertemplate <class _HashIterator>
264*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types_from_iterator;
265*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
266*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
267*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
268*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
269*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
270*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
271*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
272*58b9f456SAndroid Build Coastguard Workerstruct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
273*58b9f456SAndroid Build Coastguard Worker
274*58b9f456SAndroid Build Coastguard Worker
275*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeValueTp, class _VoidPtr>
276*58b9f456SAndroid Build Coastguard Workerstruct __make_hash_node_types {
277*58b9f456SAndroid Build Coastguard Worker  typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
278*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;
279*58b9f456SAndroid Build Coastguard Worker  typedef __hash_node_types<_NodePtr> type;
280*58b9f456SAndroid Build Coastguard Worker};
281*58b9f456SAndroid Build Coastguard Worker
282*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
283*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_iterator
284*58b9f456SAndroid Build Coastguard Worker{
285*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_types<_NodePtr> _NodeTypes;
286*58b9f456SAndroid Build Coastguard Worker    typedef _NodePtr                            __node_pointer;
287*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__next_pointer __next_pointer;
288*58b9f456SAndroid Build Coastguard Worker
289*58b9f456SAndroid Build Coastguard Worker    __next_pointer            __node_;
290*58b9f456SAndroid Build Coastguard Worker
291*58b9f456SAndroid Build Coastguard Workerpublic:
292*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                           iterator_category;
293*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type         value_type;
294*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::difference_type           difference_type;
295*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                    reference;
296*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type_pointer pointer;
297*58b9f456SAndroid Build Coastguard Worker
298*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) {
299*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
300*58b9f456SAndroid Build Coastguard Worker    }
301*58b9f456SAndroid Build Coastguard Worker
302*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
303*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
304*58b9f456SAndroid Build Coastguard Worker    __hash_iterator(const __hash_iterator& __i)
305*58b9f456SAndroid Build Coastguard Worker        : __node_(__i.__node_)
306*58b9f456SAndroid Build Coastguard Worker    {
307*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__i);
308*58b9f456SAndroid Build Coastguard Worker    }
309*58b9f456SAndroid Build Coastguard Worker
310*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
311*58b9f456SAndroid Build Coastguard Worker    ~__hash_iterator()
312*58b9f456SAndroid Build Coastguard Worker    {
313*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
314*58b9f456SAndroid Build Coastguard Worker    }
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
317*58b9f456SAndroid Build Coastguard Worker    __hash_iterator& operator=(const __hash_iterator& __i)
318*58b9f456SAndroid Build Coastguard Worker    {
319*58b9f456SAndroid Build Coastguard Worker        if (this != &__i)
320*58b9f456SAndroid Build Coastguard Worker        {
321*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__i);
322*58b9f456SAndroid Build Coastguard Worker            __node_ = __i.__node_;
323*58b9f456SAndroid Build Coastguard Worker        }
324*58b9f456SAndroid Build Coastguard Worker        return *this;
325*58b9f456SAndroid Build Coastguard Worker    }
326*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
327*58b9f456SAndroid Build Coastguard Worker
328*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
329*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {
330*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
331*58b9f456SAndroid Build Coastguard Worker                             "Attempted to dereference a non-dereferenceable unordered container iterator");
332*58b9f456SAndroid Build Coastguard Worker        return __node_->__upcast()->__value_;
333*58b9f456SAndroid Build Coastguard Worker    }
334*58b9f456SAndroid Build Coastguard Worker
335*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
336*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const {
337*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
338*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container iterator");
339*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
340*58b9f456SAndroid Build Coastguard Worker    }
341*58b9f456SAndroid Build Coastguard Worker
342*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
343*58b9f456SAndroid Build Coastguard Worker    __hash_iterator& operator++() {
344*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
345*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable unordered container iterator");
346*58b9f456SAndroid Build Coastguard Worker        __node_ = __node_->__next_;
347*58b9f456SAndroid Build Coastguard Worker        return *this;
348*58b9f456SAndroid Build Coastguard Worker    }
349*58b9f456SAndroid Build Coastguard Worker
350*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
351*58b9f456SAndroid Build Coastguard Worker    __hash_iterator operator++(int)
352*58b9f456SAndroid Build Coastguard Worker    {
353*58b9f456SAndroid Build Coastguard Worker        __hash_iterator __t(*this);
354*58b9f456SAndroid Build Coastguard Worker        ++(*this);
355*58b9f456SAndroid Build Coastguard Worker        return __t;
356*58b9f456SAndroid Build Coastguard Worker    }
357*58b9f456SAndroid Build Coastguard Worker
358*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
359*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_iterator& __x, const __hash_iterator& __y)
360*58b9f456SAndroid Build Coastguard Worker    {
361*58b9f456SAndroid Build Coastguard Worker        return __x.__node_ == __y.__node_;
362*58b9f456SAndroid Build Coastguard Worker    }
363*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
364*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y)
365*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
366*58b9f456SAndroid Build Coastguard Worker
367*58b9f456SAndroid Build Coastguard Workerprivate:
368*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
369*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
370*58b9f456SAndroid Build Coastguard Worker    __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
371*58b9f456SAndroid Build Coastguard Worker        : __node_(__node)
372*58b9f456SAndroid Build Coastguard Worker        {
373*58b9f456SAndroid Build Coastguard Worker            __get_db()->__insert_ic(this, __c);
374*58b9f456SAndroid Build Coastguard Worker        }
375*58b9f456SAndroid Build Coastguard Worker#else
376*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
377*58b9f456SAndroid Build Coastguard Worker    __hash_iterator(__next_pointer __node) _NOEXCEPT
378*58b9f456SAndroid Build Coastguard Worker        : __node_(__node)
379*58b9f456SAndroid Build Coastguard Worker        {}
380*58b9f456SAndroid Build Coastguard Worker#endif
381*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class> friend class __hash_table;
382*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
383*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
384*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
385*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
386*58b9f456SAndroid Build Coastguard Worker};
387*58b9f456SAndroid Build Coastguard Worker
388*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
389*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_const_iterator
390*58b9f456SAndroid Build Coastguard Worker{
391*58b9f456SAndroid Build Coastguard Worker    static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");
392*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_types<_NodePtr> _NodeTypes;
393*58b9f456SAndroid Build Coastguard Worker    typedef _NodePtr                            __node_pointer;
394*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__next_pointer __next_pointer;
395*58b9f456SAndroid Build Coastguard Worker
396*58b9f456SAndroid Build Coastguard Worker    __next_pointer __node_;
397*58b9f456SAndroid Build Coastguard Worker
398*58b9f456SAndroid Build Coastguard Workerpublic:
399*58b9f456SAndroid Build Coastguard Worker    typedef __hash_iterator<_NodePtr> __non_const_iterator;
400*58b9f456SAndroid Build Coastguard Worker
401*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                                 iterator_category;
402*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type               value_type;
403*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::difference_type                 difference_type;
404*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                                    reference;
405*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
406*58b9f456SAndroid Build Coastguard Worker
407*58b9f456SAndroid Build Coastguard Worker
408*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {
409*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
410*58b9f456SAndroid Build Coastguard Worker    }
411*58b9f456SAndroid Build Coastguard Worker
412*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
413*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
414*58b9f456SAndroid Build Coastguard Worker        : __node_(__x.__node_)
415*58b9f456SAndroid Build Coastguard Worker    {
416*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
417*58b9f456SAndroid Build Coastguard Worker    }
418*58b9f456SAndroid Build Coastguard Worker
419*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
420*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
421*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator(const __hash_const_iterator& __i)
422*58b9f456SAndroid Build Coastguard Worker        : __node_(__i.__node_)
423*58b9f456SAndroid Build Coastguard Worker    {
424*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__i);
425*58b9f456SAndroid Build Coastguard Worker    }
426*58b9f456SAndroid Build Coastguard Worker
427*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
428*58b9f456SAndroid Build Coastguard Worker    ~__hash_const_iterator()
429*58b9f456SAndroid Build Coastguard Worker    {
430*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
431*58b9f456SAndroid Build Coastguard Worker    }
432*58b9f456SAndroid Build Coastguard Worker
433*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
434*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator& operator=(const __hash_const_iterator& __i)
435*58b9f456SAndroid Build Coastguard Worker    {
436*58b9f456SAndroid Build Coastguard Worker        if (this != &__i)
437*58b9f456SAndroid Build Coastguard Worker        {
438*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__i);
439*58b9f456SAndroid Build Coastguard Worker            __node_ = __i.__node_;
440*58b9f456SAndroid Build Coastguard Worker        }
441*58b9f456SAndroid Build Coastguard Worker        return *this;
442*58b9f456SAndroid Build Coastguard Worker    }
443*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
444*58b9f456SAndroid Build Coastguard Worker
445*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
446*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {
447*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
448*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container const_iterator");
449*58b9f456SAndroid Build Coastguard Worker        return __node_->__upcast()->__value_;
450*58b9f456SAndroid Build Coastguard Worker    }
451*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
452*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const {
453*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
454*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container const_iterator");
455*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
456*58b9f456SAndroid Build Coastguard Worker    }
457*58b9f456SAndroid Build Coastguard Worker
458*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
459*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator& operator++() {
460*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
461*58b9f456SAndroid Build Coastguard Worker                             "Attempted to increment non-incrementable unordered container const_iterator");
462*58b9f456SAndroid Build Coastguard Worker        __node_ = __node_->__next_;
463*58b9f456SAndroid Build Coastguard Worker        return *this;
464*58b9f456SAndroid Build Coastguard Worker    }
465*58b9f456SAndroid Build Coastguard Worker
466*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
467*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator operator++(int)
468*58b9f456SAndroid Build Coastguard Worker    {
469*58b9f456SAndroid Build Coastguard Worker        __hash_const_iterator __t(*this);
470*58b9f456SAndroid Build Coastguard Worker        ++(*this);
471*58b9f456SAndroid Build Coastguard Worker        return __t;
472*58b9f456SAndroid Build Coastguard Worker    }
473*58b9f456SAndroid Build Coastguard Worker
474*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
475*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
476*58b9f456SAndroid Build Coastguard Worker    {
477*58b9f456SAndroid Build Coastguard Worker        return __x.__node_ == __y.__node_;
478*58b9f456SAndroid Build Coastguard Worker    }
479*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
480*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
481*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
482*58b9f456SAndroid Build Coastguard Worker
483*58b9f456SAndroid Build Coastguard Workerprivate:
484*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
485*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
486*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT
487*58b9f456SAndroid Build Coastguard Worker        : __node_(__node)
488*58b9f456SAndroid Build Coastguard Worker        {
489*58b9f456SAndroid Build Coastguard Worker            __get_db()->__insert_ic(this, __c);
490*58b9f456SAndroid Build Coastguard Worker        }
491*58b9f456SAndroid Build Coastguard Worker#else
492*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
493*58b9f456SAndroid Build Coastguard Worker    __hash_const_iterator(__next_pointer __node) _NOEXCEPT
494*58b9f456SAndroid Build Coastguard Worker        : __node_(__node)
495*58b9f456SAndroid Build Coastguard Worker        {}
496*58b9f456SAndroid Build Coastguard Worker#endif
497*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class> friend class __hash_table;
498*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
499*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
500*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
501*58b9f456SAndroid Build Coastguard Worker};
502*58b9f456SAndroid Build Coastguard Worker
503*58b9f456SAndroid Build Coastguard Workertemplate <class _NodePtr>
504*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_local_iterator
505*58b9f456SAndroid Build Coastguard Worker{
506*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_types<_NodePtr> _NodeTypes;
507*58b9f456SAndroid Build Coastguard Worker    typedef _NodePtr                            __node_pointer;
508*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__next_pointer __next_pointer;
509*58b9f456SAndroid Build Coastguard Worker
510*58b9f456SAndroid Build Coastguard Worker    __next_pointer         __node_;
511*58b9f456SAndroid Build Coastguard Worker    size_t                 __bucket_;
512*58b9f456SAndroid Build Coastguard Worker    size_t                 __bucket_count_;
513*58b9f456SAndroid Build Coastguard Worker
514*58b9f456SAndroid Build Coastguard Workerpublic:
515*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                                iterator_category;
516*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type              value_type;
517*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::difference_type                difference_type;
518*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                         reference;
519*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type_pointer      pointer;
520*58b9f456SAndroid Build Coastguard Worker
521*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {
522*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
523*58b9f456SAndroid Build Coastguard Worker    }
524*58b9f456SAndroid Build Coastguard Worker
525*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
526*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
527*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator(const __hash_local_iterator& __i)
528*58b9f456SAndroid Build Coastguard Worker        : __node_(__i.__node_),
529*58b9f456SAndroid Build Coastguard Worker          __bucket_(__i.__bucket_),
530*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__i.__bucket_count_)
531*58b9f456SAndroid Build Coastguard Worker    {
532*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__i);
533*58b9f456SAndroid Build Coastguard Worker    }
534*58b9f456SAndroid Build Coastguard Worker
535*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
536*58b9f456SAndroid Build Coastguard Worker    ~__hash_local_iterator()
537*58b9f456SAndroid Build Coastguard Worker    {
538*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
539*58b9f456SAndroid Build Coastguard Worker    }
540*58b9f456SAndroid Build Coastguard Worker
541*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
542*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator& operator=(const __hash_local_iterator& __i)
543*58b9f456SAndroid Build Coastguard Worker    {
544*58b9f456SAndroid Build Coastguard Worker        if (this != &__i)
545*58b9f456SAndroid Build Coastguard Worker        {
546*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__i);
547*58b9f456SAndroid Build Coastguard Worker            __node_ = __i.__node_;
548*58b9f456SAndroid Build Coastguard Worker            __bucket_ = __i.__bucket_;
549*58b9f456SAndroid Build Coastguard Worker            __bucket_count_ = __i.__bucket_count_;
550*58b9f456SAndroid Build Coastguard Worker        }
551*58b9f456SAndroid Build Coastguard Worker        return *this;
552*58b9f456SAndroid Build Coastguard Worker    }
553*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
554*58b9f456SAndroid Build Coastguard Worker
555*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
556*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {
557*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
558*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container local_iterator");
559*58b9f456SAndroid Build Coastguard Worker        return __node_->__upcast()->__value_;
560*58b9f456SAndroid Build Coastguard Worker    }
561*58b9f456SAndroid Build Coastguard Worker
562*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
563*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const {
564*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
565*58b9f456SAndroid Build Coastguard Worker                             "Attempted to dereference a non-dereferenceable unordered container local_iterator");
566*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
567*58b9f456SAndroid Build Coastguard Worker    }
568*58b9f456SAndroid Build Coastguard Worker
569*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
570*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator& operator++() {
571*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
572*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable unordered container local_iterator");
573*58b9f456SAndroid Build Coastguard Worker        __node_ = __node_->__next_;
574*58b9f456SAndroid Build Coastguard Worker        if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
575*58b9f456SAndroid Build Coastguard Worker            __node_ = nullptr;
576*58b9f456SAndroid Build Coastguard Worker        return *this;
577*58b9f456SAndroid Build Coastguard Worker    }
578*58b9f456SAndroid Build Coastguard Worker
579*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
580*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator operator++(int)
581*58b9f456SAndroid Build Coastguard Worker    {
582*58b9f456SAndroid Build Coastguard Worker        __hash_local_iterator __t(*this);
583*58b9f456SAndroid Build Coastguard Worker        ++(*this);
584*58b9f456SAndroid Build Coastguard Worker        return __t;
585*58b9f456SAndroid Build Coastguard Worker    }
586*58b9f456SAndroid Build Coastguard Worker
587*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
588*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
589*58b9f456SAndroid Build Coastguard Worker    {
590*58b9f456SAndroid Build Coastguard Worker        return __x.__node_ == __y.__node_;
591*58b9f456SAndroid Build Coastguard Worker    }
592*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
593*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
594*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
595*58b9f456SAndroid Build Coastguard Worker
596*58b9f456SAndroid Build Coastguard Workerprivate:
597*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
598*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
599*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator(__next_pointer __node, size_t __bucket,
600*58b9f456SAndroid Build Coastguard Worker                          size_t __bucket_count, const void* __c) _NOEXCEPT
601*58b9f456SAndroid Build Coastguard Worker        : __node_(__node),
602*58b9f456SAndroid Build Coastguard Worker          __bucket_(__bucket),
603*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__bucket_count)
604*58b9f456SAndroid Build Coastguard Worker        {
605*58b9f456SAndroid Build Coastguard Worker            __get_db()->__insert_ic(this, __c);
606*58b9f456SAndroid Build Coastguard Worker            if (__node_ != nullptr)
607*58b9f456SAndroid Build Coastguard Worker                __node_ = __node_->__next_;
608*58b9f456SAndroid Build Coastguard Worker        }
609*58b9f456SAndroid Build Coastguard Worker#else
610*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
611*58b9f456SAndroid Build Coastguard Worker    __hash_local_iterator(__next_pointer __node, size_t __bucket,
612*58b9f456SAndroid Build Coastguard Worker                          size_t __bucket_count) _NOEXCEPT
613*58b9f456SAndroid Build Coastguard Worker        : __node_(__node),
614*58b9f456SAndroid Build Coastguard Worker          __bucket_(__bucket),
615*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__bucket_count)
616*58b9f456SAndroid Build Coastguard Worker        {
617*58b9f456SAndroid Build Coastguard Worker            if (__node_ != nullptr)
618*58b9f456SAndroid Build Coastguard Worker                __node_ = __node_->__next_;
619*58b9f456SAndroid Build Coastguard Worker        }
620*58b9f456SAndroid Build Coastguard Worker#endif
621*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class> friend class __hash_table;
622*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
623*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;
624*58b9f456SAndroid Build Coastguard Worker};
625*58b9f456SAndroid Build Coastguard Worker
626*58b9f456SAndroid Build Coastguard Workertemplate <class _ConstNodePtr>
627*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator
628*58b9f456SAndroid Build Coastguard Worker{
629*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_types<_ConstNodePtr> _NodeTypes;
630*58b9f456SAndroid Build Coastguard Worker    typedef _ConstNodePtr                       __node_pointer;
631*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__next_pointer __next_pointer;
632*58b9f456SAndroid Build Coastguard Worker
633*58b9f456SAndroid Build Coastguard Worker    __next_pointer         __node_;
634*58b9f456SAndroid Build Coastguard Worker    size_t                 __bucket_;
635*58b9f456SAndroid Build Coastguard Worker    size_t                 __bucket_count_;
636*58b9f456SAndroid Build Coastguard Worker
637*58b9f456SAndroid Build Coastguard Worker    typedef pointer_traits<__node_pointer>          __pointer_traits;
638*58b9f456SAndroid Build Coastguard Worker    typedef typename __pointer_traits::element_type __node;
639*58b9f456SAndroid Build Coastguard Worker    typedef typename remove_const<__node>::type     __non_const_node;
640*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
641*58b9f456SAndroid Build Coastguard Worker        __non_const_node_pointer;
642*58b9f456SAndroid Build Coastguard Workerpublic:
643*58b9f456SAndroid Build Coastguard Worker    typedef __hash_local_iterator<__non_const_node_pointer>
644*58b9f456SAndroid Build Coastguard Worker                                                    __non_const_iterator;
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Worker    typedef forward_iterator_tag                                 iterator_category;
647*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type               value_type;
648*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::difference_type                 difference_type;
649*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                                    reference;
650*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
651*58b9f456SAndroid Build Coastguard Worker
652*58b9f456SAndroid Build Coastguard Worker
653*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {
654*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
655*58b9f456SAndroid Build Coastguard Worker    }
656*58b9f456SAndroid Build Coastguard Worker
657*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
658*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT
659*58b9f456SAndroid Build Coastguard Worker        : __node_(__x.__node_),
660*58b9f456SAndroid Build Coastguard Worker          __bucket_(__x.__bucket_),
661*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__x.__bucket_count_)
662*58b9f456SAndroid Build Coastguard Worker    {
663*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x));
664*58b9f456SAndroid Build Coastguard Worker    }
665*58b9f456SAndroid Build Coastguard Worker
666*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
667*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
668*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator(const __hash_const_local_iterator& __i)
669*58b9f456SAndroid Build Coastguard Worker        : __node_(__i.__node_),
670*58b9f456SAndroid Build Coastguard Worker          __bucket_(__i.__bucket_),
671*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__i.__bucket_count_)
672*58b9f456SAndroid Build Coastguard Worker    {
673*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__i);
674*58b9f456SAndroid Build Coastguard Worker    }
675*58b9f456SAndroid Build Coastguard Worker
676*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
677*58b9f456SAndroid Build Coastguard Worker    ~__hash_const_local_iterator()
678*58b9f456SAndroid Build Coastguard Worker    {
679*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
680*58b9f456SAndroid Build Coastguard Worker    }
681*58b9f456SAndroid Build Coastguard Worker
682*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
683*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i)
684*58b9f456SAndroid Build Coastguard Worker    {
685*58b9f456SAndroid Build Coastguard Worker        if (this != &__i)
686*58b9f456SAndroid Build Coastguard Worker        {
687*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__i);
688*58b9f456SAndroid Build Coastguard Worker            __node_ = __i.__node_;
689*58b9f456SAndroid Build Coastguard Worker            __bucket_ = __i.__bucket_;
690*58b9f456SAndroid Build Coastguard Worker            __bucket_count_ = __i.__bucket_count_;
691*58b9f456SAndroid Build Coastguard Worker        }
692*58b9f456SAndroid Build Coastguard Worker        return *this;
693*58b9f456SAndroid Build Coastguard Worker    }
694*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
695*58b9f456SAndroid Build Coastguard Worker
696*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
697*58b9f456SAndroid Build Coastguard Worker    reference operator*() const {
698*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
699*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
700*58b9f456SAndroid Build Coastguard Worker        return __node_->__upcast()->__value_;
701*58b9f456SAndroid Build Coastguard Worker    }
702*58b9f456SAndroid Build Coastguard Worker
703*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
704*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const {
705*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
706*58b9f456SAndroid Build Coastguard Worker                           "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
707*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_);
708*58b9f456SAndroid Build Coastguard Worker    }
709*58b9f456SAndroid Build Coastguard Worker
710*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
711*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator& operator++() {
712*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
713*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable unordered container const_local_iterator");
714*58b9f456SAndroid Build Coastguard Worker        __node_ = __node_->__next_;
715*58b9f456SAndroid Build Coastguard Worker        if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
716*58b9f456SAndroid Build Coastguard Worker            __node_ = nullptr;
717*58b9f456SAndroid Build Coastguard Worker        return *this;
718*58b9f456SAndroid Build Coastguard Worker    }
719*58b9f456SAndroid Build Coastguard Worker
720*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
721*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator operator++(int)
722*58b9f456SAndroid Build Coastguard Worker    {
723*58b9f456SAndroid Build Coastguard Worker        __hash_const_local_iterator __t(*this);
724*58b9f456SAndroid Build Coastguard Worker        ++(*this);
725*58b9f456SAndroid Build Coastguard Worker        return __t;
726*58b9f456SAndroid Build Coastguard Worker    }
727*58b9f456SAndroid Build Coastguard Worker
728*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
729*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
730*58b9f456SAndroid Build Coastguard Worker    {
731*58b9f456SAndroid Build Coastguard Worker        return __x.__node_ == __y.__node_;
732*58b9f456SAndroid Build Coastguard Worker    }
733*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
734*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
735*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
736*58b9f456SAndroid Build Coastguard Worker
737*58b9f456SAndroid Build Coastguard Workerprivate:
738*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
739*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
740*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
741*58b9f456SAndroid Build Coastguard Worker                                size_t __bucket_count, const void* __c) _NOEXCEPT
742*58b9f456SAndroid Build Coastguard Worker        : __node_(__node),
743*58b9f456SAndroid Build Coastguard Worker          __bucket_(__bucket),
744*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__bucket_count)
745*58b9f456SAndroid Build Coastguard Worker        {
746*58b9f456SAndroid Build Coastguard Worker            __get_db()->__insert_ic(this, __c);
747*58b9f456SAndroid Build Coastguard Worker            if (__node_ != nullptr)
748*58b9f456SAndroid Build Coastguard Worker                __node_ = __node_->__next_;
749*58b9f456SAndroid Build Coastguard Worker        }
750*58b9f456SAndroid Build Coastguard Worker#else
751*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
752*58b9f456SAndroid Build Coastguard Worker    __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
753*58b9f456SAndroid Build Coastguard Worker                                size_t __bucket_count) _NOEXCEPT
754*58b9f456SAndroid Build Coastguard Worker        : __node_(__node),
755*58b9f456SAndroid Build Coastguard Worker          __bucket_(__bucket),
756*58b9f456SAndroid Build Coastguard Worker          __bucket_count_(__bucket_count)
757*58b9f456SAndroid Build Coastguard Worker        {
758*58b9f456SAndroid Build Coastguard Worker            if (__node_ != nullptr)
759*58b9f456SAndroid Build Coastguard Worker                __node_ = __node_->__next_;
760*58b9f456SAndroid Build Coastguard Worker        }
761*58b9f456SAndroid Build Coastguard Worker#endif
762*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class> friend class __hash_table;
763*58b9f456SAndroid Build Coastguard Worker    template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
764*58b9f456SAndroid Build Coastguard Worker};
765*58b9f456SAndroid Build Coastguard Worker
766*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc>
767*58b9f456SAndroid Build Coastguard Workerclass __bucket_list_deallocator
768*58b9f456SAndroid Build Coastguard Worker{
769*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                          allocator_type;
770*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>                __alloc_traits;
771*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type              size_type;
772*58b9f456SAndroid Build Coastguard Worker
773*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<size_type, allocator_type> __data_;
774*58b9f456SAndroid Build Coastguard Workerpublic:
775*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer pointer;
776*58b9f456SAndroid Build Coastguard Worker
777*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
778*58b9f456SAndroid Build Coastguard Worker    __bucket_list_deallocator()
779*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
780*58b9f456SAndroid Build Coastguard Worker        : __data_(0) {}
781*58b9f456SAndroid Build Coastguard Worker
782*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
783*58b9f456SAndroid Build Coastguard Worker    __bucket_list_deallocator(const allocator_type& __a, size_type __size)
784*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
785*58b9f456SAndroid Build Coastguard Worker        : __data_(__size, __a) {}
786*58b9f456SAndroid Build Coastguard Worker
787*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
788*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
789*58b9f456SAndroid Build Coastguard Worker    __bucket_list_deallocator(__bucket_list_deallocator&& __x)
790*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
791*58b9f456SAndroid Build Coastguard Worker        : __data_(_VSTD::move(__x.__data_))
792*58b9f456SAndroid Build Coastguard Worker    {
793*58b9f456SAndroid Build Coastguard Worker        __x.size() = 0;
794*58b9f456SAndroid Build Coastguard Worker    }
795*58b9f456SAndroid Build Coastguard Worker#endif
796*58b9f456SAndroid Build Coastguard Worker
797*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
798*58b9f456SAndroid Build Coastguard Worker    size_type& size() _NOEXCEPT {return __data_.first();}
799*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
800*58b9f456SAndroid Build Coastguard Worker    size_type  size() const _NOEXCEPT {return __data_.first();}
801*58b9f456SAndroid Build Coastguard Worker
802*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
803*58b9f456SAndroid Build Coastguard Worker    allocator_type& __alloc() _NOEXCEPT {return __data_.second();}
804*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
805*58b9f456SAndroid Build Coastguard Worker    const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();}
806*58b9f456SAndroid Build Coastguard Worker
807*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
808*58b9f456SAndroid Build Coastguard Worker    void operator()(pointer __p) _NOEXCEPT
809*58b9f456SAndroid Build Coastguard Worker    {
810*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::deallocate(__alloc(), __p, size());
811*58b9f456SAndroid Build Coastguard Worker    }
812*58b9f456SAndroid Build Coastguard Worker};
813*58b9f456SAndroid Build Coastguard Worker
814*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc> class __hash_map_node_destructor;
815*58b9f456SAndroid Build Coastguard Worker
816*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc>
817*58b9f456SAndroid Build Coastguard Workerclass __hash_node_destructor
818*58b9f456SAndroid Build Coastguard Worker{
819*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                          allocator_type;
820*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>                __alloc_traits;
821*58b9f456SAndroid Build Coastguard Worker
822*58b9f456SAndroid Build Coastguard Workerpublic:
823*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer                pointer;
824*58b9f456SAndroid Build Coastguard Workerprivate:
825*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_types<pointer> _NodeTypes;
826*58b9f456SAndroid Build Coastguard Worker
827*58b9f456SAndroid Build Coastguard Worker    allocator_type& __na_;
828*58b9f456SAndroid Build Coastguard Worker
829*58b9f456SAndroid Build Coastguard Worker    __hash_node_destructor& operator=(const __hash_node_destructor&);
830*58b9f456SAndroid Build Coastguard Worker
831*58b9f456SAndroid Build Coastguard Workerpublic:
832*58b9f456SAndroid Build Coastguard Worker    bool __value_constructed;
833*58b9f456SAndroid Build Coastguard Worker
834*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
835*58b9f456SAndroid Build Coastguard Worker    explicit __hash_node_destructor(allocator_type& __na,
836*58b9f456SAndroid Build Coastguard Worker                                    bool __constructed = false) _NOEXCEPT
837*58b9f456SAndroid Build Coastguard Worker        : __na_(__na),
838*58b9f456SAndroid Build Coastguard Worker          __value_constructed(__constructed)
839*58b9f456SAndroid Build Coastguard Worker        {}
840*58b9f456SAndroid Build Coastguard Worker
841*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
842*58b9f456SAndroid Build Coastguard Worker    void operator()(pointer __p) _NOEXCEPT
843*58b9f456SAndroid Build Coastguard Worker    {
844*58b9f456SAndroid Build Coastguard Worker        if (__value_constructed)
845*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));
846*58b9f456SAndroid Build Coastguard Worker        if (__p)
847*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::deallocate(__na_, __p, 1);
848*58b9f456SAndroid Build Coastguard Worker    }
849*58b9f456SAndroid Build Coastguard Worker
850*58b9f456SAndroid Build Coastguard Worker    template <class> friend class __hash_map_node_destructor;
851*58b9f456SAndroid Build Coastguard Worker};
852*58b9f456SAndroid Build Coastguard Worker
853*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
854*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeType, class _Alloc>
855*58b9f456SAndroid Build Coastguard Workerstruct __generic_container_node_destructor;
856*58b9f456SAndroid Build Coastguard Worker
857*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr, class _Alloc>
858*58b9f456SAndroid Build Coastguard Workerstruct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
859*58b9f456SAndroid Build Coastguard Worker    : __hash_node_destructor<_Alloc>
860*58b9f456SAndroid Build Coastguard Worker{
861*58b9f456SAndroid Build Coastguard Worker    using __hash_node_destructor<_Alloc>::__hash_node_destructor;
862*58b9f456SAndroid Build Coastguard Worker};
863*58b9f456SAndroid Build Coastguard Worker#endif
864*58b9f456SAndroid Build Coastguard Worker
865*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Hash, class _Equal>
866*58b9f456SAndroid Build Coastguard Workerstruct __enforce_unordered_container_requirements {
867*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
868*58b9f456SAndroid Build Coastguard Worker    static_assert(__check_hash_requirements<_Key, _Hash>::value,
869*58b9f456SAndroid Build Coastguard Worker    "the specified hash does not meet the Hash requirements");
870*58b9f456SAndroid Build Coastguard Worker    static_assert(is_copy_constructible<_Equal>::value,
871*58b9f456SAndroid Build Coastguard Worker    "the specified comparator is required to be copy constructible");
872*58b9f456SAndroid Build Coastguard Worker#endif
873*58b9f456SAndroid Build Coastguard Worker    typedef int type;
874*58b9f456SAndroid Build Coastguard Worker};
875*58b9f456SAndroid Build Coastguard Worker
876*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Hash, class _Equal>
877*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
878*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
879*58b9f456SAndroid Build Coastguard Worker    "the specified comparator type does not provide a const call operator")
880*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
881*58b9f456SAndroid Build Coastguard Worker    "the specified hash functor does not provide a const call operator")
882*58b9f456SAndroid Build Coastguard Worker#endif
883*58b9f456SAndroid Build Coastguard Workertypename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
884*58b9f456SAndroid Build Coastguard Worker__diagnose_unordered_container_requirements(int);
885*58b9f456SAndroid Build Coastguard Worker
886*58b9f456SAndroid Build Coastguard Worker// This dummy overload is used so that the compiler won't emit a spurious
887*58b9f456SAndroid Build Coastguard Worker// "no matching function for call to __diagnose_unordered_xxx" diagnostic
888*58b9f456SAndroid Build Coastguard Worker// when the overload above causes a hard error.
889*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Hash, class _Equal>
890*58b9f456SAndroid Build Coastguard Workerint __diagnose_unordered_container_requirements(void*);
891*58b9f456SAndroid Build Coastguard Worker
892*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
893*58b9f456SAndroid Build Coastguard Workerclass __hash_table
894*58b9f456SAndroid Build Coastguard Worker{
895*58b9f456SAndroid Build Coastguard Workerpublic:
896*58b9f456SAndroid Build Coastguard Worker    typedef _Tp    value_type;
897*58b9f456SAndroid Build Coastguard Worker    typedef _Hash  hasher;
898*58b9f456SAndroid Build Coastguard Worker    typedef _Equal key_equal;
899*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc allocator_type;
900*58b9f456SAndroid Build Coastguard Worker
901*58b9f456SAndroid Build Coastguard Workerprivate:
902*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type> __alloc_traits;
903*58b9f456SAndroid Build Coastguard Worker    typedef typename
904*58b9f456SAndroid Build Coastguard Worker      __make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type
905*58b9f456SAndroid Build Coastguard Worker                                                                     _NodeTypes;
906*58b9f456SAndroid Build Coastguard Workerpublic:
907*58b9f456SAndroid Build Coastguard Worker
908*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_value_type           __node_value_type;
909*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__container_value_type      __container_value_type;
910*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::key_type                    key_type;
911*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                              reference;
912*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                        const_reference;
913*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer         pointer;
914*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::const_pointer   const_pointer;
915*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
916*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type       size_type;
917*58b9f456SAndroid Build Coastguard Worker#else
918*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::size_type           size_type;
919*58b9f456SAndroid Build Coastguard Worker#endif
920*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::difference_type     difference_type;
921*58b9f456SAndroid Build Coastguard Workerpublic:
922*58b9f456SAndroid Build Coastguard Worker    // Create __node
923*58b9f456SAndroid Build Coastguard Worker
924*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_type __node;
925*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
926*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<__node_allocator>       __node_traits;
927*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__void_pointer      __void_pointer;
928*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_pointer      __node_pointer;
929*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_pointer      __node_const_pointer;
930*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_base_type    __first_node;
931*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
932*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTypes::__next_pointer      __next_pointer;
933*58b9f456SAndroid Build Coastguard Worker
934*58b9f456SAndroid Build Coastguard Workerprivate:
935*58b9f456SAndroid Build Coastguard Worker    // check for sane allocator pointer rebinding semantics. Rebinding the
936*58b9f456SAndroid Build Coastguard Worker    // allocator for a new pointer type should be exactly the same as rebinding
937*58b9f456SAndroid Build Coastguard Worker    // the pointer using 'pointer_traits'.
938*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
939*58b9f456SAndroid Build Coastguard Worker                  "Allocator does not rebind pointers in a sane manner.");
940*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type
941*58b9f456SAndroid Build Coastguard Worker        __node_base_allocator;
942*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<__node_base_allocator> __node_base_traits;
943*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
944*58b9f456SAndroid Build Coastguard Worker                 "Allocator does not rebind pointers in a sane manner.");
945*58b9f456SAndroid Build Coastguard Worker
946*58b9f456SAndroid Build Coastguard Workerprivate:
947*58b9f456SAndroid Build Coastguard Worker
948*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator;
949*58b9f456SAndroid Build Coastguard Worker    typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
950*58b9f456SAndroid Build Coastguard Worker    typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;
951*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<__pointer_allocator>          __pointer_alloc_traits;
952*58b9f456SAndroid Build Coastguard Worker    typedef typename __bucket_list_deleter::pointer       __node_pointer_pointer;
953*58b9f456SAndroid Build Coastguard Worker
954*58b9f456SAndroid Build Coastguard Worker    // --- Member data begin ---
955*58b9f456SAndroid Build Coastguard Worker    __bucket_list                                         __bucket_list_;
956*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<__first_node, __node_allocator>     __p1_;
957*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<size_type, hasher>                  __p2_;
958*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<float, key_equal>                   __p3_;
959*58b9f456SAndroid Build Coastguard Worker    // --- Member data end ---
960*58b9f456SAndroid Build Coastguard Worker
961*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
962*58b9f456SAndroid Build Coastguard Worker    size_type& size() _NOEXCEPT {return __p2_.first();}
963*58b9f456SAndroid Build Coastguard Workerpublic:
964*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
965*58b9f456SAndroid Build Coastguard Worker    size_type  size() const _NOEXCEPT {return __p2_.first();}
966*58b9f456SAndroid Build Coastguard Worker
967*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
968*58b9f456SAndroid Build Coastguard Worker    hasher& hash_function() _NOEXCEPT {return __p2_.second();}
969*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
970*58b9f456SAndroid Build Coastguard Worker    const hasher& hash_function() const _NOEXCEPT {return __p2_.second();}
971*58b9f456SAndroid Build Coastguard Worker
972*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
973*58b9f456SAndroid Build Coastguard Worker    float& max_load_factor() _NOEXCEPT {return __p3_.first();}
974*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
975*58b9f456SAndroid Build Coastguard Worker    float  max_load_factor() const _NOEXCEPT {return __p3_.first();}
976*58b9f456SAndroid Build Coastguard Worker
977*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
978*58b9f456SAndroid Build Coastguard Worker    key_equal& key_eq() _NOEXCEPT {return __p3_.second();}
979*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
980*58b9f456SAndroid Build Coastguard Worker    const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();}
981*58b9f456SAndroid Build Coastguard Worker
982*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
983*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();}
984*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
985*58b9f456SAndroid Build Coastguard Worker    const __node_allocator& __node_alloc() const _NOEXCEPT
986*58b9f456SAndroid Build Coastguard Worker        {return __p1_.second();}
987*58b9f456SAndroid Build Coastguard Worker
988*58b9f456SAndroid Build Coastguard Workerpublic:
989*58b9f456SAndroid Build Coastguard Worker    typedef __hash_iterator<__node_pointer>                   iterator;
990*58b9f456SAndroid Build Coastguard Worker    typedef __hash_const_iterator<__node_pointer>             const_iterator;
991*58b9f456SAndroid Build Coastguard Worker    typedef __hash_local_iterator<__node_pointer>             local_iterator;
992*58b9f456SAndroid Build Coastguard Worker    typedef __hash_const_local_iterator<__node_pointer>       const_local_iterator;
993*58b9f456SAndroid Build Coastguard Worker
994*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
995*58b9f456SAndroid Build Coastguard Worker    __hash_table()
996*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
997*58b9f456SAndroid Build Coastguard Worker            is_nothrow_default_constructible<__bucket_list>::value &&
998*58b9f456SAndroid Build Coastguard Worker            is_nothrow_default_constructible<__first_node>::value &&
999*58b9f456SAndroid Build Coastguard Worker            is_nothrow_default_constructible<__node_allocator>::value &&
1000*58b9f456SAndroid Build Coastguard Worker            is_nothrow_default_constructible<hasher>::value &&
1001*58b9f456SAndroid Build Coastguard Worker            is_nothrow_default_constructible<key_equal>::value);
1002*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1003*58b9f456SAndroid Build Coastguard Worker    __hash_table(const hasher& __hf, const key_equal& __eql);
1004*58b9f456SAndroid Build Coastguard Worker    __hash_table(const hasher& __hf, const key_equal& __eql,
1005*58b9f456SAndroid Build Coastguard Worker                 const allocator_type& __a);
1006*58b9f456SAndroid Build Coastguard Worker    explicit __hash_table(const allocator_type& __a);
1007*58b9f456SAndroid Build Coastguard Worker    __hash_table(const __hash_table& __u);
1008*58b9f456SAndroid Build Coastguard Worker    __hash_table(const __hash_table& __u, const allocator_type& __a);
1009*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1010*58b9f456SAndroid Build Coastguard Worker    __hash_table(__hash_table&& __u)
1011*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1012*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__bucket_list>::value &&
1013*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__first_node>::value &&
1014*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__node_allocator>::value &&
1015*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<hasher>::value &&
1016*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<key_equal>::value);
1017*58b9f456SAndroid Build Coastguard Worker    __hash_table(__hash_table&& __u, const allocator_type& __a);
1018*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1019*58b9f456SAndroid Build Coastguard Worker    ~__hash_table();
1020*58b9f456SAndroid Build Coastguard Worker
1021*58b9f456SAndroid Build Coastguard Worker    __hash_table& operator=(const __hash_table& __u);
1022*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1023*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1024*58b9f456SAndroid Build Coastguard Worker    __hash_table& operator=(__hash_table&& __u)
1025*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1026*58b9f456SAndroid Build Coastguard Worker            __node_traits::propagate_on_container_move_assignment::value &&
1027*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value &&
1028*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<hasher>::value &&
1029*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<key_equal>::value);
1030*58b9f456SAndroid Build Coastguard Worker#endif
1031*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
1032*58b9f456SAndroid Build Coastguard Worker        void __assign_unique(_InputIterator __first, _InputIterator __last);
1033*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
1034*58b9f456SAndroid Build Coastguard Worker        void __assign_multi(_InputIterator __first, _InputIterator __last);
1035*58b9f456SAndroid Build Coastguard Worker
1036*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1037*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const _NOEXCEPT
1038*58b9f456SAndroid Build Coastguard Worker    {
1039*58b9f456SAndroid Build Coastguard Worker        return std::min<size_type>(
1040*58b9f456SAndroid Build Coastguard Worker            __node_traits::max_size(__node_alloc()),
1041*58b9f456SAndroid Build Coastguard Worker            numeric_limits<difference_type >::max()
1042*58b9f456SAndroid Build Coastguard Worker        );
1043*58b9f456SAndroid Build Coastguard Worker    }
1044*58b9f456SAndroid Build Coastguard Worker
1045*58b9f456SAndroid Build Coastguard Workerprivate:
1046*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1047*58b9f456SAndroid Build Coastguard Worker    __next_pointer __node_insert_multi_prepare(size_t __cp_hash,
1048*58b9f456SAndroid Build Coastguard Worker                                               value_type& __cp_val);
1049*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1050*58b9f456SAndroid Build Coastguard Worker    void __node_insert_multi_perform(__node_pointer __cp,
1051*58b9f456SAndroid Build Coastguard Worker                                     __next_pointer __pn) _NOEXCEPT;
1052*58b9f456SAndroid Build Coastguard Worker
1053*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1054*58b9f456SAndroid Build Coastguard Worker    __next_pointer __node_insert_unique_prepare(size_t __nd_hash,
1055*58b9f456SAndroid Build Coastguard Worker                                                value_type& __nd_val);
1056*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1057*58b9f456SAndroid Build Coastguard Worker    void __node_insert_unique_perform(__node_pointer __ptr) _NOEXCEPT;
1058*58b9f456SAndroid Build Coastguard Worker
1059*58b9f456SAndroid Build Coastguard Workerpublic:
1060*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1061*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
1062*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1063*58b9f456SAndroid Build Coastguard Worker    iterator             __node_insert_multi(__node_pointer __nd);
1064*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1065*58b9f456SAndroid Build Coastguard Worker    iterator             __node_insert_multi(const_iterator __p,
1066*58b9f456SAndroid Build Coastguard Worker                                             __node_pointer __nd);
1067*58b9f456SAndroid Build Coastguard Worker
1068*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1069*58b9f456SAndroid Build Coastguard Worker    template <class _Key, class ..._Args>
1070*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1071*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
1072*58b9f456SAndroid Build Coastguard Worker
1073*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1074*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1075*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __emplace_unique_impl(_Args&&... __args);
1076*58b9f456SAndroid Build Coastguard Worker
1077*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1078*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1079*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __emplace_unique(_Pp&& __x) {
1080*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
1081*58b9f456SAndroid Build Coastguard Worker                                          __can_extract_key<_Pp, key_type>());
1082*58b9f456SAndroid Build Coastguard Worker    }
1083*58b9f456SAndroid Build Coastguard Worker
1084*58b9f456SAndroid Build Coastguard Worker    template <class _First, class _Second>
1085*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1086*58b9f456SAndroid Build Coastguard Worker    typename enable_if<
1087*58b9f456SAndroid Build Coastguard Worker        __can_extract_map_key<_First, key_type, __container_value_type>::value,
1088*58b9f456SAndroid Build Coastguard Worker        pair<iterator, bool>
1089*58b9f456SAndroid Build Coastguard Worker    >::type __emplace_unique(_First&& __f, _Second&& __s) {
1090*58b9f456SAndroid Build Coastguard Worker        return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f),
1091*58b9f456SAndroid Build Coastguard Worker                                              _VSTD::forward<_Second>(__s));
1092*58b9f456SAndroid Build Coastguard Worker    }
1093*58b9f456SAndroid Build Coastguard Worker
1094*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1095*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1096*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __emplace_unique(_Args&&... __args) {
1097*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
1098*58b9f456SAndroid Build Coastguard Worker    }
1099*58b9f456SAndroid Build Coastguard Worker
1100*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1101*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1102*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool>
1103*58b9f456SAndroid Build Coastguard Worker    __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) {
1104*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_impl(_VSTD::forward<_Pp>(__x));
1105*58b9f456SAndroid Build Coastguard Worker    }
1106*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1107*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1108*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool>
1109*58b9f456SAndroid Build Coastguard Worker    __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) {
1110*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x));
1111*58b9f456SAndroid Build Coastguard Worker    }
1112*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1113*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1114*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool>
1115*58b9f456SAndroid Build Coastguard Worker    __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) {
1116*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x));
1117*58b9f456SAndroid Build Coastguard Worker    }
1118*58b9f456SAndroid Build Coastguard Worker
1119*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1120*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1121*58b9f456SAndroid Build Coastguard Worker    iterator __emplace_multi(_Args&&... __args);
1122*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1123*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1124*58b9f456SAndroid Build Coastguard Worker    iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
1125*58b9f456SAndroid Build Coastguard Worker
1126*58b9f456SAndroid Build Coastguard Worker
1127*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1128*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool>
1129*58b9f456SAndroid Build Coastguard Worker    __insert_unique(__container_value_type&& __x) {
1130*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x));
1131*58b9f456SAndroid Build Coastguard Worker    }
1132*58b9f456SAndroid Build Coastguard Worker
1133*58b9f456SAndroid Build Coastguard Worker    template <class _Pp, class = typename enable_if<
1134*58b9f456SAndroid Build Coastguard Worker            !__is_same_uncvref<_Pp, __container_value_type>::value
1135*58b9f456SAndroid Build Coastguard Worker        >::type>
1136*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1137*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __insert_unique(_Pp&& __x) {
1138*58b9f456SAndroid Build Coastguard Worker      return __emplace_unique(_VSTD::forward<_Pp>(__x));
1139*58b9f456SAndroid Build Coastguard Worker    }
1140*58b9f456SAndroid Build Coastguard Worker
1141*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1142*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1143*58b9f456SAndroid Build Coastguard Worker    iterator __insert_multi(_Pp&& __x) {
1144*58b9f456SAndroid Build Coastguard Worker      return __emplace_multi(_VSTD::forward<_Pp>(__x));
1145*58b9f456SAndroid Build Coastguard Worker    }
1146*58b9f456SAndroid Build Coastguard Worker
1147*58b9f456SAndroid Build Coastguard Worker    template <class _Pp>
1148*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1149*58b9f456SAndroid Build Coastguard Worker    iterator __insert_multi(const_iterator __p, _Pp&& __x) {
1150*58b9f456SAndroid Build Coastguard Worker        return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x));
1151*58b9f456SAndroid Build Coastguard Worker    }
1152*58b9f456SAndroid Build Coastguard Worker
1153*58b9f456SAndroid Build Coastguard Worker#else  // !defined(_LIBCPP_CXX03_LANG)
1154*58b9f456SAndroid Build Coastguard Worker    template <class _Key, class _Args>
1155*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1156*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __emplace_unique_key_args(_Key const&, _Args& __args);
1157*58b9f456SAndroid Build Coastguard Worker
1158*58b9f456SAndroid Build Coastguard Worker    iterator __insert_multi(const __container_value_type& __x);
1159*58b9f456SAndroid Build Coastguard Worker    iterator __insert_multi(const_iterator __p, const __container_value_type& __x);
1160*58b9f456SAndroid Build Coastguard Worker#endif
1161*58b9f456SAndroid Build Coastguard Worker
1162*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1163*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __insert_unique(const __container_value_type& __x) {
1164*58b9f456SAndroid Build Coastguard Worker        return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
1165*58b9f456SAndroid Build Coastguard Worker    }
1166*58b9f456SAndroid Build Coastguard Worker
1167*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1168*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle, class _InsertReturnType>
1169*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1170*58b9f456SAndroid Build Coastguard Worker    _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh);
1171*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle>
1172*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1173*58b9f456SAndroid Build Coastguard Worker    iterator __node_handle_insert_unique(const_iterator __hint,
1174*58b9f456SAndroid Build Coastguard Worker                                         _NodeHandle&& __nh);
1175*58b9f456SAndroid Build Coastguard Worker    template <class _Table>
1176*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1177*58b9f456SAndroid Build Coastguard Worker    void __node_handle_merge_unique(_Table& __source);
1178*58b9f456SAndroid Build Coastguard Worker
1179*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle>
1180*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1181*58b9f456SAndroid Build Coastguard Worker    iterator __node_handle_insert_multi(_NodeHandle&& __nh);
1182*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle>
1183*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1184*58b9f456SAndroid Build Coastguard Worker    iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh);
1185*58b9f456SAndroid Build Coastguard Worker    template <class _Table>
1186*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1187*58b9f456SAndroid Build Coastguard Worker    void __node_handle_merge_multi(_Table& __source);
1188*58b9f456SAndroid Build Coastguard Worker
1189*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle>
1190*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1191*58b9f456SAndroid Build Coastguard Worker    _NodeHandle __node_handle_extract(key_type const& __key);
1192*58b9f456SAndroid Build Coastguard Worker    template <class _NodeHandle>
1193*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1194*58b9f456SAndroid Build Coastguard Worker    _NodeHandle __node_handle_extract(const_iterator __it);
1195*58b9f456SAndroid Build Coastguard Worker#endif
1196*58b9f456SAndroid Build Coastguard Worker
1197*58b9f456SAndroid Build Coastguard Worker    void clear() _NOEXCEPT;
1198*58b9f456SAndroid Build Coastguard Worker    void rehash(size_type __n);
1199*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
1200*58b9f456SAndroid Build Coastguard Worker        {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
1201*58b9f456SAndroid Build Coastguard Worker
1202*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1203*58b9f456SAndroid Build Coastguard Worker    size_type bucket_count() const _NOEXCEPT
1204*58b9f456SAndroid Build Coastguard Worker    {
1205*58b9f456SAndroid Build Coastguard Worker        return __bucket_list_.get_deleter().size();
1206*58b9f456SAndroid Build Coastguard Worker    }
1207*58b9f456SAndroid Build Coastguard Worker
1208*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1209*58b9f456SAndroid Build Coastguard Worker    iterator       begin() _NOEXCEPT;
1210*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1211*58b9f456SAndroid Build Coastguard Worker    iterator       end() _NOEXCEPT;
1212*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1213*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const _NOEXCEPT;
1214*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1215*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT;
1216*58b9f456SAndroid Build Coastguard Worker
1217*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1218*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
1219*58b9f456SAndroid Build Coastguard Worker        size_type bucket(const _Key& __k) const
1220*58b9f456SAndroid Build Coastguard Worker        {
1221*58b9f456SAndroid Build Coastguard Worker            _LIBCPP_ASSERT(bucket_count() > 0,
1222*58b9f456SAndroid Build Coastguard Worker                "unordered container::bucket(key) called when bucket_count() == 0");
1223*58b9f456SAndroid Build Coastguard Worker            return __constrain_hash(hash_function()(__k), bucket_count());
1224*58b9f456SAndroid Build Coastguard Worker        }
1225*58b9f456SAndroid Build Coastguard Worker
1226*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1227*58b9f456SAndroid Build Coastguard Worker        iterator       find(const _Key& __x);
1228*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1229*58b9f456SAndroid Build Coastguard Worker        const_iterator find(const _Key& __x) const;
1230*58b9f456SAndroid Build Coastguard Worker
1231*58b9f456SAndroid Build Coastguard Worker    typedef __hash_node_destructor<__node_allocator> _Dp;
1232*58b9f456SAndroid Build Coastguard Worker    typedef unique_ptr<__node, _Dp> __node_holder;
1233*58b9f456SAndroid Build Coastguard Worker
1234*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator __p);
1235*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator __first, const_iterator __last);
1236*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1237*58b9f456SAndroid Build Coastguard Worker        size_type __erase_unique(const _Key& __k);
1238*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1239*58b9f456SAndroid Build Coastguard Worker        size_type __erase_multi(const _Key& __k);
1240*58b9f456SAndroid Build Coastguard Worker    __node_holder remove(const_iterator __p) _NOEXCEPT;
1241*58b9f456SAndroid Build Coastguard Worker
1242*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1243*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
1244*58b9f456SAndroid Build Coastguard Worker        size_type __count_unique(const _Key& __k) const;
1245*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1246*58b9f456SAndroid Build Coastguard Worker        size_type __count_multi(const _Key& __k) const;
1247*58b9f456SAndroid Build Coastguard Worker
1248*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1249*58b9f456SAndroid Build Coastguard Worker        pair<iterator, iterator>
1250*58b9f456SAndroid Build Coastguard Worker        __equal_range_unique(const _Key& __k);
1251*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1252*58b9f456SAndroid Build Coastguard Worker        pair<const_iterator, const_iterator>
1253*58b9f456SAndroid Build Coastguard Worker        __equal_range_unique(const _Key& __k) const;
1254*58b9f456SAndroid Build Coastguard Worker
1255*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1256*58b9f456SAndroid Build Coastguard Worker        pair<iterator, iterator>
1257*58b9f456SAndroid Build Coastguard Worker        __equal_range_multi(const _Key& __k);
1258*58b9f456SAndroid Build Coastguard Worker    template <class _Key>
1259*58b9f456SAndroid Build Coastguard Worker        pair<const_iterator, const_iterator>
1260*58b9f456SAndroid Build Coastguard Worker        __equal_range_multi(const _Key& __k) const;
1261*58b9f456SAndroid Build Coastguard Worker
1262*58b9f456SAndroid Build Coastguard Worker    void swap(__hash_table& __u)
1263*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 11
1264*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(
1265*58b9f456SAndroid Build Coastguard Worker            __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
1266*58b9f456SAndroid Build Coastguard Worker            && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
1267*58b9f456SAndroid Build Coastguard Worker                  || __is_nothrow_swappable<__pointer_allocator>::value)
1268*58b9f456SAndroid Build Coastguard Worker            && (!__node_traits::propagate_on_container_swap::value
1269*58b9f456SAndroid Build Coastguard Worker                  || __is_nothrow_swappable<__node_allocator>::value)
1270*58b9f456SAndroid Build Coastguard Worker            );
1271*58b9f456SAndroid Build Coastguard Worker#else
1272*58b9f456SAndroid Build Coastguard Worker     _NOEXCEPT_DEBUG_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
1273*58b9f456SAndroid Build Coastguard Worker#endif
1274*58b9f456SAndroid Build Coastguard Worker
1275*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1276*58b9f456SAndroid Build Coastguard Worker    size_type max_bucket_count() const _NOEXCEPT
1277*58b9f456SAndroid Build Coastguard Worker        {return max_size(); }
1278*58b9f456SAndroid Build Coastguard Worker    size_type bucket_size(size_type __n) const;
1279*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
1280*58b9f456SAndroid Build Coastguard Worker    {
1281*58b9f456SAndroid Build Coastguard Worker        size_type __bc = bucket_count();
1282*58b9f456SAndroid Build Coastguard Worker        return __bc != 0 ? (float)size() / __bc : 0.f;
1283*58b9f456SAndroid Build Coastguard Worker    }
1284*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT
1285*58b9f456SAndroid Build Coastguard Worker    {
1286*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__mlf > 0,
1287*58b9f456SAndroid Build Coastguard Worker            "unordered container::max_load_factor(lf) called with lf <= 0");
1288*58b9f456SAndroid Build Coastguard Worker        max_load_factor() = _VSTD::max(__mlf, load_factor());
1289*58b9f456SAndroid Build Coastguard Worker    }
1290*58b9f456SAndroid Build Coastguard Worker
1291*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1292*58b9f456SAndroid Build Coastguard Worker    local_iterator
1293*58b9f456SAndroid Build Coastguard Worker    begin(size_type __n)
1294*58b9f456SAndroid Build Coastguard Worker    {
1295*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__n < bucket_count(),
1296*58b9f456SAndroid Build Coastguard Worker            "unordered container::begin(n) called with n >= bucket_count()");
1297*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1298*58b9f456SAndroid Build Coastguard Worker        return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1299*58b9f456SAndroid Build Coastguard Worker#else
1300*58b9f456SAndroid Build Coastguard Worker        return local_iterator(__bucket_list_[__n], __n, bucket_count());
1301*58b9f456SAndroid Build Coastguard Worker#endif
1302*58b9f456SAndroid Build Coastguard Worker    }
1303*58b9f456SAndroid Build Coastguard Worker
1304*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1305*58b9f456SAndroid Build Coastguard Worker    local_iterator
1306*58b9f456SAndroid Build Coastguard Worker    end(size_type __n)
1307*58b9f456SAndroid Build Coastguard Worker    {
1308*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__n < bucket_count(),
1309*58b9f456SAndroid Build Coastguard Worker            "unordered container::end(n) called with n >= bucket_count()");
1310*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1311*58b9f456SAndroid Build Coastguard Worker        return local_iterator(nullptr, __n, bucket_count(), this);
1312*58b9f456SAndroid Build Coastguard Worker#else
1313*58b9f456SAndroid Build Coastguard Worker        return local_iterator(nullptr, __n, bucket_count());
1314*58b9f456SAndroid Build Coastguard Worker#endif
1315*58b9f456SAndroid Build Coastguard Worker    }
1316*58b9f456SAndroid Build Coastguard Worker
1317*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1318*58b9f456SAndroid Build Coastguard Worker    const_local_iterator
1319*58b9f456SAndroid Build Coastguard Worker    cbegin(size_type __n) const
1320*58b9f456SAndroid Build Coastguard Worker    {
1321*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__n < bucket_count(),
1322*58b9f456SAndroid Build Coastguard Worker            "unordered container::cbegin(n) called with n >= bucket_count()");
1323*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1324*58b9f456SAndroid Build Coastguard Worker        return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
1325*58b9f456SAndroid Build Coastguard Worker#else
1326*58b9f456SAndroid Build Coastguard Worker        return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
1327*58b9f456SAndroid Build Coastguard Worker#endif
1328*58b9f456SAndroid Build Coastguard Worker    }
1329*58b9f456SAndroid Build Coastguard Worker
1330*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1331*58b9f456SAndroid Build Coastguard Worker    const_local_iterator
1332*58b9f456SAndroid Build Coastguard Worker    cend(size_type __n) const
1333*58b9f456SAndroid Build Coastguard Worker    {
1334*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__n < bucket_count(),
1335*58b9f456SAndroid Build Coastguard Worker            "unordered container::cend(n) called with n >= bucket_count()");
1336*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1337*58b9f456SAndroid Build Coastguard Worker        return const_local_iterator(nullptr, __n, bucket_count(), this);
1338*58b9f456SAndroid Build Coastguard Worker#else
1339*58b9f456SAndroid Build Coastguard Worker        return const_local_iterator(nullptr, __n, bucket_count());
1340*58b9f456SAndroid Build Coastguard Worker#endif
1341*58b9f456SAndroid Build Coastguard Worker    }
1342*58b9f456SAndroid Build Coastguard Worker
1343*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1344*58b9f456SAndroid Build Coastguard Worker
1345*58b9f456SAndroid Build Coastguard Worker    bool __dereferenceable(const const_iterator* __i) const;
1346*58b9f456SAndroid Build Coastguard Worker    bool __decrementable(const const_iterator* __i) const;
1347*58b9f456SAndroid Build Coastguard Worker    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1348*58b9f456SAndroid Build Coastguard Worker    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
1349*58b9f456SAndroid Build Coastguard Worker
1350*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1351*58b9f456SAndroid Build Coastguard Worker
1352*58b9f456SAndroid Build Coastguard Workerprivate:
1353*58b9f456SAndroid Build Coastguard Worker    void __rehash(size_type __n);
1354*58b9f456SAndroid Build Coastguard Worker
1355*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1356*58b9f456SAndroid Build Coastguard Worker    template <class ..._Args>
1357*58b9f456SAndroid Build Coastguard Worker    __node_holder __construct_node(_Args&& ...__args);
1358*58b9f456SAndroid Build Coastguard Worker
1359*58b9f456SAndroid Build Coastguard Worker    template <class _First, class ..._Rest>
1360*58b9f456SAndroid Build Coastguard Worker    __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest);
1361*58b9f456SAndroid Build Coastguard Worker#else // _LIBCPP_CXX03_LANG
1362*58b9f456SAndroid Build Coastguard Worker    __node_holder __construct_node(const __container_value_type& __v);
1363*58b9f456SAndroid Build Coastguard Worker    __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v);
1364*58b9f456SAndroid Build Coastguard Worker#endif
1365*58b9f456SAndroid Build Coastguard Worker
1366*58b9f456SAndroid Build Coastguard Worker
1367*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1368*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const __hash_table& __u)
1369*58b9f456SAndroid Build Coastguard Worker        {__copy_assign_alloc(__u, integral_constant<bool,
1370*58b9f456SAndroid Build Coastguard Worker             __node_traits::propagate_on_container_copy_assignment::value>());}
1371*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const __hash_table& __u, true_type);
1372*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1373*58b9f456SAndroid Build Coastguard Worker        void __copy_assign_alloc(const __hash_table&, false_type) {}
1374*58b9f456SAndroid Build Coastguard Worker
1375*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1376*58b9f456SAndroid Build Coastguard Worker    void __move_assign(__hash_table& __u, false_type);
1377*58b9f456SAndroid Build Coastguard Worker    void __move_assign(__hash_table& __u, true_type)
1378*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1379*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value &&
1380*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<hasher>::value &&
1381*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<key_equal>::value);
1382*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1383*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(__hash_table& __u)
1384*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1385*58b9f456SAndroid Build Coastguard Worker            !__node_traits::propagate_on_container_move_assignment::value ||
1386*58b9f456SAndroid Build Coastguard Worker            (is_nothrow_move_assignable<__pointer_allocator>::value &&
1387*58b9f456SAndroid Build Coastguard Worker             is_nothrow_move_assignable<__node_allocator>::value))
1388*58b9f456SAndroid Build Coastguard Worker        {__move_assign_alloc(__u, integral_constant<bool,
1389*58b9f456SAndroid Build Coastguard Worker             __node_traits::propagate_on_container_move_assignment::value>());}
1390*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1391*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(__hash_table& __u, true_type)
1392*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1393*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__pointer_allocator>::value &&
1394*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value)
1395*58b9f456SAndroid Build Coastguard Worker    {
1396*58b9f456SAndroid Build Coastguard Worker        __bucket_list_.get_deleter().__alloc() =
1397*58b9f456SAndroid Build Coastguard Worker                _VSTD::move(__u.__bucket_list_.get_deleter().__alloc());
1398*58b9f456SAndroid Build Coastguard Worker        __node_alloc() = _VSTD::move(__u.__node_alloc());
1399*58b9f456SAndroid Build Coastguard Worker    }
1400*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1401*58b9f456SAndroid Build Coastguard Worker        void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
1402*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG
1403*58b9f456SAndroid Build Coastguard Worker
1404*58b9f456SAndroid Build Coastguard Worker    void __deallocate_node(__next_pointer __np) _NOEXCEPT;
1405*58b9f456SAndroid Build Coastguard Worker    __next_pointer __detach() _NOEXCEPT;
1406*58b9f456SAndroid Build Coastguard Worker
1407*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map;
1408*58b9f456SAndroid Build Coastguard Worker    template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;
1409*58b9f456SAndroid Build Coastguard Worker};
1410*58b9f456SAndroid Build Coastguard Worker
1411*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1412*58b9f456SAndroid Build Coastguard Workerinline
1413*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
1414*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(
1415*58b9f456SAndroid Build Coastguard Worker        is_nothrow_default_constructible<__bucket_list>::value &&
1416*58b9f456SAndroid Build Coastguard Worker        is_nothrow_default_constructible<__first_node>::value &&
1417*58b9f456SAndroid Build Coastguard Worker        is_nothrow_default_constructible<__node_allocator>::value &&
1418*58b9f456SAndroid Build Coastguard Worker        is_nothrow_default_constructible<hasher>::value &&
1419*58b9f456SAndroid Build Coastguard Worker        is_nothrow_default_constructible<key_equal>::value)
1420*58b9f456SAndroid Build Coastguard Worker    : __p2_(0),
1421*58b9f456SAndroid Build Coastguard Worker      __p3_(1.0f)
1422*58b9f456SAndroid Build Coastguard Worker{
1423*58b9f456SAndroid Build Coastguard Worker}
1424*58b9f456SAndroid Build Coastguard Worker
1425*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1426*58b9f456SAndroid Build Coastguard Workerinline
1427*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
1428*58b9f456SAndroid Build Coastguard Worker                                                       const key_equal& __eql)
1429*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr, __bucket_list_deleter()),
1430*58b9f456SAndroid Build Coastguard Worker      __p1_(),
1431*58b9f456SAndroid Build Coastguard Worker      __p2_(0, __hf),
1432*58b9f456SAndroid Build Coastguard Worker      __p3_(1.0f, __eql)
1433*58b9f456SAndroid Build Coastguard Worker{
1434*58b9f456SAndroid Build Coastguard Worker}
1435*58b9f456SAndroid Build Coastguard Worker
1436*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1437*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
1438*58b9f456SAndroid Build Coastguard Worker                                                       const key_equal& __eql,
1439*58b9f456SAndroid Build Coastguard Worker                                                       const allocator_type& __a)
1440*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1441*58b9f456SAndroid Build Coastguard Worker      __p1_(__second_tag(), __node_allocator(__a)),
1442*58b9f456SAndroid Build Coastguard Worker      __p2_(0, __hf),
1443*58b9f456SAndroid Build Coastguard Worker      __p3_(1.0f, __eql)
1444*58b9f456SAndroid Build Coastguard Worker{
1445*58b9f456SAndroid Build Coastguard Worker}
1446*58b9f456SAndroid Build Coastguard Worker
1447*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1448*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)
1449*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1450*58b9f456SAndroid Build Coastguard Worker      __p1_(__second_tag(), __node_allocator(__a)),
1451*58b9f456SAndroid Build Coastguard Worker      __p2_(0),
1452*58b9f456SAndroid Build Coastguard Worker      __p3_(1.0f)
1453*58b9f456SAndroid Build Coastguard Worker{
1454*58b9f456SAndroid Build Coastguard Worker}
1455*58b9f456SAndroid Build Coastguard Worker
1456*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1457*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
1458*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr,
1459*58b9f456SAndroid Build Coastguard Worker          __bucket_list_deleter(allocator_traits<__pointer_allocator>::
1460*58b9f456SAndroid Build Coastguard Worker              select_on_container_copy_construction(
1461*58b9f456SAndroid Build Coastguard Worker                  __u.__bucket_list_.get_deleter().__alloc()), 0)),
1462*58b9f456SAndroid Build Coastguard Worker      __p1_(__second_tag(), allocator_traits<__node_allocator>::
1463*58b9f456SAndroid Build Coastguard Worker          select_on_container_copy_construction(__u.__node_alloc())),
1464*58b9f456SAndroid Build Coastguard Worker      __p2_(0, __u.hash_function()),
1465*58b9f456SAndroid Build Coastguard Worker      __p3_(__u.__p3_)
1466*58b9f456SAndroid Build Coastguard Worker{
1467*58b9f456SAndroid Build Coastguard Worker}
1468*58b9f456SAndroid Build Coastguard Worker
1469*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1470*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
1471*58b9f456SAndroid Build Coastguard Worker                                                       const allocator_type& __a)
1472*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1473*58b9f456SAndroid Build Coastguard Worker      __p1_(__second_tag(), __node_allocator(__a)),
1474*58b9f456SAndroid Build Coastguard Worker      __p2_(0, __u.hash_function()),
1475*58b9f456SAndroid Build Coastguard Worker      __p3_(__u.__p3_)
1476*58b9f456SAndroid Build Coastguard Worker{
1477*58b9f456SAndroid Build Coastguard Worker}
1478*58b9f456SAndroid Build Coastguard Worker
1479*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1480*58b9f456SAndroid Build Coastguard Worker
1481*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1482*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
1483*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1484*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__bucket_list>::value &&
1485*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__first_node>::value &&
1486*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<__node_allocator>::value &&
1487*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<hasher>::value &&
1488*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_constructible<key_equal>::value)
1489*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(_VSTD::move(__u.__bucket_list_)),
1490*58b9f456SAndroid Build Coastguard Worker      __p1_(_VSTD::move(__u.__p1_)),
1491*58b9f456SAndroid Build Coastguard Worker      __p2_(_VSTD::move(__u.__p2_)),
1492*58b9f456SAndroid Build Coastguard Worker      __p3_(_VSTD::move(__u.__p3_))
1493*58b9f456SAndroid Build Coastguard Worker{
1494*58b9f456SAndroid Build Coastguard Worker    if (size() > 0)
1495*58b9f456SAndroid Build Coastguard Worker    {
1496*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1497*58b9f456SAndroid Build Coastguard Worker            __p1_.first().__ptr();
1498*58b9f456SAndroid Build Coastguard Worker        __u.__p1_.first().__next_ = nullptr;
1499*58b9f456SAndroid Build Coastguard Worker        __u.size() = 0;
1500*58b9f456SAndroid Build Coastguard Worker    }
1501*58b9f456SAndroid Build Coastguard Worker}
1502*58b9f456SAndroid Build Coastguard Worker
1503*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1504*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
1505*58b9f456SAndroid Build Coastguard Worker                                                       const allocator_type& __a)
1506*58b9f456SAndroid Build Coastguard Worker    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1507*58b9f456SAndroid Build Coastguard Worker      __p1_(__second_tag(), __node_allocator(__a)),
1508*58b9f456SAndroid Build Coastguard Worker      __p2_(0, _VSTD::move(__u.hash_function())),
1509*58b9f456SAndroid Build Coastguard Worker      __p3_(_VSTD::move(__u.__p3_))
1510*58b9f456SAndroid Build Coastguard Worker{
1511*58b9f456SAndroid Build Coastguard Worker    if (__a == allocator_type(__u.__node_alloc()))
1512*58b9f456SAndroid Build Coastguard Worker    {
1513*58b9f456SAndroid Build Coastguard Worker        __bucket_list_.reset(__u.__bucket_list_.release());
1514*58b9f456SAndroid Build Coastguard Worker        __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
1515*58b9f456SAndroid Build Coastguard Worker        __u.__bucket_list_.get_deleter().size() = 0;
1516*58b9f456SAndroid Build Coastguard Worker        if (__u.size() > 0)
1517*58b9f456SAndroid Build Coastguard Worker        {
1518*58b9f456SAndroid Build Coastguard Worker            __p1_.first().__next_ = __u.__p1_.first().__next_;
1519*58b9f456SAndroid Build Coastguard Worker            __u.__p1_.first().__next_ = nullptr;
1520*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1521*58b9f456SAndroid Build Coastguard Worker                __p1_.first().__ptr();
1522*58b9f456SAndroid Build Coastguard Worker            size() = __u.size();
1523*58b9f456SAndroid Build Coastguard Worker            __u.size() = 0;
1524*58b9f456SAndroid Build Coastguard Worker        }
1525*58b9f456SAndroid Build Coastguard Worker    }
1526*58b9f456SAndroid Build Coastguard Worker}
1527*58b9f456SAndroid Build Coastguard Worker
1528*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1529*58b9f456SAndroid Build Coastguard Worker
1530*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1531*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
1532*58b9f456SAndroid Build Coastguard Worker{
1533*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_CXX03_LANG)
1534*58b9f456SAndroid Build Coastguard Worker    static_assert((is_copy_constructible<key_equal>::value),
1535*58b9f456SAndroid Build Coastguard Worker                 "Predicate must be copy-constructible.");
1536*58b9f456SAndroid Build Coastguard Worker    static_assert((is_copy_constructible<hasher>::value),
1537*58b9f456SAndroid Build Coastguard Worker                 "Hasher must be copy-constructible.");
1538*58b9f456SAndroid Build Coastguard Worker#endif
1539*58b9f456SAndroid Build Coastguard Worker
1540*58b9f456SAndroid Build Coastguard Worker    __deallocate_node(__p1_.first().__next_);
1541*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1542*58b9f456SAndroid Build Coastguard Worker    __get_db()->__erase_c(this);
1543*58b9f456SAndroid Build Coastguard Worker#endif
1544*58b9f456SAndroid Build Coastguard Worker}
1545*58b9f456SAndroid Build Coastguard Worker
1546*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1547*58b9f456SAndroid Build Coastguard Workervoid
1548*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc(
1549*58b9f456SAndroid Build Coastguard Worker        const __hash_table& __u, true_type)
1550*58b9f456SAndroid Build Coastguard Worker{
1551*58b9f456SAndroid Build Coastguard Worker    if (__node_alloc() != __u.__node_alloc())
1552*58b9f456SAndroid Build Coastguard Worker    {
1553*58b9f456SAndroid Build Coastguard Worker        clear();
1554*58b9f456SAndroid Build Coastguard Worker        __bucket_list_.reset();
1555*58b9f456SAndroid Build Coastguard Worker        __bucket_list_.get_deleter().size() = 0;
1556*58b9f456SAndroid Build Coastguard Worker    }
1557*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc();
1558*58b9f456SAndroid Build Coastguard Worker    __node_alloc() = __u.__node_alloc();
1559*58b9f456SAndroid Build Coastguard Worker}
1560*58b9f456SAndroid Build Coastguard Worker
1561*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1562*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>&
1563*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u)
1564*58b9f456SAndroid Build Coastguard Worker{
1565*58b9f456SAndroid Build Coastguard Worker    if (this != &__u)
1566*58b9f456SAndroid Build Coastguard Worker    {
1567*58b9f456SAndroid Build Coastguard Worker        __copy_assign_alloc(__u);
1568*58b9f456SAndroid Build Coastguard Worker        hash_function() = __u.hash_function();
1569*58b9f456SAndroid Build Coastguard Worker        key_eq() = __u.key_eq();
1570*58b9f456SAndroid Build Coastguard Worker        max_load_factor() = __u.max_load_factor();
1571*58b9f456SAndroid Build Coastguard Worker        __assign_multi(__u.begin(), __u.end());
1572*58b9f456SAndroid Build Coastguard Worker    }
1573*58b9f456SAndroid Build Coastguard Worker    return *this;
1574*58b9f456SAndroid Build Coastguard Worker}
1575*58b9f456SAndroid Build Coastguard Worker
1576*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1577*58b9f456SAndroid Build Coastguard Workervoid
1578*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np)
1579*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT
1580*58b9f456SAndroid Build Coastguard Worker{
1581*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __node_alloc();
1582*58b9f456SAndroid Build Coastguard Worker    while (__np != nullptr)
1583*58b9f456SAndroid Build Coastguard Worker    {
1584*58b9f456SAndroid Build Coastguard Worker        __next_pointer __next = __np->__next_;
1585*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1586*58b9f456SAndroid Build Coastguard Worker        __c_node* __c = __get_db()->__find_c_and_lock(this);
1587*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __p = __c->end_; __p != __c->beg_; )
1588*58b9f456SAndroid Build Coastguard Worker        {
1589*58b9f456SAndroid Build Coastguard Worker            --__p;
1590*58b9f456SAndroid Build Coastguard Worker            iterator* __i = static_cast<iterator*>((*__p)->__i_);
1591*58b9f456SAndroid Build Coastguard Worker            if (__i->__node_ == __np)
1592*58b9f456SAndroid Build Coastguard Worker            {
1593*58b9f456SAndroid Build Coastguard Worker                (*__p)->__c_ = nullptr;
1594*58b9f456SAndroid Build Coastguard Worker                if (--__c->end_ != __p)
1595*58b9f456SAndroid Build Coastguard Worker                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1596*58b9f456SAndroid Build Coastguard Worker            }
1597*58b9f456SAndroid Build Coastguard Worker        }
1598*58b9f456SAndroid Build Coastguard Worker        __get_db()->unlock();
1599*58b9f456SAndroid Build Coastguard Worker#endif
1600*58b9f456SAndroid Build Coastguard Worker        __node_pointer __real_np = __np->__upcast();
1601*58b9f456SAndroid Build Coastguard Worker        __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__value_));
1602*58b9f456SAndroid Build Coastguard Worker        __node_traits::deallocate(__na, __real_np, 1);
1603*58b9f456SAndroid Build Coastguard Worker        __np = __next;
1604*58b9f456SAndroid Build Coastguard Worker    }
1605*58b9f456SAndroid Build Coastguard Worker}
1606*58b9f456SAndroid Build Coastguard Worker
1607*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1608*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
1609*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
1610*58b9f456SAndroid Build Coastguard Worker{
1611*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
1612*58b9f456SAndroid Build Coastguard Worker    for (size_type __i = 0; __i < __bc; ++__i)
1613*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__i] = nullptr;
1614*58b9f456SAndroid Build Coastguard Worker    size() = 0;
1615*58b9f456SAndroid Build Coastguard Worker    __next_pointer __cache = __p1_.first().__next_;
1616*58b9f456SAndroid Build Coastguard Worker    __p1_.first().__next_ = nullptr;
1617*58b9f456SAndroid Build Coastguard Worker    return __cache;
1618*58b9f456SAndroid Build Coastguard Worker}
1619*58b9f456SAndroid Build Coastguard Worker
1620*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1621*58b9f456SAndroid Build Coastguard Worker
1622*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1623*58b9f456SAndroid Build Coastguard Workervoid
1624*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
1625*58b9f456SAndroid Build Coastguard Worker        __hash_table& __u, true_type)
1626*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(
1627*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<__node_allocator>::value &&
1628*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<hasher>::value &&
1629*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<key_equal>::value)
1630*58b9f456SAndroid Build Coastguard Worker{
1631*58b9f456SAndroid Build Coastguard Worker    clear();
1632*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.reset(__u.__bucket_list_.release());
1633*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
1634*58b9f456SAndroid Build Coastguard Worker    __u.__bucket_list_.get_deleter().size() = 0;
1635*58b9f456SAndroid Build Coastguard Worker    __move_assign_alloc(__u);
1636*58b9f456SAndroid Build Coastguard Worker    size() = __u.size();
1637*58b9f456SAndroid Build Coastguard Worker    hash_function() = _VSTD::move(__u.hash_function());
1638*58b9f456SAndroid Build Coastguard Worker    max_load_factor() = __u.max_load_factor();
1639*58b9f456SAndroid Build Coastguard Worker    key_eq() = _VSTD::move(__u.key_eq());
1640*58b9f456SAndroid Build Coastguard Worker    __p1_.first().__next_ = __u.__p1_.first().__next_;
1641*58b9f456SAndroid Build Coastguard Worker    if (size() > 0)
1642*58b9f456SAndroid Build Coastguard Worker    {
1643*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1644*58b9f456SAndroid Build Coastguard Worker            __p1_.first().__ptr();
1645*58b9f456SAndroid Build Coastguard Worker        __u.__p1_.first().__next_ = nullptr;
1646*58b9f456SAndroid Build Coastguard Worker        __u.size() = 0;
1647*58b9f456SAndroid Build Coastguard Worker    }
1648*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1649*58b9f456SAndroid Build Coastguard Worker    __get_db()->swap(this, &__u);
1650*58b9f456SAndroid Build Coastguard Worker#endif
1651*58b9f456SAndroid Build Coastguard Worker}
1652*58b9f456SAndroid Build Coastguard Worker
1653*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1654*58b9f456SAndroid Build Coastguard Workervoid
1655*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
1656*58b9f456SAndroid Build Coastguard Worker        __hash_table& __u, false_type)
1657*58b9f456SAndroid Build Coastguard Worker{
1658*58b9f456SAndroid Build Coastguard Worker    if (__node_alloc() == __u.__node_alloc())
1659*58b9f456SAndroid Build Coastguard Worker        __move_assign(__u, true_type());
1660*58b9f456SAndroid Build Coastguard Worker    else
1661*58b9f456SAndroid Build Coastguard Worker    {
1662*58b9f456SAndroid Build Coastguard Worker        hash_function() = _VSTD::move(__u.hash_function());
1663*58b9f456SAndroid Build Coastguard Worker        key_eq() = _VSTD::move(__u.key_eq());
1664*58b9f456SAndroid Build Coastguard Worker        max_load_factor() = __u.max_load_factor();
1665*58b9f456SAndroid Build Coastguard Worker        if (bucket_count() != 0)
1666*58b9f456SAndroid Build Coastguard Worker        {
1667*58b9f456SAndroid Build Coastguard Worker            __next_pointer __cache = __detach();
1668*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1669*58b9f456SAndroid Build Coastguard Worker            try
1670*58b9f456SAndroid Build Coastguard Worker            {
1671*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1672*58b9f456SAndroid Build Coastguard Worker                const_iterator __i = __u.begin();
1673*58b9f456SAndroid Build Coastguard Worker                while (__cache != nullptr && __u.size() != 0)
1674*58b9f456SAndroid Build Coastguard Worker                {
1675*58b9f456SAndroid Build Coastguard Worker                    __cache->__upcast()->__value_ =
1676*58b9f456SAndroid Build Coastguard Worker                        _VSTD::move(__u.remove(__i++)->__value_);
1677*58b9f456SAndroid Build Coastguard Worker                    __next_pointer __next = __cache->__next_;
1678*58b9f456SAndroid Build Coastguard Worker                    __node_insert_multi(__cache->__upcast());
1679*58b9f456SAndroid Build Coastguard Worker                    __cache = __next;
1680*58b9f456SAndroid Build Coastguard Worker                }
1681*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1682*58b9f456SAndroid Build Coastguard Worker            }
1683*58b9f456SAndroid Build Coastguard Worker            catch (...)
1684*58b9f456SAndroid Build Coastguard Worker            {
1685*58b9f456SAndroid Build Coastguard Worker                __deallocate_node(__cache);
1686*58b9f456SAndroid Build Coastguard Worker                throw;
1687*58b9f456SAndroid Build Coastguard Worker            }
1688*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1689*58b9f456SAndroid Build Coastguard Worker            __deallocate_node(__cache);
1690*58b9f456SAndroid Build Coastguard Worker        }
1691*58b9f456SAndroid Build Coastguard Worker        const_iterator __i = __u.begin();
1692*58b9f456SAndroid Build Coastguard Worker        while (__u.size() != 0)
1693*58b9f456SAndroid Build Coastguard Worker        {
1694*58b9f456SAndroid Build Coastguard Worker            __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_));
1695*58b9f456SAndroid Build Coastguard Worker            __node_insert_multi(__h.get());
1696*58b9f456SAndroid Build Coastguard Worker            __h.release();
1697*58b9f456SAndroid Build Coastguard Worker        }
1698*58b9f456SAndroid Build Coastguard Worker    }
1699*58b9f456SAndroid Build Coastguard Worker}
1700*58b9f456SAndroid Build Coastguard Worker
1701*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1702*58b9f456SAndroid Build Coastguard Workerinline
1703*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>&
1704*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
1705*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(
1706*58b9f456SAndroid Build Coastguard Worker        __node_traits::propagate_on_container_move_assignment::value &&
1707*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<__node_allocator>::value &&
1708*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<hasher>::value &&
1709*58b9f456SAndroid Build Coastguard Worker        is_nothrow_move_assignable<key_equal>::value)
1710*58b9f456SAndroid Build Coastguard Worker{
1711*58b9f456SAndroid Build Coastguard Worker    __move_assign(__u, integral_constant<bool,
1712*58b9f456SAndroid Build Coastguard Worker                  __node_traits::propagate_on_container_move_assignment::value>());
1713*58b9f456SAndroid Build Coastguard Worker    return *this;
1714*58b9f456SAndroid Build Coastguard Worker}
1715*58b9f456SAndroid Build Coastguard Worker
1716*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1717*58b9f456SAndroid Build Coastguard Worker
1718*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1719*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
1720*58b9f456SAndroid Build Coastguard Workervoid
1721*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first,
1722*58b9f456SAndroid Build Coastguard Worker                                                          _InputIterator __last)
1723*58b9f456SAndroid Build Coastguard Worker{
1724*58b9f456SAndroid Build Coastguard Worker    typedef iterator_traits<_InputIterator> _ITraits;
1725*58b9f456SAndroid Build Coastguard Worker    typedef typename _ITraits::value_type _ItValueType;
1726*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<_ItValueType, __container_value_type>::value),
1727*58b9f456SAndroid Build Coastguard Worker                  "__assign_unique may only be called with the containers value type");
1728*58b9f456SAndroid Build Coastguard Worker
1729*58b9f456SAndroid Build Coastguard Worker    if (bucket_count() != 0)
1730*58b9f456SAndroid Build Coastguard Worker    {
1731*58b9f456SAndroid Build Coastguard Worker        __next_pointer __cache = __detach();
1732*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1733*58b9f456SAndroid Build Coastguard Worker        try
1734*58b9f456SAndroid Build Coastguard Worker        {
1735*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1736*58b9f456SAndroid Build Coastguard Worker            for (; __cache != nullptr && __first != __last; ++__first)
1737*58b9f456SAndroid Build Coastguard Worker            {
1738*58b9f456SAndroid Build Coastguard Worker                __cache->__upcast()->__value_ = *__first;
1739*58b9f456SAndroid Build Coastguard Worker                __next_pointer __next = __cache->__next_;
1740*58b9f456SAndroid Build Coastguard Worker                __node_insert_unique(__cache->__upcast());
1741*58b9f456SAndroid Build Coastguard Worker                __cache = __next;
1742*58b9f456SAndroid Build Coastguard Worker            }
1743*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1744*58b9f456SAndroid Build Coastguard Worker        }
1745*58b9f456SAndroid Build Coastguard Worker        catch (...)
1746*58b9f456SAndroid Build Coastguard Worker        {
1747*58b9f456SAndroid Build Coastguard Worker            __deallocate_node(__cache);
1748*58b9f456SAndroid Build Coastguard Worker            throw;
1749*58b9f456SAndroid Build Coastguard Worker        }
1750*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1751*58b9f456SAndroid Build Coastguard Worker        __deallocate_node(__cache);
1752*58b9f456SAndroid Build Coastguard Worker    }
1753*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
1754*58b9f456SAndroid Build Coastguard Worker        __insert_unique(*__first);
1755*58b9f456SAndroid Build Coastguard Worker}
1756*58b9f456SAndroid Build Coastguard Worker
1757*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1758*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
1759*58b9f456SAndroid Build Coastguard Workervoid
1760*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
1761*58b9f456SAndroid Build Coastguard Worker                                                         _InputIterator __last)
1762*58b9f456SAndroid Build Coastguard Worker{
1763*58b9f456SAndroid Build Coastguard Worker    typedef iterator_traits<_InputIterator> _ITraits;
1764*58b9f456SAndroid Build Coastguard Worker    typedef typename _ITraits::value_type _ItValueType;
1765*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<_ItValueType, __container_value_type>::value ||
1766*58b9f456SAndroid Build Coastguard Worker                  is_same<_ItValueType, __node_value_type>::value),
1767*58b9f456SAndroid Build Coastguard Worker                  "__assign_multi may only be called with the containers value type"
1768*58b9f456SAndroid Build Coastguard Worker                  " or the nodes value type");
1769*58b9f456SAndroid Build Coastguard Worker    if (bucket_count() != 0)
1770*58b9f456SAndroid Build Coastguard Worker    {
1771*58b9f456SAndroid Build Coastguard Worker        __next_pointer __cache = __detach();
1772*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1773*58b9f456SAndroid Build Coastguard Worker        try
1774*58b9f456SAndroid Build Coastguard Worker        {
1775*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1776*58b9f456SAndroid Build Coastguard Worker            for (; __cache != nullptr && __first != __last; ++__first)
1777*58b9f456SAndroid Build Coastguard Worker            {
1778*58b9f456SAndroid Build Coastguard Worker                __cache->__upcast()->__value_ = *__first;
1779*58b9f456SAndroid Build Coastguard Worker                __next_pointer __next = __cache->__next_;
1780*58b9f456SAndroid Build Coastguard Worker                __node_insert_multi(__cache->__upcast());
1781*58b9f456SAndroid Build Coastguard Worker                __cache = __next;
1782*58b9f456SAndroid Build Coastguard Worker            }
1783*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1784*58b9f456SAndroid Build Coastguard Worker        }
1785*58b9f456SAndroid Build Coastguard Worker        catch (...)
1786*58b9f456SAndroid Build Coastguard Worker        {
1787*58b9f456SAndroid Build Coastguard Worker            __deallocate_node(__cache);
1788*58b9f456SAndroid Build Coastguard Worker            throw;
1789*58b9f456SAndroid Build Coastguard Worker        }
1790*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1791*58b9f456SAndroid Build Coastguard Worker        __deallocate_node(__cache);
1792*58b9f456SAndroid Build Coastguard Worker    }
1793*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
1794*58b9f456SAndroid Build Coastguard Worker        __insert_multi(_NodeTypes::__get_value(*__first));
1795*58b9f456SAndroid Build Coastguard Worker}
1796*58b9f456SAndroid Build Coastguard Worker
1797*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1798*58b9f456SAndroid Build Coastguard Workerinline
1799*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1800*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
1801*58b9f456SAndroid Build Coastguard Worker{
1802*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1803*58b9f456SAndroid Build Coastguard Worker    return iterator(__p1_.first().__next_, this);
1804*58b9f456SAndroid Build Coastguard Worker#else
1805*58b9f456SAndroid Build Coastguard Worker    return iterator(__p1_.first().__next_);
1806*58b9f456SAndroid Build Coastguard Worker#endif
1807*58b9f456SAndroid Build Coastguard Worker}
1808*58b9f456SAndroid Build Coastguard Worker
1809*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1810*58b9f456SAndroid Build Coastguard Workerinline
1811*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1812*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
1813*58b9f456SAndroid Build Coastguard Worker{
1814*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1815*58b9f456SAndroid Build Coastguard Worker    return iterator(nullptr, this);
1816*58b9f456SAndroid Build Coastguard Worker#else
1817*58b9f456SAndroid Build Coastguard Worker    return iterator(nullptr);
1818*58b9f456SAndroid Build Coastguard Worker#endif
1819*58b9f456SAndroid Build Coastguard Worker}
1820*58b9f456SAndroid Build Coastguard Worker
1821*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1822*58b9f456SAndroid Build Coastguard Workerinline
1823*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1824*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
1825*58b9f456SAndroid Build Coastguard Worker{
1826*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1827*58b9f456SAndroid Build Coastguard Worker    return const_iterator(__p1_.first().__next_, this);
1828*58b9f456SAndroid Build Coastguard Worker#else
1829*58b9f456SAndroid Build Coastguard Worker    return const_iterator(__p1_.first().__next_);
1830*58b9f456SAndroid Build Coastguard Worker#endif
1831*58b9f456SAndroid Build Coastguard Worker}
1832*58b9f456SAndroid Build Coastguard Worker
1833*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1834*58b9f456SAndroid Build Coastguard Workerinline
1835*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1836*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
1837*58b9f456SAndroid Build Coastguard Worker{
1838*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1839*58b9f456SAndroid Build Coastguard Worker    return const_iterator(nullptr, this);
1840*58b9f456SAndroid Build Coastguard Worker#else
1841*58b9f456SAndroid Build Coastguard Worker    return const_iterator(nullptr);
1842*58b9f456SAndroid Build Coastguard Worker#endif
1843*58b9f456SAndroid Build Coastguard Worker}
1844*58b9f456SAndroid Build Coastguard Worker
1845*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1846*58b9f456SAndroid Build Coastguard Workervoid
1847*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT
1848*58b9f456SAndroid Build Coastguard Worker{
1849*58b9f456SAndroid Build Coastguard Worker    if (size() > 0)
1850*58b9f456SAndroid Build Coastguard Worker    {
1851*58b9f456SAndroid Build Coastguard Worker        __deallocate_node(__p1_.first().__next_);
1852*58b9f456SAndroid Build Coastguard Worker        __p1_.first().__next_ = nullptr;
1853*58b9f456SAndroid Build Coastguard Worker        size_type __bc = bucket_count();
1854*58b9f456SAndroid Build Coastguard Worker        for (size_type __i = 0; __i < __bc; ++__i)
1855*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__i] = nullptr;
1856*58b9f456SAndroid Build Coastguard Worker        size() = 0;
1857*58b9f456SAndroid Build Coastguard Worker    }
1858*58b9f456SAndroid Build Coastguard Worker}
1859*58b9f456SAndroid Build Coastguard Worker
1860*58b9f456SAndroid Build Coastguard Worker
1861*58b9f456SAndroid Build Coastguard Worker// Prepare the container for an insertion of the value __value with the hash
1862*58b9f456SAndroid Build Coastguard Worker// __hash. This does a lookup into the container to see if __value is already
1863*58b9f456SAndroid Build Coastguard Worker// present, and performs a rehash if necessary. Returns a pointer to the
1864*58b9f456SAndroid Build Coastguard Worker// existing element if it exists, otherwise nullptr.
1865*58b9f456SAndroid Build Coastguard Worker//
1866*58b9f456SAndroid Build Coastguard Worker// Note that this function does forward exceptions if key_eq() throws, and never
1867*58b9f456SAndroid Build Coastguard Worker// mutates __value or actually inserts into the map.
1868*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1869*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
1870*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
1871*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
1872*58b9f456SAndroid Build Coastguard Worker    size_t __hash, value_type& __value)
1873*58b9f456SAndroid Build Coastguard Worker{
1874*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
1875*58b9f456SAndroid Build Coastguard Worker
1876*58b9f456SAndroid Build Coastguard Worker    if (__bc != 0)
1877*58b9f456SAndroid Build Coastguard Worker    {
1878*58b9f456SAndroid Build Coastguard Worker        size_t __chash = __constrain_hash(__hash, __bc);
1879*58b9f456SAndroid Build Coastguard Worker        __next_pointer __ndptr = __bucket_list_[__chash];
1880*58b9f456SAndroid Build Coastguard Worker        if (__ndptr != nullptr)
1881*58b9f456SAndroid Build Coastguard Worker        {
1882*58b9f456SAndroid Build Coastguard Worker            for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&
1883*58b9f456SAndroid Build Coastguard Worker                                             __constrain_hash(__ndptr->__hash(), __bc) == __chash;
1884*58b9f456SAndroid Build Coastguard Worker                                                     __ndptr = __ndptr->__next_)
1885*58b9f456SAndroid Build Coastguard Worker            {
1886*58b9f456SAndroid Build Coastguard Worker                if (key_eq()(__ndptr->__upcast()->__value_, __value))
1887*58b9f456SAndroid Build Coastguard Worker                    return __ndptr;
1888*58b9f456SAndroid Build Coastguard Worker            }
1889*58b9f456SAndroid Build Coastguard Worker        }
1890*58b9f456SAndroid Build Coastguard Worker    }
1891*58b9f456SAndroid Build Coastguard Worker    if (size()+1 > __bc * max_load_factor() || __bc == 0)
1892*58b9f456SAndroid Build Coastguard Worker    {
1893*58b9f456SAndroid Build Coastguard Worker        rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1894*58b9f456SAndroid Build Coastguard Worker                                     size_type(ceil(float(size() + 1) / max_load_factor()))));
1895*58b9f456SAndroid Build Coastguard Worker    }
1896*58b9f456SAndroid Build Coastguard Worker    return nullptr;
1897*58b9f456SAndroid Build Coastguard Worker}
1898*58b9f456SAndroid Build Coastguard Worker
1899*58b9f456SAndroid Build Coastguard Worker// Insert the node __nd into the container by pushing it into the right bucket,
1900*58b9f456SAndroid Build Coastguard Worker// and updating size(). Assumes that __nd->__hash is up-to-date, and that
1901*58b9f456SAndroid Build Coastguard Worker// rehashing has already occurred and that no element with the same key exists
1902*58b9f456SAndroid Build Coastguard Worker// in the map.
1903*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1904*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
1905*58b9f456SAndroid Build Coastguard Workervoid
1906*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
1907*58b9f456SAndroid Build Coastguard Worker    __node_pointer __nd) _NOEXCEPT
1908*58b9f456SAndroid Build Coastguard Worker{
1909*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
1910*58b9f456SAndroid Build Coastguard Worker    size_t __chash = __constrain_hash(__nd->__hash(), __bc);
1911*58b9f456SAndroid Build Coastguard Worker    // insert_after __bucket_list_[__chash], or __first_node if bucket is null
1912*58b9f456SAndroid Build Coastguard Worker    __next_pointer __pn = __bucket_list_[__chash];
1913*58b9f456SAndroid Build Coastguard Worker    if (__pn == nullptr)
1914*58b9f456SAndroid Build Coastguard Worker    {
1915*58b9f456SAndroid Build Coastguard Worker        __pn =__p1_.first().__ptr();
1916*58b9f456SAndroid Build Coastguard Worker        __nd->__next_ = __pn->__next_;
1917*58b9f456SAndroid Build Coastguard Worker        __pn->__next_ = __nd->__ptr();
1918*58b9f456SAndroid Build Coastguard Worker        // fix up __bucket_list_
1919*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__chash] = __pn;
1920*58b9f456SAndroid Build Coastguard Worker        if (__nd->__next_ != nullptr)
1921*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
1922*58b9f456SAndroid Build Coastguard Worker    }
1923*58b9f456SAndroid Build Coastguard Worker    else
1924*58b9f456SAndroid Build Coastguard Worker    {
1925*58b9f456SAndroid Build Coastguard Worker        __nd->__next_ = __pn->__next_;
1926*58b9f456SAndroid Build Coastguard Worker        __pn->__next_ = __nd->__ptr();
1927*58b9f456SAndroid Build Coastguard Worker    }
1928*58b9f456SAndroid Build Coastguard Worker    ++size();
1929*58b9f456SAndroid Build Coastguard Worker}
1930*58b9f456SAndroid Build Coastguard Worker
1931*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1932*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
1933*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd)
1934*58b9f456SAndroid Build Coastguard Worker{
1935*58b9f456SAndroid Build Coastguard Worker    __nd->__hash_ = hash_function()(__nd->__value_);
1936*58b9f456SAndroid Build Coastguard Worker    __next_pointer __existing_node =
1937*58b9f456SAndroid Build Coastguard Worker        __node_insert_unique_prepare(__nd->__hash(), __nd->__value_);
1938*58b9f456SAndroid Build Coastguard Worker
1939*58b9f456SAndroid Build Coastguard Worker    // Insert the node, unless it already exists in the container.
1940*58b9f456SAndroid Build Coastguard Worker    bool __inserted = false;
1941*58b9f456SAndroid Build Coastguard Worker    if (__existing_node == nullptr)
1942*58b9f456SAndroid Build Coastguard Worker    {
1943*58b9f456SAndroid Build Coastguard Worker        __node_insert_unique_perform(__nd);
1944*58b9f456SAndroid Build Coastguard Worker        __existing_node = __nd->__ptr();
1945*58b9f456SAndroid Build Coastguard Worker        __inserted = true;
1946*58b9f456SAndroid Build Coastguard Worker    }
1947*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1948*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, bool>(iterator(__existing_node, this), __inserted);
1949*58b9f456SAndroid Build Coastguard Worker#else
1950*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, bool>(iterator(__existing_node), __inserted);
1951*58b9f456SAndroid Build Coastguard Worker#endif
1952*58b9f456SAndroid Build Coastguard Worker}
1953*58b9f456SAndroid Build Coastguard Worker
1954*58b9f456SAndroid Build Coastguard Worker// Prepare the container for an insertion of the value __cp_val with the hash
1955*58b9f456SAndroid Build Coastguard Worker// __cp_hash. This does a lookup into the container to see if __cp_value is
1956*58b9f456SAndroid Build Coastguard Worker// already present, and performs a rehash if necessary. Returns a pointer to the
1957*58b9f456SAndroid Build Coastguard Worker// last occurance of __cp_val in the map.
1958*58b9f456SAndroid Build Coastguard Worker//
1959*58b9f456SAndroid Build Coastguard Worker// Note that this function does forward exceptions if key_eq() throws, and never
1960*58b9f456SAndroid Build Coastguard Worker// mutates __value or actually inserts into the map.
1961*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
1962*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer
1963*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
1964*58b9f456SAndroid Build Coastguard Worker    size_t __cp_hash, value_type& __cp_val)
1965*58b9f456SAndroid Build Coastguard Worker{
1966*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
1967*58b9f456SAndroid Build Coastguard Worker    if (size()+1 > __bc * max_load_factor() || __bc == 0)
1968*58b9f456SAndroid Build Coastguard Worker    {
1969*58b9f456SAndroid Build Coastguard Worker        rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1970*58b9f456SAndroid Build Coastguard Worker                       size_type(ceil(float(size() + 1) / max_load_factor()))));
1971*58b9f456SAndroid Build Coastguard Worker        __bc = bucket_count();
1972*58b9f456SAndroid Build Coastguard Worker    }
1973*58b9f456SAndroid Build Coastguard Worker    size_t __chash = __constrain_hash(__cp_hash, __bc);
1974*58b9f456SAndroid Build Coastguard Worker    __next_pointer __pn = __bucket_list_[__chash];
1975*58b9f456SAndroid Build Coastguard Worker    if (__pn != nullptr)
1976*58b9f456SAndroid Build Coastguard Worker    {
1977*58b9f456SAndroid Build Coastguard Worker        for (bool __found = false; __pn->__next_ != nullptr &&
1978*58b9f456SAndroid Build Coastguard Worker                                   __constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
1979*58b9f456SAndroid Build Coastguard Worker                                                           __pn = __pn->__next_)
1980*58b9f456SAndroid Build Coastguard Worker        {
1981*58b9f456SAndroid Build Coastguard Worker            //      __found    key_eq()     action
1982*58b9f456SAndroid Build Coastguard Worker            //      false       false       loop
1983*58b9f456SAndroid Build Coastguard Worker            //      true        true        loop
1984*58b9f456SAndroid Build Coastguard Worker            //      false       true        set __found to true
1985*58b9f456SAndroid Build Coastguard Worker            //      true        false       break
1986*58b9f456SAndroid Build Coastguard Worker            if (__found != (__pn->__next_->__hash() == __cp_hash &&
1987*58b9f456SAndroid Build Coastguard Worker                            key_eq()(__pn->__next_->__upcast()->__value_, __cp_val)))
1988*58b9f456SAndroid Build Coastguard Worker            {
1989*58b9f456SAndroid Build Coastguard Worker                if (!__found)
1990*58b9f456SAndroid Build Coastguard Worker                    __found = true;
1991*58b9f456SAndroid Build Coastguard Worker                else
1992*58b9f456SAndroid Build Coastguard Worker                    break;
1993*58b9f456SAndroid Build Coastguard Worker            }
1994*58b9f456SAndroid Build Coastguard Worker        }
1995*58b9f456SAndroid Build Coastguard Worker    }
1996*58b9f456SAndroid Build Coastguard Worker    return __pn;
1997*58b9f456SAndroid Build Coastguard Worker}
1998*58b9f456SAndroid Build Coastguard Worker
1999*58b9f456SAndroid Build Coastguard Worker// Insert the node __cp into the container after __pn (which is the last node in
2000*58b9f456SAndroid Build Coastguard Worker// the bucket that compares equal to __cp). Rehashing, and checking for
2001*58b9f456SAndroid Build Coastguard Worker// uniqueness has already been performed (in __node_insert_multi_prepare), so
2002*58b9f456SAndroid Build Coastguard Worker// all we need to do is update the bucket and size(). Assumes that __cp->__hash
2003*58b9f456SAndroid Build Coastguard Worker// is up-to-date.
2004*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2005*58b9f456SAndroid Build Coastguard Workervoid
2006*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
2007*58b9f456SAndroid Build Coastguard Worker    __node_pointer __cp, __next_pointer __pn) _NOEXCEPT
2008*58b9f456SAndroid Build Coastguard Worker{
2009*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2010*58b9f456SAndroid Build Coastguard Worker    size_t __chash = __constrain_hash(__cp->__hash_, __bc);
2011*58b9f456SAndroid Build Coastguard Worker    if (__pn == nullptr)
2012*58b9f456SAndroid Build Coastguard Worker    {
2013*58b9f456SAndroid Build Coastguard Worker        __pn =__p1_.first().__ptr();
2014*58b9f456SAndroid Build Coastguard Worker        __cp->__next_ = __pn->__next_;
2015*58b9f456SAndroid Build Coastguard Worker        __pn->__next_ = __cp->__ptr();
2016*58b9f456SAndroid Build Coastguard Worker        // fix up __bucket_list_
2017*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__chash] = __pn;
2018*58b9f456SAndroid Build Coastguard Worker        if (__cp->__next_ != nullptr)
2019*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)]
2020*58b9f456SAndroid Build Coastguard Worker                = __cp->__ptr();
2021*58b9f456SAndroid Build Coastguard Worker    }
2022*58b9f456SAndroid Build Coastguard Worker    else
2023*58b9f456SAndroid Build Coastguard Worker    {
2024*58b9f456SAndroid Build Coastguard Worker        __cp->__next_ = __pn->__next_;
2025*58b9f456SAndroid Build Coastguard Worker        __pn->__next_ = __cp->__ptr();
2026*58b9f456SAndroid Build Coastguard Worker        if (__cp->__next_ != nullptr)
2027*58b9f456SAndroid Build Coastguard Worker        {
2028*58b9f456SAndroid Build Coastguard Worker            size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc);
2029*58b9f456SAndroid Build Coastguard Worker            if (__nhash != __chash)
2030*58b9f456SAndroid Build Coastguard Worker                __bucket_list_[__nhash] = __cp->__ptr();
2031*58b9f456SAndroid Build Coastguard Worker        }
2032*58b9f456SAndroid Build Coastguard Worker    }
2033*58b9f456SAndroid Build Coastguard Worker    ++size();
2034*58b9f456SAndroid Build Coastguard Worker}
2035*58b9f456SAndroid Build Coastguard Worker
2036*58b9f456SAndroid Build Coastguard Worker
2037*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2038*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2039*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp)
2040*58b9f456SAndroid Build Coastguard Worker{
2041*58b9f456SAndroid Build Coastguard Worker    __cp->__hash_ = hash_function()(__cp->__value_);
2042*58b9f456SAndroid Build Coastguard Worker    __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_);
2043*58b9f456SAndroid Build Coastguard Worker    __node_insert_multi_perform(__cp, __pn);
2044*58b9f456SAndroid Build Coastguard Worker
2045*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2046*58b9f456SAndroid Build Coastguard Worker    return iterator(__cp->__ptr(), this);
2047*58b9f456SAndroid Build Coastguard Worker#else
2048*58b9f456SAndroid Build Coastguard Worker    return iterator(__cp->__ptr());
2049*58b9f456SAndroid Build Coastguard Worker#endif
2050*58b9f456SAndroid Build Coastguard Worker}
2051*58b9f456SAndroid Build Coastguard Worker
2052*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2053*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2054*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
2055*58b9f456SAndroid Build Coastguard Worker        const_iterator __p, __node_pointer __cp)
2056*58b9f456SAndroid Build Coastguard Worker{
2057*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2058*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2059*58b9f456SAndroid Build Coastguard Worker        "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
2060*58b9f456SAndroid Build Coastguard Worker        " referring to this unordered container");
2061*58b9f456SAndroid Build Coastguard Worker#endif
2062*58b9f456SAndroid Build Coastguard Worker    if (__p != end() && key_eq()(*__p, __cp->__value_))
2063*58b9f456SAndroid Build Coastguard Worker    {
2064*58b9f456SAndroid Build Coastguard Worker        __next_pointer __np = __p.__node_;
2065*58b9f456SAndroid Build Coastguard Worker        __cp->__hash_ = __np->__hash();
2066*58b9f456SAndroid Build Coastguard Worker        size_type __bc = bucket_count();
2067*58b9f456SAndroid Build Coastguard Worker        if (size()+1 > __bc * max_load_factor() || __bc == 0)
2068*58b9f456SAndroid Build Coastguard Worker        {
2069*58b9f456SAndroid Build Coastguard Worker            rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
2070*58b9f456SAndroid Build Coastguard Worker                           size_type(ceil(float(size() + 1) / max_load_factor()))));
2071*58b9f456SAndroid Build Coastguard Worker            __bc = bucket_count();
2072*58b9f456SAndroid Build Coastguard Worker        }
2073*58b9f456SAndroid Build Coastguard Worker        size_t __chash = __constrain_hash(__cp->__hash_, __bc);
2074*58b9f456SAndroid Build Coastguard Worker        __next_pointer __pp = __bucket_list_[__chash];
2075*58b9f456SAndroid Build Coastguard Worker        while (__pp->__next_ != __np)
2076*58b9f456SAndroid Build Coastguard Worker            __pp = __pp->__next_;
2077*58b9f456SAndroid Build Coastguard Worker        __cp->__next_ = __np;
2078*58b9f456SAndroid Build Coastguard Worker        __pp->__next_ = static_cast<__next_pointer>(__cp);
2079*58b9f456SAndroid Build Coastguard Worker        ++size();
2080*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2081*58b9f456SAndroid Build Coastguard Worker        return iterator(static_cast<__next_pointer>(__cp), this);
2082*58b9f456SAndroid Build Coastguard Worker#else
2083*58b9f456SAndroid Build Coastguard Worker        return iterator(static_cast<__next_pointer>(__cp));
2084*58b9f456SAndroid Build Coastguard Worker#endif
2085*58b9f456SAndroid Build Coastguard Worker    }
2086*58b9f456SAndroid Build Coastguard Worker    return __node_insert_multi(__cp);
2087*58b9f456SAndroid Build Coastguard Worker}
2088*58b9f456SAndroid Build Coastguard Worker
2089*58b9f456SAndroid Build Coastguard Worker
2090*58b9f456SAndroid Build Coastguard Worker
2091*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2092*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2093*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class ..._Args>
2094*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
2095*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args)
2096*58b9f456SAndroid Build Coastguard Worker#else
2097*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2098*58b9f456SAndroid Build Coastguard Workertemplate <class _Key, class _Args>
2099*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
2100*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args)
2101*58b9f456SAndroid Build Coastguard Worker#endif
2102*58b9f456SAndroid Build Coastguard Worker{
2103*58b9f456SAndroid Build Coastguard Worker
2104*58b9f456SAndroid Build Coastguard Worker    size_t __hash = hash_function()(__k);
2105*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2106*58b9f456SAndroid Build Coastguard Worker    bool __inserted = false;
2107*58b9f456SAndroid Build Coastguard Worker    __next_pointer __nd;
2108*58b9f456SAndroid Build Coastguard Worker    size_t __chash;
2109*58b9f456SAndroid Build Coastguard Worker    if (__bc != 0)
2110*58b9f456SAndroid Build Coastguard Worker    {
2111*58b9f456SAndroid Build Coastguard Worker        __chash = __constrain_hash(__hash, __bc);
2112*58b9f456SAndroid Build Coastguard Worker        __nd = __bucket_list_[__chash];
2113*58b9f456SAndroid Build Coastguard Worker        if (__nd != nullptr)
2114*58b9f456SAndroid Build Coastguard Worker        {
2115*58b9f456SAndroid Build Coastguard Worker            for (__nd = __nd->__next_; __nd != nullptr &&
2116*58b9f456SAndroid Build Coastguard Worker                (__nd->__hash() == __hash || __constrain_hash(__nd->__hash(), __bc) == __chash);
2117*58b9f456SAndroid Build Coastguard Worker                                                           __nd = __nd->__next_)
2118*58b9f456SAndroid Build Coastguard Worker            {
2119*58b9f456SAndroid Build Coastguard Worker                if (key_eq()(__nd->__upcast()->__value_, __k))
2120*58b9f456SAndroid Build Coastguard Worker                    goto __done;
2121*58b9f456SAndroid Build Coastguard Worker            }
2122*58b9f456SAndroid Build Coastguard Worker        }
2123*58b9f456SAndroid Build Coastguard Worker    }
2124*58b9f456SAndroid Build Coastguard Worker    {
2125*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2126*58b9f456SAndroid Build Coastguard Worker        __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
2127*58b9f456SAndroid Build Coastguard Worker#else
2128*58b9f456SAndroid Build Coastguard Worker        __node_holder __h = __construct_node_hash(__hash, __args);
2129*58b9f456SAndroid Build Coastguard Worker#endif
2130*58b9f456SAndroid Build Coastguard Worker        if (size()+1 > __bc * max_load_factor() || __bc == 0)
2131*58b9f456SAndroid Build Coastguard Worker        {
2132*58b9f456SAndroid Build Coastguard Worker            rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
2133*58b9f456SAndroid Build Coastguard Worker                           size_type(ceil(float(size() + 1) / max_load_factor()))));
2134*58b9f456SAndroid Build Coastguard Worker            __bc = bucket_count();
2135*58b9f456SAndroid Build Coastguard Worker            __chash = __constrain_hash(__hash, __bc);
2136*58b9f456SAndroid Build Coastguard Worker        }
2137*58b9f456SAndroid Build Coastguard Worker        // insert_after __bucket_list_[__chash], or __first_node if bucket is null
2138*58b9f456SAndroid Build Coastguard Worker        __next_pointer __pn = __bucket_list_[__chash];
2139*58b9f456SAndroid Build Coastguard Worker        if (__pn == nullptr)
2140*58b9f456SAndroid Build Coastguard Worker        {
2141*58b9f456SAndroid Build Coastguard Worker            __pn = __p1_.first().__ptr();
2142*58b9f456SAndroid Build Coastguard Worker            __h->__next_ = __pn->__next_;
2143*58b9f456SAndroid Build Coastguard Worker            __pn->__next_ = __h.get()->__ptr();
2144*58b9f456SAndroid Build Coastguard Worker            // fix up __bucket_list_
2145*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__chash] = __pn;
2146*58b9f456SAndroid Build Coastguard Worker            if (__h->__next_ != nullptr)
2147*58b9f456SAndroid Build Coastguard Worker                __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)]
2148*58b9f456SAndroid Build Coastguard Worker                    = __h.get()->__ptr();
2149*58b9f456SAndroid Build Coastguard Worker        }
2150*58b9f456SAndroid Build Coastguard Worker        else
2151*58b9f456SAndroid Build Coastguard Worker        {
2152*58b9f456SAndroid Build Coastguard Worker            __h->__next_ = __pn->__next_;
2153*58b9f456SAndroid Build Coastguard Worker            __pn->__next_ = static_cast<__next_pointer>(__h.get());
2154*58b9f456SAndroid Build Coastguard Worker        }
2155*58b9f456SAndroid Build Coastguard Worker        __nd = static_cast<__next_pointer>(__h.release());
2156*58b9f456SAndroid Build Coastguard Worker        // increment size
2157*58b9f456SAndroid Build Coastguard Worker        ++size();
2158*58b9f456SAndroid Build Coastguard Worker        __inserted = true;
2159*58b9f456SAndroid Build Coastguard Worker    }
2160*58b9f456SAndroid Build Coastguard Worker__done:
2161*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2162*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, bool>(iterator(__nd, this), __inserted);
2163*58b9f456SAndroid Build Coastguard Worker#else
2164*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, bool>(iterator(__nd), __inserted);
2165*58b9f456SAndroid Build Coastguard Worker#endif
2166*58b9f456SAndroid Build Coastguard Worker}
2167*58b9f456SAndroid Build Coastguard Worker
2168*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2169*58b9f456SAndroid Build Coastguard Worker
2170*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2171*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
2172*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
2173*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args)
2174*58b9f456SAndroid Build Coastguard Worker{
2175*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2176*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __r = __node_insert_unique(__h.get());
2177*58b9f456SAndroid Build Coastguard Worker    if (__r.second)
2178*58b9f456SAndroid Build Coastguard Worker        __h.release();
2179*58b9f456SAndroid Build Coastguard Worker    return __r;
2180*58b9f456SAndroid Build Coastguard Worker}
2181*58b9f456SAndroid Build Coastguard Worker
2182*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2183*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
2184*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2185*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args)
2186*58b9f456SAndroid Build Coastguard Worker{
2187*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2188*58b9f456SAndroid Build Coastguard Worker    iterator __r = __node_insert_multi(__h.get());
2189*58b9f456SAndroid Build Coastguard Worker    __h.release();
2190*58b9f456SAndroid Build Coastguard Worker    return __r;
2191*58b9f456SAndroid Build Coastguard Worker}
2192*58b9f456SAndroid Build Coastguard Worker
2193*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2194*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
2195*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2196*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
2197*58b9f456SAndroid Build Coastguard Worker        const_iterator __p, _Args&&... __args)
2198*58b9f456SAndroid Build Coastguard Worker{
2199*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2200*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2201*58b9f456SAndroid Build Coastguard Worker        "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
2202*58b9f456SAndroid Build Coastguard Worker        " referring to this unordered container");
2203*58b9f456SAndroid Build Coastguard Worker#endif
2204*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
2205*58b9f456SAndroid Build Coastguard Worker    iterator __r = __node_insert_multi(__p, __h.get());
2206*58b9f456SAndroid Build Coastguard Worker    __h.release();
2207*58b9f456SAndroid Build Coastguard Worker    return __r;
2208*58b9f456SAndroid Build Coastguard Worker}
2209*58b9f456SAndroid Build Coastguard Worker
2210*58b9f456SAndroid Build Coastguard Worker#else // _LIBCPP_CXX03_LANG
2211*58b9f456SAndroid Build Coastguard Worker
2212*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2213*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2214*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x)
2215*58b9f456SAndroid Build Coastguard Worker{
2216*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(__x);
2217*58b9f456SAndroid Build Coastguard Worker    iterator __r = __node_insert_multi(__h.get());
2218*58b9f456SAndroid Build Coastguard Worker    __h.release();
2219*58b9f456SAndroid Build Coastguard Worker    return __r;
2220*58b9f456SAndroid Build Coastguard Worker}
2221*58b9f456SAndroid Build Coastguard Worker
2222*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2223*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2224*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
2225*58b9f456SAndroid Build Coastguard Worker                                                         const __container_value_type& __x)
2226*58b9f456SAndroid Build Coastguard Worker{
2227*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2228*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2229*58b9f456SAndroid Build Coastguard Worker        "unordered container::insert(const_iterator, lvalue) called with an iterator not"
2230*58b9f456SAndroid Build Coastguard Worker        " referring to this unordered container");
2231*58b9f456SAndroid Build Coastguard Worker#endif
2232*58b9f456SAndroid Build Coastguard Worker    __node_holder __h = __construct_node(__x);
2233*58b9f456SAndroid Build Coastguard Worker    iterator __r = __node_insert_multi(__p, __h.get());
2234*58b9f456SAndroid Build Coastguard Worker    __h.release();
2235*58b9f456SAndroid Build Coastguard Worker    return __r;
2236*58b9f456SAndroid Build Coastguard Worker}
2237*58b9f456SAndroid Build Coastguard Worker
2238*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
2239*58b9f456SAndroid Build Coastguard Worker
2240*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
2241*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2242*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle, class _InsertReturnType>
2243*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2244*58b9f456SAndroid Build Coastguard Worker_InsertReturnType
2245*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
2246*58b9f456SAndroid Build Coastguard Worker    _NodeHandle&& __nh)
2247*58b9f456SAndroid Build Coastguard Worker{
2248*58b9f456SAndroid Build Coastguard Worker    if (__nh.empty())
2249*58b9f456SAndroid Build Coastguard Worker        return _InsertReturnType{end(), false, _NodeHandle()};
2250*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
2251*58b9f456SAndroid Build Coastguard Worker    if (__result.second)
2252*58b9f456SAndroid Build Coastguard Worker        __nh.__release();
2253*58b9f456SAndroid Build Coastguard Worker    return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)};
2254*58b9f456SAndroid Build Coastguard Worker}
2255*58b9f456SAndroid Build Coastguard Worker
2256*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2257*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle>
2258*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2259*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2260*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
2261*58b9f456SAndroid Build Coastguard Worker    const_iterator, _NodeHandle&& __nh)
2262*58b9f456SAndroid Build Coastguard Worker{
2263*58b9f456SAndroid Build Coastguard Worker    if (__nh.empty())
2264*58b9f456SAndroid Build Coastguard Worker        return end();
2265*58b9f456SAndroid Build Coastguard Worker    pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
2266*58b9f456SAndroid Build Coastguard Worker    if (__result.second)
2267*58b9f456SAndroid Build Coastguard Worker        __nh.__release();
2268*58b9f456SAndroid Build Coastguard Worker    return __result.first;
2269*58b9f456SAndroid Build Coastguard Worker}
2270*58b9f456SAndroid Build Coastguard Worker
2271*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2272*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle>
2273*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2274*58b9f456SAndroid Build Coastguard Worker_NodeHandle
2275*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
2276*58b9f456SAndroid Build Coastguard Worker    key_type const& __key)
2277*58b9f456SAndroid Build Coastguard Worker{
2278*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__key);
2279*58b9f456SAndroid Build Coastguard Worker    if (__i == end())
2280*58b9f456SAndroid Build Coastguard Worker        return _NodeHandle();
2281*58b9f456SAndroid Build Coastguard Worker    return __node_handle_extract<_NodeHandle>(__i);
2282*58b9f456SAndroid Build Coastguard Worker}
2283*58b9f456SAndroid Build Coastguard Worker
2284*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2285*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle>
2286*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2287*58b9f456SAndroid Build Coastguard Worker_NodeHandle
2288*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
2289*58b9f456SAndroid Build Coastguard Worker    const_iterator __p)
2290*58b9f456SAndroid Build Coastguard Worker{
2291*58b9f456SAndroid Build Coastguard Worker    allocator_type __alloc(__node_alloc());
2292*58b9f456SAndroid Build Coastguard Worker    return _NodeHandle(remove(__p).release(), __alloc);
2293*58b9f456SAndroid Build Coastguard Worker}
2294*58b9f456SAndroid Build Coastguard Worker
2295*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2296*58b9f456SAndroid Build Coastguard Workertemplate <class _Table>
2297*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2298*58b9f456SAndroid Build Coastguard Workervoid
2299*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_unique(
2300*58b9f456SAndroid Build Coastguard Worker    _Table& __source)
2301*58b9f456SAndroid Build Coastguard Worker{
2302*58b9f456SAndroid Build Coastguard Worker    static_assert(is_same<__node, typename _Table::__node>::value, "");
2303*58b9f456SAndroid Build Coastguard Worker
2304*58b9f456SAndroid Build Coastguard Worker    for (typename _Table::iterator __it = __source.begin();
2305*58b9f456SAndroid Build Coastguard Worker         __it != __source.end();)
2306*58b9f456SAndroid Build Coastguard Worker    {
2307*58b9f456SAndroid Build Coastguard Worker        __node_pointer __src_ptr = __it.__node_->__upcast();
2308*58b9f456SAndroid Build Coastguard Worker        size_t __hash = hash_function()(__src_ptr->__value_);
2309*58b9f456SAndroid Build Coastguard Worker        __next_pointer __existing_node =
2310*58b9f456SAndroid Build Coastguard Worker            __node_insert_unique_prepare(__hash, __src_ptr->__value_);
2311*58b9f456SAndroid Build Coastguard Worker        auto __prev_iter = __it++;
2312*58b9f456SAndroid Build Coastguard Worker        if (__existing_node == nullptr)
2313*58b9f456SAndroid Build Coastguard Worker        {
2314*58b9f456SAndroid Build Coastguard Worker            (void)__source.remove(__prev_iter).release();
2315*58b9f456SAndroid Build Coastguard Worker            __src_ptr->__hash_ = __hash;
2316*58b9f456SAndroid Build Coastguard Worker            __node_insert_unique_perform(__src_ptr);
2317*58b9f456SAndroid Build Coastguard Worker        }
2318*58b9f456SAndroid Build Coastguard Worker    }
2319*58b9f456SAndroid Build Coastguard Worker}
2320*58b9f456SAndroid Build Coastguard Worker
2321*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2322*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle>
2323*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2324*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2325*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
2326*58b9f456SAndroid Build Coastguard Worker    _NodeHandle&& __nh)
2327*58b9f456SAndroid Build Coastguard Worker{
2328*58b9f456SAndroid Build Coastguard Worker    if (__nh.empty())
2329*58b9f456SAndroid Build Coastguard Worker        return end();
2330*58b9f456SAndroid Build Coastguard Worker    iterator __result = __node_insert_multi(__nh.__ptr_);
2331*58b9f456SAndroid Build Coastguard Worker    __nh.__release();
2332*58b9f456SAndroid Build Coastguard Worker    return __result;
2333*58b9f456SAndroid Build Coastguard Worker}
2334*58b9f456SAndroid Build Coastguard Worker
2335*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2336*58b9f456SAndroid Build Coastguard Workertemplate <class _NodeHandle>
2337*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2338*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2339*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
2340*58b9f456SAndroid Build Coastguard Worker    const_iterator __hint, _NodeHandle&& __nh)
2341*58b9f456SAndroid Build Coastguard Worker{
2342*58b9f456SAndroid Build Coastguard Worker    if (__nh.empty())
2343*58b9f456SAndroid Build Coastguard Worker        return end();
2344*58b9f456SAndroid Build Coastguard Worker    iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
2345*58b9f456SAndroid Build Coastguard Worker    __nh.__release();
2346*58b9f456SAndroid Build Coastguard Worker    return __result;
2347*58b9f456SAndroid Build Coastguard Worker}
2348*58b9f456SAndroid Build Coastguard Worker
2349*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2350*58b9f456SAndroid Build Coastguard Workertemplate <class _Table>
2351*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
2352*58b9f456SAndroid Build Coastguard Workervoid
2353*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
2354*58b9f456SAndroid Build Coastguard Worker    _Table& __source)
2355*58b9f456SAndroid Build Coastguard Worker{
2356*58b9f456SAndroid Build Coastguard Worker    static_assert(is_same<typename _Table::__node, __node>::value, "");
2357*58b9f456SAndroid Build Coastguard Worker
2358*58b9f456SAndroid Build Coastguard Worker    for (typename _Table::iterator __it = __source.begin();
2359*58b9f456SAndroid Build Coastguard Worker         __it != __source.end();)
2360*58b9f456SAndroid Build Coastguard Worker    {
2361*58b9f456SAndroid Build Coastguard Worker        __node_pointer __src_ptr = __it.__node_->__upcast();
2362*58b9f456SAndroid Build Coastguard Worker        size_t __src_hash = hash_function()(__src_ptr->__value_);
2363*58b9f456SAndroid Build Coastguard Worker        __next_pointer __pn =
2364*58b9f456SAndroid Build Coastguard Worker            __node_insert_multi_prepare(__src_hash, __src_ptr->__value_);
2365*58b9f456SAndroid Build Coastguard Worker        (void)__source.remove(__it++).release();
2366*58b9f456SAndroid Build Coastguard Worker        __src_ptr->__hash_ = __src_hash;
2367*58b9f456SAndroid Build Coastguard Worker        __node_insert_multi_perform(__src_ptr, __pn);
2368*58b9f456SAndroid Build Coastguard Worker    }
2369*58b9f456SAndroid Build Coastguard Worker}
2370*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_STD_VER > 14
2371*58b9f456SAndroid Build Coastguard Worker
2372*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2373*58b9f456SAndroid Build Coastguard Workervoid
2374*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
2375*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2376*58b9f456SAndroid Build Coastguard Worker{
2377*58b9f456SAndroid Build Coastguard Worker    if (__n == 1)
2378*58b9f456SAndroid Build Coastguard Worker        __n = 2;
2379*58b9f456SAndroid Build Coastguard Worker    else if (__n & (__n - 1))
2380*58b9f456SAndroid Build Coastguard Worker        __n = __next_prime(__n);
2381*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2382*58b9f456SAndroid Build Coastguard Worker    if (__n > __bc)
2383*58b9f456SAndroid Build Coastguard Worker        __rehash(__n);
2384*58b9f456SAndroid Build Coastguard Worker    else if (__n < __bc)
2385*58b9f456SAndroid Build Coastguard Worker    {
2386*58b9f456SAndroid Build Coastguard Worker        __n = _VSTD::max<size_type>
2387*58b9f456SAndroid Build Coastguard Worker              (
2388*58b9f456SAndroid Build Coastguard Worker                  __n,
2389*58b9f456SAndroid Build Coastguard Worker                  __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) :
2390*58b9f456SAndroid Build Coastguard Worker                                           __next_prime(size_t(ceil(float(size()) / max_load_factor())))
2391*58b9f456SAndroid Build Coastguard Worker              );
2392*58b9f456SAndroid Build Coastguard Worker        if (__n < __bc)
2393*58b9f456SAndroid Build Coastguard Worker            __rehash(__n);
2394*58b9f456SAndroid Build Coastguard Worker    }
2395*58b9f456SAndroid Build Coastguard Worker}
2396*58b9f456SAndroid Build Coastguard Worker
2397*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2398*58b9f456SAndroid Build Coastguard Workervoid
2399*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
2400*58b9f456SAndroid Build Coastguard Worker{
2401*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2402*58b9f456SAndroid Build Coastguard Worker    __get_db()->__invalidate_all(this);
2403*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
2404*58b9f456SAndroid Build Coastguard Worker    __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
2405*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.reset(__nbc > 0 ?
2406*58b9f456SAndroid Build Coastguard Worker                      __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
2407*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.get_deleter().size() = __nbc;
2408*58b9f456SAndroid Build Coastguard Worker    if (__nbc > 0)
2409*58b9f456SAndroid Build Coastguard Worker    {
2410*58b9f456SAndroid Build Coastguard Worker        for (size_type __i = 0; __i < __nbc; ++__i)
2411*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__i] = nullptr;
2412*58b9f456SAndroid Build Coastguard Worker        __next_pointer __pp = __p1_.first().__ptr();
2413*58b9f456SAndroid Build Coastguard Worker        __next_pointer __cp = __pp->__next_;
2414*58b9f456SAndroid Build Coastguard Worker        if (__cp != nullptr)
2415*58b9f456SAndroid Build Coastguard Worker        {
2416*58b9f456SAndroid Build Coastguard Worker            size_type __chash = __constrain_hash(__cp->__hash(), __nbc);
2417*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__chash] = __pp;
2418*58b9f456SAndroid Build Coastguard Worker            size_type __phash = __chash;
2419*58b9f456SAndroid Build Coastguard Worker            for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr;
2420*58b9f456SAndroid Build Coastguard Worker                                                           __cp = __pp->__next_)
2421*58b9f456SAndroid Build Coastguard Worker            {
2422*58b9f456SAndroid Build Coastguard Worker                __chash = __constrain_hash(__cp->__hash(), __nbc);
2423*58b9f456SAndroid Build Coastguard Worker                if (__chash == __phash)
2424*58b9f456SAndroid Build Coastguard Worker                    __pp = __cp;
2425*58b9f456SAndroid Build Coastguard Worker                else
2426*58b9f456SAndroid Build Coastguard Worker                {
2427*58b9f456SAndroid Build Coastguard Worker                    if (__bucket_list_[__chash] == nullptr)
2428*58b9f456SAndroid Build Coastguard Worker                    {
2429*58b9f456SAndroid Build Coastguard Worker                        __bucket_list_[__chash] = __pp;
2430*58b9f456SAndroid Build Coastguard Worker                        __pp = __cp;
2431*58b9f456SAndroid Build Coastguard Worker                        __phash = __chash;
2432*58b9f456SAndroid Build Coastguard Worker                    }
2433*58b9f456SAndroid Build Coastguard Worker                    else
2434*58b9f456SAndroid Build Coastguard Worker                    {
2435*58b9f456SAndroid Build Coastguard Worker                        __next_pointer __np = __cp;
2436*58b9f456SAndroid Build Coastguard Worker                        for (; __np->__next_ != nullptr &&
2437*58b9f456SAndroid Build Coastguard Worker                               key_eq()(__cp->__upcast()->__value_,
2438*58b9f456SAndroid Build Coastguard Worker                                        __np->__next_->__upcast()->__value_);
2439*58b9f456SAndroid Build Coastguard Worker                                                           __np = __np->__next_)
2440*58b9f456SAndroid Build Coastguard Worker                            ;
2441*58b9f456SAndroid Build Coastguard Worker                        __pp->__next_ = __np->__next_;
2442*58b9f456SAndroid Build Coastguard Worker                        __np->__next_ = __bucket_list_[__chash]->__next_;
2443*58b9f456SAndroid Build Coastguard Worker                        __bucket_list_[__chash]->__next_ = __cp;
2444*58b9f456SAndroid Build Coastguard Worker
2445*58b9f456SAndroid Build Coastguard Worker                    }
2446*58b9f456SAndroid Build Coastguard Worker                }
2447*58b9f456SAndroid Build Coastguard Worker            }
2448*58b9f456SAndroid Build Coastguard Worker        }
2449*58b9f456SAndroid Build Coastguard Worker    }
2450*58b9f456SAndroid Build Coastguard Worker}
2451*58b9f456SAndroid Build Coastguard Worker
2452*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2453*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2454*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2455*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
2456*58b9f456SAndroid Build Coastguard Worker{
2457*58b9f456SAndroid Build Coastguard Worker    size_t __hash = hash_function()(__k);
2458*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2459*58b9f456SAndroid Build Coastguard Worker    if (__bc != 0)
2460*58b9f456SAndroid Build Coastguard Worker    {
2461*58b9f456SAndroid Build Coastguard Worker        size_t __chash = __constrain_hash(__hash, __bc);
2462*58b9f456SAndroid Build Coastguard Worker        __next_pointer __nd = __bucket_list_[__chash];
2463*58b9f456SAndroid Build Coastguard Worker        if (__nd != nullptr)
2464*58b9f456SAndroid Build Coastguard Worker        {
2465*58b9f456SAndroid Build Coastguard Worker            for (__nd = __nd->__next_; __nd != nullptr &&
2466*58b9f456SAndroid Build Coastguard Worker                (__nd->__hash() == __hash
2467*58b9f456SAndroid Build Coastguard Worker                  || __constrain_hash(__nd->__hash(), __bc) == __chash);
2468*58b9f456SAndroid Build Coastguard Worker                                                           __nd = __nd->__next_)
2469*58b9f456SAndroid Build Coastguard Worker            {
2470*58b9f456SAndroid Build Coastguard Worker                if ((__nd->__hash() == __hash)
2471*58b9f456SAndroid Build Coastguard Worker                    && key_eq()(__nd->__upcast()->__value_, __k))
2472*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2473*58b9f456SAndroid Build Coastguard Worker                    return iterator(__nd, this);
2474*58b9f456SAndroid Build Coastguard Worker#else
2475*58b9f456SAndroid Build Coastguard Worker                    return iterator(__nd);
2476*58b9f456SAndroid Build Coastguard Worker#endif
2477*58b9f456SAndroid Build Coastguard Worker            }
2478*58b9f456SAndroid Build Coastguard Worker        }
2479*58b9f456SAndroid Build Coastguard Worker    }
2480*58b9f456SAndroid Build Coastguard Worker    return end();
2481*58b9f456SAndroid Build Coastguard Worker}
2482*58b9f456SAndroid Build Coastguard Worker
2483*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2484*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2485*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
2486*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
2487*58b9f456SAndroid Build Coastguard Worker{
2488*58b9f456SAndroid Build Coastguard Worker    size_t __hash = hash_function()(__k);
2489*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2490*58b9f456SAndroid Build Coastguard Worker    if (__bc != 0)
2491*58b9f456SAndroid Build Coastguard Worker    {
2492*58b9f456SAndroid Build Coastguard Worker        size_t __chash = __constrain_hash(__hash, __bc);
2493*58b9f456SAndroid Build Coastguard Worker        __next_pointer __nd = __bucket_list_[__chash];
2494*58b9f456SAndroid Build Coastguard Worker        if (__nd != nullptr)
2495*58b9f456SAndroid Build Coastguard Worker        {
2496*58b9f456SAndroid Build Coastguard Worker            for (__nd = __nd->__next_; __nd != nullptr &&
2497*58b9f456SAndroid Build Coastguard Worker                (__hash == __nd->__hash()
2498*58b9f456SAndroid Build Coastguard Worker                    || __constrain_hash(__nd->__hash(), __bc) == __chash);
2499*58b9f456SAndroid Build Coastguard Worker                                                           __nd = __nd->__next_)
2500*58b9f456SAndroid Build Coastguard Worker            {
2501*58b9f456SAndroid Build Coastguard Worker                if ((__nd->__hash() == __hash)
2502*58b9f456SAndroid Build Coastguard Worker                    && key_eq()(__nd->__upcast()->__value_, __k))
2503*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2504*58b9f456SAndroid Build Coastguard Worker                    return const_iterator(__nd, this);
2505*58b9f456SAndroid Build Coastguard Worker#else
2506*58b9f456SAndroid Build Coastguard Worker                    return const_iterator(__nd);
2507*58b9f456SAndroid Build Coastguard Worker#endif
2508*58b9f456SAndroid Build Coastguard Worker            }
2509*58b9f456SAndroid Build Coastguard Worker        }
2510*58b9f456SAndroid Build Coastguard Worker
2511*58b9f456SAndroid Build Coastguard Worker    }
2512*58b9f456SAndroid Build Coastguard Worker    return end();
2513*58b9f456SAndroid Build Coastguard Worker}
2514*58b9f456SAndroid Build Coastguard Worker
2515*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2516*58b9f456SAndroid Build Coastguard Worker
2517*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2518*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Args>
2519*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2520*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args)
2521*58b9f456SAndroid Build Coastguard Worker{
2522*58b9f456SAndroid Build Coastguard Worker    static_assert(!__is_hash_value_type<_Args...>::value,
2523*58b9f456SAndroid Build Coastguard Worker                  "Construct cannot be called with a hash value type");
2524*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __node_alloc();
2525*58b9f456SAndroid Build Coastguard Worker    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2526*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...);
2527*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__value_constructed = true;
2528*58b9f456SAndroid Build Coastguard Worker    __h->__hash_ = hash_function()(__h->__value_);
2529*58b9f456SAndroid Build Coastguard Worker    __h->__next_ = nullptr;
2530*58b9f456SAndroid Build Coastguard Worker    return __h;
2531*58b9f456SAndroid Build Coastguard Worker}
2532*58b9f456SAndroid Build Coastguard Worker
2533*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2534*58b9f456SAndroid Build Coastguard Workertemplate <class _First, class ..._Rest>
2535*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2536*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(
2537*58b9f456SAndroid Build Coastguard Worker    size_t __hash, _First&& __f, _Rest&& ...__rest)
2538*58b9f456SAndroid Build Coastguard Worker{
2539*58b9f456SAndroid Build Coastguard Worker    static_assert(!__is_hash_value_type<_First, _Rest...>::value,
2540*58b9f456SAndroid Build Coastguard Worker                  "Construct cannot be called with a hash value type");
2541*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __node_alloc();
2542*58b9f456SAndroid Build Coastguard Worker    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2543*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_),
2544*58b9f456SAndroid Build Coastguard Worker                             _VSTD::forward<_First>(__f),
2545*58b9f456SAndroid Build Coastguard Worker                             _VSTD::forward<_Rest>(__rest)...);
2546*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__value_constructed = true;
2547*58b9f456SAndroid Build Coastguard Worker    __h->__hash_ = __hash;
2548*58b9f456SAndroid Build Coastguard Worker    __h->__next_ = nullptr;
2549*58b9f456SAndroid Build Coastguard Worker    return __h;
2550*58b9f456SAndroid Build Coastguard Worker}
2551*58b9f456SAndroid Build Coastguard Worker
2552*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_CXX03_LANG
2553*58b9f456SAndroid Build Coastguard Worker
2554*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2555*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2556*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v)
2557*58b9f456SAndroid Build Coastguard Worker{
2558*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __node_alloc();
2559*58b9f456SAndroid Build Coastguard Worker    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2560*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
2561*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__value_constructed = true;
2562*58b9f456SAndroid Build Coastguard Worker    __h->__hash_ = hash_function()(__h->__value_);
2563*58b9f456SAndroid Build Coastguard Worker    __h->__next_ = nullptr;
2564*58b9f456SAndroid Build Coastguard Worker    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
2565*58b9f456SAndroid Build Coastguard Worker}
2566*58b9f456SAndroid Build Coastguard Worker
2567*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2568*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2569*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash,
2570*58b9f456SAndroid Build Coastguard Worker                                                                const __container_value_type& __v)
2571*58b9f456SAndroid Build Coastguard Worker{
2572*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = __node_alloc();
2573*58b9f456SAndroid Build Coastguard Worker    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
2574*58b9f456SAndroid Build Coastguard Worker    __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v);
2575*58b9f456SAndroid Build Coastguard Worker    __h.get_deleter().__value_constructed = true;
2576*58b9f456SAndroid Build Coastguard Worker    __h->__hash_ = __hash;
2577*58b9f456SAndroid Build Coastguard Worker    __h->__next_ = nullptr;
2578*58b9f456SAndroid Build Coastguard Worker    return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
2579*58b9f456SAndroid Build Coastguard Worker}
2580*58b9f456SAndroid Build Coastguard Worker
2581*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
2582*58b9f456SAndroid Build Coastguard Worker
2583*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2584*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2585*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
2586*58b9f456SAndroid Build Coastguard Worker{
2587*58b9f456SAndroid Build Coastguard Worker    __next_pointer __np = __p.__node_;
2588*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2589*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2590*58b9f456SAndroid Build Coastguard Worker        "unordered container erase(iterator) called with an iterator not"
2591*58b9f456SAndroid Build Coastguard Worker        " referring to this container");
2592*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__p != end(),
2593*58b9f456SAndroid Build Coastguard Worker        "unordered container erase(iterator) called with a non-dereferenceable iterator");
2594*58b9f456SAndroid Build Coastguard Worker    iterator __r(__np, this);
2595*58b9f456SAndroid Build Coastguard Worker#else
2596*58b9f456SAndroid Build Coastguard Worker    iterator __r(__np);
2597*58b9f456SAndroid Build Coastguard Worker#endif
2598*58b9f456SAndroid Build Coastguard Worker    ++__r;
2599*58b9f456SAndroid Build Coastguard Worker    remove(__p);
2600*58b9f456SAndroid Build Coastguard Worker    return __r;
2601*58b9f456SAndroid Build Coastguard Worker}
2602*58b9f456SAndroid Build Coastguard Worker
2603*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2604*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
2605*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
2606*58b9f456SAndroid Build Coastguard Worker                                                const_iterator __last)
2607*58b9f456SAndroid Build Coastguard Worker{
2608*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2609*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
2610*58b9f456SAndroid Build Coastguard Worker        "unodered container::erase(iterator, iterator) called with an iterator not"
2611*58b9f456SAndroid Build Coastguard Worker        " referring to this unodered container");
2612*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
2613*58b9f456SAndroid Build Coastguard Worker        "unodered container::erase(iterator, iterator) called with an iterator not"
2614*58b9f456SAndroid Build Coastguard Worker        " referring to this unodered container");
2615*58b9f456SAndroid Build Coastguard Worker#endif
2616*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __p = __first; __first != __last; __p = __first)
2617*58b9f456SAndroid Build Coastguard Worker    {
2618*58b9f456SAndroid Build Coastguard Worker        ++__first;
2619*58b9f456SAndroid Build Coastguard Worker        erase(__p);
2620*58b9f456SAndroid Build Coastguard Worker    }
2621*58b9f456SAndroid Build Coastguard Worker    __next_pointer __np = __last.__node_;
2622*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2623*58b9f456SAndroid Build Coastguard Worker    return iterator (__np, this);
2624*58b9f456SAndroid Build Coastguard Worker#else
2625*58b9f456SAndroid Build Coastguard Worker    return iterator (__np);
2626*58b9f456SAndroid Build Coastguard Worker#endif
2627*58b9f456SAndroid Build Coastguard Worker}
2628*58b9f456SAndroid Build Coastguard Worker
2629*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2630*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2631*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
2632*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k)
2633*58b9f456SAndroid Build Coastguard Worker{
2634*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__k);
2635*58b9f456SAndroid Build Coastguard Worker    if (__i == end())
2636*58b9f456SAndroid Build Coastguard Worker        return 0;
2637*58b9f456SAndroid Build Coastguard Worker    erase(__i);
2638*58b9f456SAndroid Build Coastguard Worker    return 1;
2639*58b9f456SAndroid Build Coastguard Worker}
2640*58b9f456SAndroid Build Coastguard Worker
2641*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2642*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2643*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
2644*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k)
2645*58b9f456SAndroid Build Coastguard Worker{
2646*58b9f456SAndroid Build Coastguard Worker    size_type __r = 0;
2647*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__k);
2648*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2649*58b9f456SAndroid Build Coastguard Worker    {
2650*58b9f456SAndroid Build Coastguard Worker        iterator __e = end();
2651*58b9f456SAndroid Build Coastguard Worker        do
2652*58b9f456SAndroid Build Coastguard Worker        {
2653*58b9f456SAndroid Build Coastguard Worker            erase(__i++);
2654*58b9f456SAndroid Build Coastguard Worker            ++__r;
2655*58b9f456SAndroid Build Coastguard Worker        } while (__i != __e && key_eq()(*__i, __k));
2656*58b9f456SAndroid Build Coastguard Worker    }
2657*58b9f456SAndroid Build Coastguard Worker    return __r;
2658*58b9f456SAndroid Build Coastguard Worker}
2659*58b9f456SAndroid Build Coastguard Worker
2660*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2661*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
2662*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2663*58b9f456SAndroid Build Coastguard Worker{
2664*58b9f456SAndroid Build Coastguard Worker    // current node
2665*58b9f456SAndroid Build Coastguard Worker    __next_pointer __cn = __p.__node_;
2666*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2667*58b9f456SAndroid Build Coastguard Worker    size_t __chash = __constrain_hash(__cn->__hash(), __bc);
2668*58b9f456SAndroid Build Coastguard Worker    // find previous node
2669*58b9f456SAndroid Build Coastguard Worker    __next_pointer __pn = __bucket_list_[__chash];
2670*58b9f456SAndroid Build Coastguard Worker    for (; __pn->__next_ != __cn; __pn = __pn->__next_)
2671*58b9f456SAndroid Build Coastguard Worker        ;
2672*58b9f456SAndroid Build Coastguard Worker    // Fix up __bucket_list_
2673*58b9f456SAndroid Build Coastguard Worker        // if __pn is not in same bucket (before begin is not in same bucket) &&
2674*58b9f456SAndroid Build Coastguard Worker        //    if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
2675*58b9f456SAndroid Build Coastguard Worker    if (__pn == __p1_.first().__ptr()
2676*58b9f456SAndroid Build Coastguard Worker            || __constrain_hash(__pn->__hash(), __bc) != __chash)
2677*58b9f456SAndroid Build Coastguard Worker    {
2678*58b9f456SAndroid Build Coastguard Worker        if (__cn->__next_ == nullptr
2679*58b9f456SAndroid Build Coastguard Worker            || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
2680*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__chash] = nullptr;
2681*58b9f456SAndroid Build Coastguard Worker    }
2682*58b9f456SAndroid Build Coastguard Worker        // if __cn->__next_ is not in same bucket (nullptr is in same bucket)
2683*58b9f456SAndroid Build Coastguard Worker    if (__cn->__next_ != nullptr)
2684*58b9f456SAndroid Build Coastguard Worker    {
2685*58b9f456SAndroid Build Coastguard Worker        size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc);
2686*58b9f456SAndroid Build Coastguard Worker        if (__nhash != __chash)
2687*58b9f456SAndroid Build Coastguard Worker            __bucket_list_[__nhash] = __pn;
2688*58b9f456SAndroid Build Coastguard Worker    }
2689*58b9f456SAndroid Build Coastguard Worker    // remove __cn
2690*58b9f456SAndroid Build Coastguard Worker    __pn->__next_ = __cn->__next_;
2691*58b9f456SAndroid Build Coastguard Worker    __cn->__next_ = nullptr;
2692*58b9f456SAndroid Build Coastguard Worker    --size();
2693*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2694*58b9f456SAndroid Build Coastguard Worker    __c_node* __c = __get_db()->__find_c_and_lock(this);
2695*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __dp = __c->end_; __dp != __c->beg_; )
2696*58b9f456SAndroid Build Coastguard Worker    {
2697*58b9f456SAndroid Build Coastguard Worker        --__dp;
2698*58b9f456SAndroid Build Coastguard Worker        iterator* __i = static_cast<iterator*>((*__dp)->__i_);
2699*58b9f456SAndroid Build Coastguard Worker        if (__i->__node_ == __cn)
2700*58b9f456SAndroid Build Coastguard Worker        {
2701*58b9f456SAndroid Build Coastguard Worker            (*__dp)->__c_ = nullptr;
2702*58b9f456SAndroid Build Coastguard Worker            if (--__c->end_ != __dp)
2703*58b9f456SAndroid Build Coastguard Worker                memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*));
2704*58b9f456SAndroid Build Coastguard Worker        }
2705*58b9f456SAndroid Build Coastguard Worker    }
2706*58b9f456SAndroid Build Coastguard Worker    __get_db()->unlock();
2707*58b9f456SAndroid Build Coastguard Worker#endif
2708*58b9f456SAndroid Build Coastguard Worker    return __node_holder(__cn->__upcast(), _Dp(__node_alloc(), true));
2709*58b9f456SAndroid Build Coastguard Worker}
2710*58b9f456SAndroid Build Coastguard Worker
2711*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2712*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2713*58b9f456SAndroid Build Coastguard Workerinline
2714*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
2715*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const
2716*58b9f456SAndroid Build Coastguard Worker{
2717*58b9f456SAndroid Build Coastguard Worker    return static_cast<size_type>(find(__k) != end());
2718*58b9f456SAndroid Build Coastguard Worker}
2719*58b9f456SAndroid Build Coastguard Worker
2720*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2721*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2722*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
2723*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const
2724*58b9f456SAndroid Build Coastguard Worker{
2725*58b9f456SAndroid Build Coastguard Worker    size_type __r = 0;
2726*58b9f456SAndroid Build Coastguard Worker    const_iterator __i = find(__k);
2727*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2728*58b9f456SAndroid Build Coastguard Worker    {
2729*58b9f456SAndroid Build Coastguard Worker        const_iterator __e = end();
2730*58b9f456SAndroid Build Coastguard Worker        do
2731*58b9f456SAndroid Build Coastguard Worker        {
2732*58b9f456SAndroid Build Coastguard Worker            ++__i;
2733*58b9f456SAndroid Build Coastguard Worker            ++__r;
2734*58b9f456SAndroid Build Coastguard Worker        } while (__i != __e && key_eq()(*__i, __k));
2735*58b9f456SAndroid Build Coastguard Worker    }
2736*58b9f456SAndroid Build Coastguard Worker    return __r;
2737*58b9f456SAndroid Build Coastguard Worker}
2738*58b9f456SAndroid Build Coastguard Worker
2739*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2740*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2741*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
2742*58b9f456SAndroid Build Coastguard Worker     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
2743*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
2744*58b9f456SAndroid Build Coastguard Worker        const _Key& __k)
2745*58b9f456SAndroid Build Coastguard Worker{
2746*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__k);
2747*58b9f456SAndroid Build Coastguard Worker    iterator __j = __i;
2748*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2749*58b9f456SAndroid Build Coastguard Worker        ++__j;
2750*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, iterator>(__i, __j);
2751*58b9f456SAndroid Build Coastguard Worker}
2752*58b9f456SAndroid Build Coastguard Worker
2753*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2754*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2755*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
2756*58b9f456SAndroid Build Coastguard Worker     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
2757*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
2758*58b9f456SAndroid Build Coastguard Worker        const _Key& __k) const
2759*58b9f456SAndroid Build Coastguard Worker{
2760*58b9f456SAndroid Build Coastguard Worker    const_iterator __i = find(__k);
2761*58b9f456SAndroid Build Coastguard Worker    const_iterator __j = __i;
2762*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2763*58b9f456SAndroid Build Coastguard Worker        ++__j;
2764*58b9f456SAndroid Build Coastguard Worker    return pair<const_iterator, const_iterator>(__i, __j);
2765*58b9f456SAndroid Build Coastguard Worker}
2766*58b9f456SAndroid Build Coastguard Worker
2767*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2768*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2769*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
2770*58b9f456SAndroid Build Coastguard Worker     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
2771*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
2772*58b9f456SAndroid Build Coastguard Worker        const _Key& __k)
2773*58b9f456SAndroid Build Coastguard Worker{
2774*58b9f456SAndroid Build Coastguard Worker    iterator __i = find(__k);
2775*58b9f456SAndroid Build Coastguard Worker    iterator __j = __i;
2776*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2777*58b9f456SAndroid Build Coastguard Worker    {
2778*58b9f456SAndroid Build Coastguard Worker        iterator __e = end();
2779*58b9f456SAndroid Build Coastguard Worker        do
2780*58b9f456SAndroid Build Coastguard Worker        {
2781*58b9f456SAndroid Build Coastguard Worker            ++__j;
2782*58b9f456SAndroid Build Coastguard Worker        } while (__j != __e && key_eq()(*__j, __k));
2783*58b9f456SAndroid Build Coastguard Worker    }
2784*58b9f456SAndroid Build Coastguard Worker    return pair<iterator, iterator>(__i, __j);
2785*58b9f456SAndroid Build Coastguard Worker}
2786*58b9f456SAndroid Build Coastguard Worker
2787*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2788*58b9f456SAndroid Build Coastguard Workertemplate <class _Key>
2789*58b9f456SAndroid Build Coastguard Workerpair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
2790*58b9f456SAndroid Build Coastguard Worker     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
2791*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
2792*58b9f456SAndroid Build Coastguard Worker        const _Key& __k) const
2793*58b9f456SAndroid Build Coastguard Worker{
2794*58b9f456SAndroid Build Coastguard Worker    const_iterator __i = find(__k);
2795*58b9f456SAndroid Build Coastguard Worker    const_iterator __j = __i;
2796*58b9f456SAndroid Build Coastguard Worker    if (__i != end())
2797*58b9f456SAndroid Build Coastguard Worker    {
2798*58b9f456SAndroid Build Coastguard Worker        const_iterator __e = end();
2799*58b9f456SAndroid Build Coastguard Worker        do
2800*58b9f456SAndroid Build Coastguard Worker        {
2801*58b9f456SAndroid Build Coastguard Worker            ++__j;
2802*58b9f456SAndroid Build Coastguard Worker        } while (__j != __e && key_eq()(*__j, __k));
2803*58b9f456SAndroid Build Coastguard Worker    }
2804*58b9f456SAndroid Build Coastguard Worker    return pair<const_iterator, const_iterator>(__i, __j);
2805*58b9f456SAndroid Build Coastguard Worker}
2806*58b9f456SAndroid Build Coastguard Worker
2807*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2808*58b9f456SAndroid Build Coastguard Workervoid
2809*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2810*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 11
2811*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_DEBUG_(
2812*58b9f456SAndroid Build Coastguard Worker        __is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
2813*58b9f456SAndroid Build Coastguard Worker        && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
2814*58b9f456SAndroid Build Coastguard Worker              || __is_nothrow_swappable<__pointer_allocator>::value)
2815*58b9f456SAndroid Build Coastguard Worker        && (!__node_traits::propagate_on_container_swap::value
2816*58b9f456SAndroid Build Coastguard Worker              || __is_nothrow_swappable<__node_allocator>::value)
2817*58b9f456SAndroid Build Coastguard Worker            )
2818*58b9f456SAndroid Build Coastguard Worker#else
2819*58b9f456SAndroid Build Coastguard Worker  _NOEXCEPT_DEBUG_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
2820*58b9f456SAndroid Build Coastguard Worker#endif
2821*58b9f456SAndroid Build Coastguard Worker{
2822*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value ||
2823*58b9f456SAndroid Build Coastguard Worker                   this->__node_alloc() == __u.__node_alloc(),
2824*58b9f456SAndroid Build Coastguard Worker                   "list::swap: Either propagate_on_container_swap must be true"
2825*58b9f456SAndroid Build Coastguard Worker                   " or the allocators must compare equal");
2826*58b9f456SAndroid Build Coastguard Worker    {
2827*58b9f456SAndroid Build Coastguard Worker    __node_pointer_pointer __npp = __bucket_list_.release();
2828*58b9f456SAndroid Build Coastguard Worker    __bucket_list_.reset(__u.__bucket_list_.release());
2829*58b9f456SAndroid Build Coastguard Worker    __u.__bucket_list_.reset(__npp);
2830*58b9f456SAndroid Build Coastguard Worker    }
2831*58b9f456SAndroid Build Coastguard Worker    _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
2832*58b9f456SAndroid Build Coastguard Worker    __swap_allocator(__bucket_list_.get_deleter().__alloc(),
2833*58b9f456SAndroid Build Coastguard Worker             __u.__bucket_list_.get_deleter().__alloc());
2834*58b9f456SAndroid Build Coastguard Worker    __swap_allocator(__node_alloc(), __u.__node_alloc());
2835*58b9f456SAndroid Build Coastguard Worker    _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
2836*58b9f456SAndroid Build Coastguard Worker    __p2_.swap(__u.__p2_);
2837*58b9f456SAndroid Build Coastguard Worker    __p3_.swap(__u.__p3_);
2838*58b9f456SAndroid Build Coastguard Worker    if (size() > 0)
2839*58b9f456SAndroid Build Coastguard Worker        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
2840*58b9f456SAndroid Build Coastguard Worker            __p1_.first().__ptr();
2841*58b9f456SAndroid Build Coastguard Worker    if (__u.size() > 0)
2842*58b9f456SAndroid Build Coastguard Worker        __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
2843*58b9f456SAndroid Build Coastguard Worker            __u.__p1_.first().__ptr();
2844*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2845*58b9f456SAndroid Build Coastguard Worker    __get_db()->swap(this, &__u);
2846*58b9f456SAndroid Build Coastguard Worker#endif
2847*58b9f456SAndroid Build Coastguard Worker}
2848*58b9f456SAndroid Build Coastguard Worker
2849*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2850*58b9f456SAndroid Build Coastguard Workertypename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
2851*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
2852*58b9f456SAndroid Build Coastguard Worker{
2853*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n < bucket_count(),
2854*58b9f456SAndroid Build Coastguard Worker        "unordered container::bucket_size(n) called with n >= bucket_count()");
2855*58b9f456SAndroid Build Coastguard Worker    __next_pointer __np = __bucket_list_[__n];
2856*58b9f456SAndroid Build Coastguard Worker    size_type __bc = bucket_count();
2857*58b9f456SAndroid Build Coastguard Worker    size_type __r = 0;
2858*58b9f456SAndroid Build Coastguard Worker    if (__np != nullptr)
2859*58b9f456SAndroid Build Coastguard Worker    {
2860*58b9f456SAndroid Build Coastguard Worker        for (__np = __np->__next_; __np != nullptr &&
2861*58b9f456SAndroid Build Coastguard Worker                                   __constrain_hash(__np->__hash(), __bc) == __n;
2862*58b9f456SAndroid Build Coastguard Worker                                                    __np = __np->__next_, ++__r)
2863*58b9f456SAndroid Build Coastguard Worker            ;
2864*58b9f456SAndroid Build Coastguard Worker    }
2865*58b9f456SAndroid Build Coastguard Worker    return __r;
2866*58b9f456SAndroid Build Coastguard Worker}
2867*58b9f456SAndroid Build Coastguard Worker
2868*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2869*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2870*58b9f456SAndroid Build Coastguard Workervoid
2871*58b9f456SAndroid Build Coastguard Workerswap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
2872*58b9f456SAndroid Build Coastguard Worker     __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y)
2873*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
2874*58b9f456SAndroid Build Coastguard Worker{
2875*58b9f456SAndroid Build Coastguard Worker    __x.swap(__y);
2876*58b9f456SAndroid Build Coastguard Worker}
2877*58b9f456SAndroid Build Coastguard Worker
2878*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2879*58b9f456SAndroid Build Coastguard Worker
2880*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2881*58b9f456SAndroid Build Coastguard Workerbool
2882*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const
2883*58b9f456SAndroid Build Coastguard Worker{
2884*58b9f456SAndroid Build Coastguard Worker    return __i->__node_ != nullptr;
2885*58b9f456SAndroid Build Coastguard Worker}
2886*58b9f456SAndroid Build Coastguard Worker
2887*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2888*58b9f456SAndroid Build Coastguard Workerbool
2889*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const
2890*58b9f456SAndroid Build Coastguard Worker{
2891*58b9f456SAndroid Build Coastguard Worker    return false;
2892*58b9f456SAndroid Build Coastguard Worker}
2893*58b9f456SAndroid Build Coastguard Worker
2894*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2895*58b9f456SAndroid Build Coastguard Workerbool
2896*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
2897*58b9f456SAndroid Build Coastguard Worker{
2898*58b9f456SAndroid Build Coastguard Worker    return false;
2899*58b9f456SAndroid Build Coastguard Worker}
2900*58b9f456SAndroid Build Coastguard Worker
2901*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Hash, class _Equal, class _Alloc>
2902*58b9f456SAndroid Build Coastguard Workerbool
2903*58b9f456SAndroid Build Coastguard Worker__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
2904*58b9f456SAndroid Build Coastguard Worker{
2905*58b9f456SAndroid Build Coastguard Worker    return false;
2906*58b9f456SAndroid Build Coastguard Worker}
2907*58b9f456SAndroid Build Coastguard Worker
2908*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
2909*58b9f456SAndroid Build Coastguard Worker
2910*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
2911*58b9f456SAndroid Build Coastguard Worker
2912*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
2913*58b9f456SAndroid Build Coastguard Worker
2914*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP__HASH_TABLE
2915