1*38fd1498Szrj // unordered_set implementation -*- C++ -*-
2*38fd1498Szrj
3*38fd1498Szrj // Copyright (C) 2010-2018 Free Software Foundation, Inc.
4*38fd1498Szrj //
5*38fd1498Szrj // This file is part of the GNU ISO C++ Library. This library is free
6*38fd1498Szrj // software; you can redistribute it and/or modify it under the
7*38fd1498Szrj // terms of the GNU General Public License as published by the
8*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj // any later version.
10*38fd1498Szrj
11*38fd1498Szrj // This library is distributed in the hope that it will be useful,
12*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*38fd1498Szrj // GNU General Public License for more details.
15*38fd1498Szrj
16*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj
20*38fd1498Szrj // You should have received a copy of the GNU General Public License and
21*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23*38fd1498Szrj // <http://www.gnu.org/licenses/>.
24*38fd1498Szrj
25*38fd1498Szrj /** @file bits/unordered_set.h
26*38fd1498Szrj * This is an internal header file, included by other library headers.
27*38fd1498Szrj * Do not attempt to use it directly. @headername{unordered_set}
28*38fd1498Szrj */
29*38fd1498Szrj
30*38fd1498Szrj #ifndef _UNORDERED_SET_H
31*38fd1498Szrj #define _UNORDERED_SET_H
32*38fd1498Szrj
_GLIBCXX_VISIBILITY(default)33*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default)
34*38fd1498Szrj {
35*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_VERSION
36*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
37*38fd1498Szrj
38*38fd1498Szrj /// Base types for unordered_set.
39*38fd1498Szrj template<bool _Cache>
40*38fd1498Szrj using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>;
41*38fd1498Szrj
42*38fd1498Szrj template<typename _Value,
43*38fd1498Szrj typename _Hash = hash<_Value>,
44*38fd1498Szrj typename _Pred = std::equal_to<_Value>,
45*38fd1498Szrj typename _Alloc = std::allocator<_Value>,
46*38fd1498Szrj typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>>
47*38fd1498Szrj using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
48*38fd1498Szrj __detail::_Identity, _Pred, _Hash,
49*38fd1498Szrj __detail::_Mod_range_hashing,
50*38fd1498Szrj __detail::_Default_ranged_hash,
51*38fd1498Szrj __detail::_Prime_rehash_policy, _Tr>;
52*38fd1498Szrj
53*38fd1498Szrj /// Base types for unordered_multiset.
54*38fd1498Szrj template<bool _Cache>
55*38fd1498Szrj using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>;
56*38fd1498Szrj
57*38fd1498Szrj template<typename _Value,
58*38fd1498Szrj typename _Hash = hash<_Value>,
59*38fd1498Szrj typename _Pred = std::equal_to<_Value>,
60*38fd1498Szrj typename _Alloc = std::allocator<_Value>,
61*38fd1498Szrj typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>>
62*38fd1498Szrj using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
63*38fd1498Szrj __detail::_Identity,
64*38fd1498Szrj _Pred, _Hash,
65*38fd1498Szrj __detail::_Mod_range_hashing,
66*38fd1498Szrj __detail::_Default_ranged_hash,
67*38fd1498Szrj __detail::_Prime_rehash_policy, _Tr>;
68*38fd1498Szrj
69*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
70*38fd1498Szrj class unordered_multiset;
71*38fd1498Szrj
72*38fd1498Szrj /**
73*38fd1498Szrj * @brief A standard container composed of unique keys (containing
74*38fd1498Szrj * at most one of each key value) in which the elements' keys are
75*38fd1498Szrj * the elements themselves.
76*38fd1498Szrj *
77*38fd1498Szrj * @ingroup unordered_associative_containers
78*38fd1498Szrj *
79*38fd1498Szrj * @tparam _Value Type of key objects.
80*38fd1498Szrj * @tparam _Hash Hashing function object type, defaults to hash<_Value>.
81*38fd1498Szrj
82*38fd1498Szrj * @tparam _Pred Predicate function object type, defaults to
83*38fd1498Szrj * equal_to<_Value>.
84*38fd1498Szrj *
85*38fd1498Szrj * @tparam _Alloc Allocator type, defaults to allocator<_Key>.
86*38fd1498Szrj *
87*38fd1498Szrj * Meets the requirements of a <a href="tables.html#65">container</a>, and
88*38fd1498Szrj * <a href="tables.html#xx">unordered associative container</a>
89*38fd1498Szrj *
90*38fd1498Szrj * Base is _Hashtable, dispatched at compile time via template
91*38fd1498Szrj * alias __uset_hashtable.
92*38fd1498Szrj */
93*38fd1498Szrj template<typename _Value,
94*38fd1498Szrj typename _Hash = hash<_Value>,
95*38fd1498Szrj typename _Pred = equal_to<_Value>,
96*38fd1498Szrj typename _Alloc = allocator<_Value>>
97*38fd1498Szrj class unordered_set
98*38fd1498Szrj {
99*38fd1498Szrj typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
100*38fd1498Szrj _Hashtable _M_h;
101*38fd1498Szrj
102*38fd1498Szrj public:
103*38fd1498Szrj // typedefs:
104*38fd1498Szrj //@{
105*38fd1498Szrj /// Public typedefs.
106*38fd1498Szrj typedef typename _Hashtable::key_type key_type;
107*38fd1498Szrj typedef typename _Hashtable::value_type value_type;
108*38fd1498Szrj typedef typename _Hashtable::hasher hasher;
109*38fd1498Szrj typedef typename _Hashtable::key_equal key_equal;
110*38fd1498Szrj typedef typename _Hashtable::allocator_type allocator_type;
111*38fd1498Szrj //@}
112*38fd1498Szrj
113*38fd1498Szrj //@{
114*38fd1498Szrj /// Iterator-related typedefs.
115*38fd1498Szrj typedef typename _Hashtable::pointer pointer;
116*38fd1498Szrj typedef typename _Hashtable::const_pointer const_pointer;
117*38fd1498Szrj typedef typename _Hashtable::reference reference;
118*38fd1498Szrj typedef typename _Hashtable::const_reference const_reference;
119*38fd1498Szrj typedef typename _Hashtable::iterator iterator;
120*38fd1498Szrj typedef typename _Hashtable::const_iterator const_iterator;
121*38fd1498Szrj typedef typename _Hashtable::local_iterator local_iterator;
122*38fd1498Szrj typedef typename _Hashtable::const_local_iterator const_local_iterator;
123*38fd1498Szrj typedef typename _Hashtable::size_type size_type;
124*38fd1498Szrj typedef typename _Hashtable::difference_type difference_type;
125*38fd1498Szrj //@}
126*38fd1498Szrj
127*38fd1498Szrj #if __cplusplus > 201402L
128*38fd1498Szrj using node_type = typename _Hashtable::node_type;
129*38fd1498Szrj using insert_return_type = typename _Hashtable::insert_return_type;
130*38fd1498Szrj #endif
131*38fd1498Szrj
132*38fd1498Szrj // construct/destroy/copy
133*38fd1498Szrj
134*38fd1498Szrj /// Default constructor.
135*38fd1498Szrj unordered_set() = default;
136*38fd1498Szrj
137*38fd1498Szrj /**
138*38fd1498Szrj * @brief Default constructor creates no elements.
139*38fd1498Szrj * @param __n Minimal initial number of buckets.
140*38fd1498Szrj * @param __hf A hash functor.
141*38fd1498Szrj * @param __eql A key equality functor.
142*38fd1498Szrj * @param __a An allocator object.
143*38fd1498Szrj */
144*38fd1498Szrj explicit
145*38fd1498Szrj unordered_set(size_type __n,
146*38fd1498Szrj const hasher& __hf = hasher(),
147*38fd1498Szrj const key_equal& __eql = key_equal(),
148*38fd1498Szrj const allocator_type& __a = allocator_type())
149*38fd1498Szrj : _M_h(__n, __hf, __eql, __a)
150*38fd1498Szrj { }
151*38fd1498Szrj
152*38fd1498Szrj /**
153*38fd1498Szrj * @brief Builds an %unordered_set from a range.
154*38fd1498Szrj * @param __first An input iterator.
155*38fd1498Szrj * @param __last An input iterator.
156*38fd1498Szrj * @param __n Minimal initial number of buckets.
157*38fd1498Szrj * @param __hf A hash functor.
158*38fd1498Szrj * @param __eql A key equality functor.
159*38fd1498Szrj * @param __a An allocator object.
160*38fd1498Szrj *
161*38fd1498Szrj * Create an %unordered_set consisting of copies of the elements from
162*38fd1498Szrj * [__first,__last). This is linear in N (where N is
163*38fd1498Szrj * distance(__first,__last)).
164*38fd1498Szrj */
165*38fd1498Szrj template<typename _InputIterator>
166*38fd1498Szrj unordered_set(_InputIterator __first, _InputIterator __last,
167*38fd1498Szrj size_type __n = 0,
168*38fd1498Szrj const hasher& __hf = hasher(),
169*38fd1498Szrj const key_equal& __eql = key_equal(),
170*38fd1498Szrj const allocator_type& __a = allocator_type())
171*38fd1498Szrj : _M_h(__first, __last, __n, __hf, __eql, __a)
172*38fd1498Szrj { }
173*38fd1498Szrj
174*38fd1498Szrj /// Copy constructor.
175*38fd1498Szrj unordered_set(const unordered_set&) = default;
176*38fd1498Szrj
177*38fd1498Szrj /// Move constructor.
178*38fd1498Szrj unordered_set(unordered_set&&) = default;
179*38fd1498Szrj
180*38fd1498Szrj /**
181*38fd1498Szrj * @brief Creates an %unordered_set with no elements.
182*38fd1498Szrj * @param __a An allocator object.
183*38fd1498Szrj */
184*38fd1498Szrj explicit
185*38fd1498Szrj unordered_set(const allocator_type& __a)
186*38fd1498Szrj : _M_h(__a)
187*38fd1498Szrj { }
188*38fd1498Szrj
189*38fd1498Szrj /*
190*38fd1498Szrj * @brief Copy constructor with allocator argument.
191*38fd1498Szrj * @param __uset Input %unordered_set to copy.
192*38fd1498Szrj * @param __a An allocator object.
193*38fd1498Szrj */
194*38fd1498Szrj unordered_set(const unordered_set& __uset,
195*38fd1498Szrj const allocator_type& __a)
196*38fd1498Szrj : _M_h(__uset._M_h, __a)
197*38fd1498Szrj { }
198*38fd1498Szrj
199*38fd1498Szrj /*
200*38fd1498Szrj * @brief Move constructor with allocator argument.
201*38fd1498Szrj * @param __uset Input %unordered_set to move.
202*38fd1498Szrj * @param __a An allocator object.
203*38fd1498Szrj */
204*38fd1498Szrj unordered_set(unordered_set&& __uset,
205*38fd1498Szrj const allocator_type& __a)
206*38fd1498Szrj : _M_h(std::move(__uset._M_h), __a)
207*38fd1498Szrj { }
208*38fd1498Szrj
209*38fd1498Szrj /**
210*38fd1498Szrj * @brief Builds an %unordered_set from an initializer_list.
211*38fd1498Szrj * @param __l An initializer_list.
212*38fd1498Szrj * @param __n Minimal initial number of buckets.
213*38fd1498Szrj * @param __hf A hash functor.
214*38fd1498Szrj * @param __eql A key equality functor.
215*38fd1498Szrj * @param __a An allocator object.
216*38fd1498Szrj *
217*38fd1498Szrj * Create an %unordered_set consisting of copies of the elements in the
218*38fd1498Szrj * list. This is linear in N (where N is @a __l.size()).
219*38fd1498Szrj */
220*38fd1498Szrj unordered_set(initializer_list<value_type> __l,
221*38fd1498Szrj size_type __n = 0,
222*38fd1498Szrj const hasher& __hf = hasher(),
223*38fd1498Szrj const key_equal& __eql = key_equal(),
224*38fd1498Szrj const allocator_type& __a = allocator_type())
225*38fd1498Szrj : _M_h(__l, __n, __hf, __eql, __a)
226*38fd1498Szrj { }
227*38fd1498Szrj
228*38fd1498Szrj unordered_set(size_type __n, const allocator_type& __a)
229*38fd1498Szrj : unordered_set(__n, hasher(), key_equal(), __a)
230*38fd1498Szrj { }
231*38fd1498Szrj
232*38fd1498Szrj unordered_set(size_type __n, const hasher& __hf,
233*38fd1498Szrj const allocator_type& __a)
234*38fd1498Szrj : unordered_set(__n, __hf, key_equal(), __a)
235*38fd1498Szrj { }
236*38fd1498Szrj
237*38fd1498Szrj template<typename _InputIterator>
238*38fd1498Szrj unordered_set(_InputIterator __first, _InputIterator __last,
239*38fd1498Szrj size_type __n,
240*38fd1498Szrj const allocator_type& __a)
241*38fd1498Szrj : unordered_set(__first, __last, __n, hasher(), key_equal(), __a)
242*38fd1498Szrj { }
243*38fd1498Szrj
244*38fd1498Szrj template<typename _InputIterator>
245*38fd1498Szrj unordered_set(_InputIterator __first, _InputIterator __last,
246*38fd1498Szrj size_type __n, const hasher& __hf,
247*38fd1498Szrj const allocator_type& __a)
248*38fd1498Szrj : unordered_set(__first, __last, __n, __hf, key_equal(), __a)
249*38fd1498Szrj { }
250*38fd1498Szrj
251*38fd1498Szrj unordered_set(initializer_list<value_type> __l,
252*38fd1498Szrj size_type __n,
253*38fd1498Szrj const allocator_type& __a)
254*38fd1498Szrj : unordered_set(__l, __n, hasher(), key_equal(), __a)
255*38fd1498Szrj { }
256*38fd1498Szrj
257*38fd1498Szrj unordered_set(initializer_list<value_type> __l,
258*38fd1498Szrj size_type __n, const hasher& __hf,
259*38fd1498Szrj const allocator_type& __a)
260*38fd1498Szrj : unordered_set(__l, __n, __hf, key_equal(), __a)
261*38fd1498Szrj { }
262*38fd1498Szrj
263*38fd1498Szrj /// Copy assignment operator.
264*38fd1498Szrj unordered_set&
265*38fd1498Szrj operator=(const unordered_set&) = default;
266*38fd1498Szrj
267*38fd1498Szrj /// Move assignment operator.
268*38fd1498Szrj unordered_set&
269*38fd1498Szrj operator=(unordered_set&&) = default;
270*38fd1498Szrj
271*38fd1498Szrj /**
272*38fd1498Szrj * @brief %Unordered_set list assignment operator.
273*38fd1498Szrj * @param __l An initializer_list.
274*38fd1498Szrj *
275*38fd1498Szrj * This function fills an %unordered_set with copies of the elements in
276*38fd1498Szrj * the initializer list @a __l.
277*38fd1498Szrj *
278*38fd1498Szrj * Note that the assignment completely changes the %unordered_set and
279*38fd1498Szrj * that the resulting %unordered_set's size is the same as the number
280*38fd1498Szrj * of elements assigned.
281*38fd1498Szrj */
282*38fd1498Szrj unordered_set&
283*38fd1498Szrj operator=(initializer_list<value_type> __l)
284*38fd1498Szrj {
285*38fd1498Szrj _M_h = __l;
286*38fd1498Szrj return *this;
287*38fd1498Szrj }
288*38fd1498Szrj
289*38fd1498Szrj /// Returns the allocator object used by the %unordered_set.
290*38fd1498Szrj allocator_type
291*38fd1498Szrj get_allocator() const noexcept
292*38fd1498Szrj { return _M_h.get_allocator(); }
293*38fd1498Szrj
294*38fd1498Szrj // size and capacity:
295*38fd1498Szrj
296*38fd1498Szrj /// Returns true if the %unordered_set is empty.
297*38fd1498Szrj bool
298*38fd1498Szrj empty() const noexcept
299*38fd1498Szrj { return _M_h.empty(); }
300*38fd1498Szrj
301*38fd1498Szrj /// Returns the size of the %unordered_set.
302*38fd1498Szrj size_type
303*38fd1498Szrj size() const noexcept
304*38fd1498Szrj { return _M_h.size(); }
305*38fd1498Szrj
306*38fd1498Szrj /// Returns the maximum size of the %unordered_set.
307*38fd1498Szrj size_type
308*38fd1498Szrj max_size() const noexcept
309*38fd1498Szrj { return _M_h.max_size(); }
310*38fd1498Szrj
311*38fd1498Szrj // iterators.
312*38fd1498Szrj
313*38fd1498Szrj //@{
314*38fd1498Szrj /**
315*38fd1498Szrj * Returns a read-only (constant) iterator that points to the first
316*38fd1498Szrj * element in the %unordered_set.
317*38fd1498Szrj */
318*38fd1498Szrj iterator
319*38fd1498Szrj begin() noexcept
320*38fd1498Szrj { return _M_h.begin(); }
321*38fd1498Szrj
322*38fd1498Szrj const_iterator
323*38fd1498Szrj begin() const noexcept
324*38fd1498Szrj { return _M_h.begin(); }
325*38fd1498Szrj //@}
326*38fd1498Szrj
327*38fd1498Szrj //@{
328*38fd1498Szrj /**
329*38fd1498Szrj * Returns a read-only (constant) iterator that points one past the last
330*38fd1498Szrj * element in the %unordered_set.
331*38fd1498Szrj */
332*38fd1498Szrj iterator
333*38fd1498Szrj end() noexcept
334*38fd1498Szrj { return _M_h.end(); }
335*38fd1498Szrj
336*38fd1498Szrj const_iterator
337*38fd1498Szrj end() const noexcept
338*38fd1498Szrj { return _M_h.end(); }
339*38fd1498Szrj //@}
340*38fd1498Szrj
341*38fd1498Szrj /**
342*38fd1498Szrj * Returns a read-only (constant) iterator that points to the first
343*38fd1498Szrj * element in the %unordered_set.
344*38fd1498Szrj */
345*38fd1498Szrj const_iterator
346*38fd1498Szrj cbegin() const noexcept
347*38fd1498Szrj { return _M_h.begin(); }
348*38fd1498Szrj
349*38fd1498Szrj /**
350*38fd1498Szrj * Returns a read-only (constant) iterator that points one past the last
351*38fd1498Szrj * element in the %unordered_set.
352*38fd1498Szrj */
353*38fd1498Szrj const_iterator
354*38fd1498Szrj cend() const noexcept
355*38fd1498Szrj { return _M_h.end(); }
356*38fd1498Szrj
357*38fd1498Szrj // modifiers.
358*38fd1498Szrj
359*38fd1498Szrj /**
360*38fd1498Szrj * @brief Attempts to build and insert an element into the
361*38fd1498Szrj * %unordered_set.
362*38fd1498Szrj * @param __args Arguments used to generate an element.
363*38fd1498Szrj * @return A pair, of which the first element is an iterator that points
364*38fd1498Szrj * to the possibly inserted element, and the second is a bool
365*38fd1498Szrj * that is true if the element was actually inserted.
366*38fd1498Szrj *
367*38fd1498Szrj * This function attempts to build and insert an element into the
368*38fd1498Szrj * %unordered_set. An %unordered_set relies on unique keys and thus an
369*38fd1498Szrj * element is only inserted if it is not already present in the
370*38fd1498Szrj * %unordered_set.
371*38fd1498Szrj *
372*38fd1498Szrj * Insertion requires amortized constant time.
373*38fd1498Szrj */
374*38fd1498Szrj template<typename... _Args>
375*38fd1498Szrj std::pair<iterator, bool>
376*38fd1498Szrj emplace(_Args&&... __args)
377*38fd1498Szrj { return _M_h.emplace(std::forward<_Args>(__args)...); }
378*38fd1498Szrj
379*38fd1498Szrj /**
380*38fd1498Szrj * @brief Attempts to insert an element into the %unordered_set.
381*38fd1498Szrj * @param __pos An iterator that serves as a hint as to where the
382*38fd1498Szrj * element should be inserted.
383*38fd1498Szrj * @param __args Arguments used to generate the element to be
384*38fd1498Szrj * inserted.
385*38fd1498Szrj * @return An iterator that points to the element with key equivalent to
386*38fd1498Szrj * the one generated from @a __args (may or may not be the
387*38fd1498Szrj * element itself).
388*38fd1498Szrj *
389*38fd1498Szrj * This function is not concerned about whether the insertion took place,
390*38fd1498Szrj * and thus does not return a boolean like the single-argument emplace()
391*38fd1498Szrj * does. Note that the first parameter is only a hint and can
392*38fd1498Szrj * potentially improve the performance of the insertion process. A bad
393*38fd1498Szrj * hint would cause no gains in efficiency.
394*38fd1498Szrj *
395*38fd1498Szrj * For more on @a hinting, see:
396*38fd1498Szrj * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
397*38fd1498Szrj *
398*38fd1498Szrj * Insertion requires amortized constant time.
399*38fd1498Szrj */
400*38fd1498Szrj template<typename... _Args>
401*38fd1498Szrj iterator
402*38fd1498Szrj emplace_hint(const_iterator __pos, _Args&&... __args)
403*38fd1498Szrj { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
404*38fd1498Szrj
405*38fd1498Szrj //@{
406*38fd1498Szrj /**
407*38fd1498Szrj * @brief Attempts to insert an element into the %unordered_set.
408*38fd1498Szrj * @param __x Element to be inserted.
409*38fd1498Szrj * @return A pair, of which the first element is an iterator that points
410*38fd1498Szrj * to the possibly inserted element, and the second is a bool
411*38fd1498Szrj * that is true if the element was actually inserted.
412*38fd1498Szrj *
413*38fd1498Szrj * This function attempts to insert an element into the %unordered_set.
414*38fd1498Szrj * An %unordered_set relies on unique keys and thus an element is only
415*38fd1498Szrj * inserted if it is not already present in the %unordered_set.
416*38fd1498Szrj *
417*38fd1498Szrj * Insertion requires amortized constant time.
418*38fd1498Szrj */
419*38fd1498Szrj std::pair<iterator, bool>
420*38fd1498Szrj insert(const value_type& __x)
421*38fd1498Szrj { return _M_h.insert(__x); }
422*38fd1498Szrj
423*38fd1498Szrj std::pair<iterator, bool>
424*38fd1498Szrj insert(value_type&& __x)
425*38fd1498Szrj { return _M_h.insert(std::move(__x)); }
426*38fd1498Szrj //@}
427*38fd1498Szrj
428*38fd1498Szrj //@{
429*38fd1498Szrj /**
430*38fd1498Szrj * @brief Attempts to insert an element into the %unordered_set.
431*38fd1498Szrj * @param __hint An iterator that serves as a hint as to where the
432*38fd1498Szrj * element should be inserted.
433*38fd1498Szrj * @param __x Element to be inserted.
434*38fd1498Szrj * @return An iterator that points to the element with key of
435*38fd1498Szrj * @a __x (may or may not be the element passed in).
436*38fd1498Szrj *
437*38fd1498Szrj * This function is not concerned about whether the insertion took place,
438*38fd1498Szrj * and thus does not return a boolean like the single-argument insert()
439*38fd1498Szrj * does. Note that the first parameter is only a hint and can
440*38fd1498Szrj * potentially improve the performance of the insertion process. A bad
441*38fd1498Szrj * hint would cause no gains in efficiency.
442*38fd1498Szrj *
443*38fd1498Szrj * For more on @a hinting, see:
444*38fd1498Szrj * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
445*38fd1498Szrj *
446*38fd1498Szrj * Insertion requires amortized constant.
447*38fd1498Szrj */
448*38fd1498Szrj iterator
449*38fd1498Szrj insert(const_iterator __hint, const value_type& __x)
450*38fd1498Szrj { return _M_h.insert(__hint, __x); }
451*38fd1498Szrj
452*38fd1498Szrj iterator
453*38fd1498Szrj insert(const_iterator __hint, value_type&& __x)
454*38fd1498Szrj { return _M_h.insert(__hint, std::move(__x)); }
455*38fd1498Szrj //@}
456*38fd1498Szrj
457*38fd1498Szrj /**
458*38fd1498Szrj * @brief A template function that attempts to insert a range of
459*38fd1498Szrj * elements.
460*38fd1498Szrj * @param __first Iterator pointing to the start of the range to be
461*38fd1498Szrj * inserted.
462*38fd1498Szrj * @param __last Iterator pointing to the end of the range.
463*38fd1498Szrj *
464*38fd1498Szrj * Complexity similar to that of the range constructor.
465*38fd1498Szrj */
466*38fd1498Szrj template<typename _InputIterator>
467*38fd1498Szrj void
468*38fd1498Szrj insert(_InputIterator __first, _InputIterator __last)
469*38fd1498Szrj { _M_h.insert(__first, __last); }
470*38fd1498Szrj
471*38fd1498Szrj /**
472*38fd1498Szrj * @brief Attempts to insert a list of elements into the %unordered_set.
473*38fd1498Szrj * @param __l A std::initializer_list<value_type> of elements
474*38fd1498Szrj * to be inserted.
475*38fd1498Szrj *
476*38fd1498Szrj * Complexity similar to that of the range constructor.
477*38fd1498Szrj */
478*38fd1498Szrj void
479*38fd1498Szrj insert(initializer_list<value_type> __l)
480*38fd1498Szrj { _M_h.insert(__l); }
481*38fd1498Szrj
482*38fd1498Szrj #if __cplusplus > 201402L
483*38fd1498Szrj /// Extract a node.
484*38fd1498Szrj node_type
485*38fd1498Szrj extract(const_iterator __pos)
486*38fd1498Szrj {
487*38fd1498Szrj __glibcxx_assert(__pos != end());
488*38fd1498Szrj return _M_h.extract(__pos);
489*38fd1498Szrj }
490*38fd1498Szrj
491*38fd1498Szrj /// Extract a node.
492*38fd1498Szrj node_type
493*38fd1498Szrj extract(const key_type& __key)
494*38fd1498Szrj { return _M_h.extract(__key); }
495*38fd1498Szrj
496*38fd1498Szrj /// Re-insert an extracted node.
497*38fd1498Szrj insert_return_type
498*38fd1498Szrj insert(node_type&& __nh)
499*38fd1498Szrj { return _M_h._M_reinsert_node(std::move(__nh)); }
500*38fd1498Szrj
501*38fd1498Szrj /// Re-insert an extracted node.
502*38fd1498Szrj iterator
503*38fd1498Szrj insert(const_iterator, node_type&& __nh)
504*38fd1498Szrj { return _M_h._M_reinsert_node(std::move(__nh)).position; }
505*38fd1498Szrj #endif // C++17
506*38fd1498Szrj
507*38fd1498Szrj //@{
508*38fd1498Szrj /**
509*38fd1498Szrj * @brief Erases an element from an %unordered_set.
510*38fd1498Szrj * @param __position An iterator pointing to the element to be erased.
511*38fd1498Szrj * @return An iterator pointing to the element immediately following
512*38fd1498Szrj * @a __position prior to the element being erased. If no such
513*38fd1498Szrj * element exists, end() is returned.
514*38fd1498Szrj *
515*38fd1498Szrj * This function erases an element, pointed to by the given iterator,
516*38fd1498Szrj * from an %unordered_set. Note that this function only erases the
517*38fd1498Szrj * element, and that if the element is itself a pointer, the pointed-to
518*38fd1498Szrj * memory is not touched in any way. Managing the pointer is the user's
519*38fd1498Szrj * responsibility.
520*38fd1498Szrj */
521*38fd1498Szrj iterator
522*38fd1498Szrj erase(const_iterator __position)
523*38fd1498Szrj { return _M_h.erase(__position); }
524*38fd1498Szrj
525*38fd1498Szrj // LWG 2059.
526*38fd1498Szrj iterator
527*38fd1498Szrj erase(iterator __position)
528*38fd1498Szrj { return _M_h.erase(__position); }
529*38fd1498Szrj //@}
530*38fd1498Szrj
531*38fd1498Szrj /**
532*38fd1498Szrj * @brief Erases elements according to the provided key.
533*38fd1498Szrj * @param __x Key of element to be erased.
534*38fd1498Szrj * @return The number of elements erased.
535*38fd1498Szrj *
536*38fd1498Szrj * This function erases all the elements located by the given key from
537*38fd1498Szrj * an %unordered_set. For an %unordered_set the result of this function
538*38fd1498Szrj * can only be 0 (not present) or 1 (present).
539*38fd1498Szrj * Note that this function only erases the element, and that if
540*38fd1498Szrj * the element is itself a pointer, the pointed-to memory is not touched
541*38fd1498Szrj * in any way. Managing the pointer is the user's responsibility.
542*38fd1498Szrj */
543*38fd1498Szrj size_type
544*38fd1498Szrj erase(const key_type& __x)
545*38fd1498Szrj { return _M_h.erase(__x); }
546*38fd1498Szrj
547*38fd1498Szrj /**
548*38fd1498Szrj * @brief Erases a [__first,__last) range of elements from an
549*38fd1498Szrj * %unordered_set.
550*38fd1498Szrj * @param __first Iterator pointing to the start of the range to be
551*38fd1498Szrj * erased.
552*38fd1498Szrj * @param __last Iterator pointing to the end of the range to
553*38fd1498Szrj * be erased.
554*38fd1498Szrj * @return The iterator @a __last.
555*38fd1498Szrj *
556*38fd1498Szrj * This function erases a sequence of elements from an %unordered_set.
557*38fd1498Szrj * Note that this function only erases the element, and that if
558*38fd1498Szrj * the element is itself a pointer, the pointed-to memory is not touched
559*38fd1498Szrj * in any way. Managing the pointer is the user's responsibility.
560*38fd1498Szrj */
561*38fd1498Szrj iterator
562*38fd1498Szrj erase(const_iterator __first, const_iterator __last)
563*38fd1498Szrj { return _M_h.erase(__first, __last); }
564*38fd1498Szrj
565*38fd1498Szrj /**
566*38fd1498Szrj * Erases all elements in an %unordered_set. Note that this function only
567*38fd1498Szrj * erases the elements, and that if the elements themselves are pointers,
568*38fd1498Szrj * the pointed-to memory is not touched in any way. Managing the pointer
569*38fd1498Szrj * is the user's responsibility.
570*38fd1498Szrj */
571*38fd1498Szrj void
572*38fd1498Szrj clear() noexcept
573*38fd1498Szrj { _M_h.clear(); }
574*38fd1498Szrj
575*38fd1498Szrj /**
576*38fd1498Szrj * @brief Swaps data with another %unordered_set.
577*38fd1498Szrj * @param __x An %unordered_set of the same element and allocator
578*38fd1498Szrj * types.
579*38fd1498Szrj *
580*38fd1498Szrj * This exchanges the elements between two sets in constant time.
581*38fd1498Szrj * Note that the global std::swap() function is specialized such that
582*38fd1498Szrj * std::swap(s1,s2) will feed to this function.
583*38fd1498Szrj */
584*38fd1498Szrj void
585*38fd1498Szrj swap(unordered_set& __x)
586*38fd1498Szrj noexcept( noexcept(_M_h.swap(__x._M_h)) )
587*38fd1498Szrj { _M_h.swap(__x._M_h); }
588*38fd1498Szrj
589*38fd1498Szrj #if __cplusplus > 201402L
590*38fd1498Szrj template<typename, typename, typename>
591*38fd1498Szrj friend class std::_Hash_merge_helper;
592*38fd1498Szrj
593*38fd1498Szrj template<typename _H2, typename _P2>
594*38fd1498Szrj void
595*38fd1498Szrj merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source)
596*38fd1498Szrj {
597*38fd1498Szrj using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
598*38fd1498Szrj _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
599*38fd1498Szrj }
600*38fd1498Szrj
601*38fd1498Szrj template<typename _H2, typename _P2>
602*38fd1498Szrj void
603*38fd1498Szrj merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
604*38fd1498Szrj { merge(__source); }
605*38fd1498Szrj
606*38fd1498Szrj template<typename _H2, typename _P2>
607*38fd1498Szrj void
608*38fd1498Szrj merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source)
609*38fd1498Szrj {
610*38fd1498Szrj using _Merge_helper = _Hash_merge_helper<unordered_set, _H2, _P2>;
611*38fd1498Szrj _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source));
612*38fd1498Szrj }
613*38fd1498Szrj
614*38fd1498Szrj template<typename _H2, typename _P2>
615*38fd1498Szrj void
616*38fd1498Szrj merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
617*38fd1498Szrj { merge(__source); }
618*38fd1498Szrj #endif // C++17
619*38fd1498Szrj
620*38fd1498Szrj // observers.
621*38fd1498Szrj
622*38fd1498Szrj /// Returns the hash functor object with which the %unordered_set was
623*38fd1498Szrj /// constructed.
624*38fd1498Szrj hasher
625*38fd1498Szrj hash_function() const
626*38fd1498Szrj { return _M_h.hash_function(); }
627*38fd1498Szrj
628*38fd1498Szrj /// Returns the key comparison object with which the %unordered_set was
629*38fd1498Szrj /// constructed.
630*38fd1498Szrj key_equal
631*38fd1498Szrj key_eq() const
632*38fd1498Szrj { return _M_h.key_eq(); }
633*38fd1498Szrj
634*38fd1498Szrj // lookup.
635*38fd1498Szrj
636*38fd1498Szrj //@{
637*38fd1498Szrj /**
638*38fd1498Szrj * @brief Tries to locate an element in an %unordered_set.
639*38fd1498Szrj * @param __x Element to be located.
640*38fd1498Szrj * @return Iterator pointing to sought-after element, or end() if not
641*38fd1498Szrj * found.
642*38fd1498Szrj *
643*38fd1498Szrj * This function takes a key and tries to locate the element with which
644*38fd1498Szrj * the key matches. If successful the function returns an iterator
645*38fd1498Szrj * pointing to the sought after element. If unsuccessful it returns the
646*38fd1498Szrj * past-the-end ( @c end() ) iterator.
647*38fd1498Szrj */
648*38fd1498Szrj iterator
649*38fd1498Szrj find(const key_type& __x)
650*38fd1498Szrj { return _M_h.find(__x); }
651*38fd1498Szrj
652*38fd1498Szrj const_iterator
653*38fd1498Szrj find(const key_type& __x) const
654*38fd1498Szrj { return _M_h.find(__x); }
655*38fd1498Szrj //@}
656*38fd1498Szrj
657*38fd1498Szrj /**
658*38fd1498Szrj * @brief Finds the number of elements.
659*38fd1498Szrj * @param __x Element to located.
660*38fd1498Szrj * @return Number of elements with specified key.
661*38fd1498Szrj *
662*38fd1498Szrj * This function only makes sense for unordered_multisets; for
663*38fd1498Szrj * unordered_set the result will either be 0 (not present) or 1
664*38fd1498Szrj * (present).
665*38fd1498Szrj */
666*38fd1498Szrj size_type
667*38fd1498Szrj count(const key_type& __x) const
668*38fd1498Szrj { return _M_h.count(__x); }
669*38fd1498Szrj
670*38fd1498Szrj //@{
671*38fd1498Szrj /**
672*38fd1498Szrj * @brief Finds a subsequence matching given key.
673*38fd1498Szrj * @param __x Key to be located.
674*38fd1498Szrj * @return Pair of iterators that possibly points to the subsequence
675*38fd1498Szrj * matching given key.
676*38fd1498Szrj *
677*38fd1498Szrj * This function probably only makes sense for multisets.
678*38fd1498Szrj */
679*38fd1498Szrj std::pair<iterator, iterator>
680*38fd1498Szrj equal_range(const key_type& __x)
681*38fd1498Szrj { return _M_h.equal_range(__x); }
682*38fd1498Szrj
683*38fd1498Szrj std::pair<const_iterator, const_iterator>
684*38fd1498Szrj equal_range(const key_type& __x) const
685*38fd1498Szrj { return _M_h.equal_range(__x); }
686*38fd1498Szrj //@}
687*38fd1498Szrj
688*38fd1498Szrj // bucket interface.
689*38fd1498Szrj
690*38fd1498Szrj /// Returns the number of buckets of the %unordered_set.
691*38fd1498Szrj size_type
692*38fd1498Szrj bucket_count() const noexcept
693*38fd1498Szrj { return _M_h.bucket_count(); }
694*38fd1498Szrj
695*38fd1498Szrj /// Returns the maximum number of buckets of the %unordered_set.
696*38fd1498Szrj size_type
697*38fd1498Szrj max_bucket_count() const noexcept
698*38fd1498Szrj { return _M_h.max_bucket_count(); }
699*38fd1498Szrj
700*38fd1498Szrj /*
701*38fd1498Szrj * @brief Returns the number of elements in a given bucket.
702*38fd1498Szrj * @param __n A bucket index.
703*38fd1498Szrj * @return The number of elements in the bucket.
704*38fd1498Szrj */
705*38fd1498Szrj size_type
706*38fd1498Szrj bucket_size(size_type __n) const
707*38fd1498Szrj { return _M_h.bucket_size(__n); }
708*38fd1498Szrj
709*38fd1498Szrj /*
710*38fd1498Szrj * @brief Returns the bucket index of a given element.
711*38fd1498Szrj * @param __key A key instance.
712*38fd1498Szrj * @return The key bucket index.
713*38fd1498Szrj */
714*38fd1498Szrj size_type
715*38fd1498Szrj bucket(const key_type& __key) const
716*38fd1498Szrj { return _M_h.bucket(__key); }
717*38fd1498Szrj
718*38fd1498Szrj //@{
719*38fd1498Szrj /**
720*38fd1498Szrj * @brief Returns a read-only (constant) iterator pointing to the first
721*38fd1498Szrj * bucket element.
722*38fd1498Szrj * @param __n The bucket index.
723*38fd1498Szrj * @return A read-only local iterator.
724*38fd1498Szrj */
725*38fd1498Szrj local_iterator
726*38fd1498Szrj begin(size_type __n)
727*38fd1498Szrj { return _M_h.begin(__n); }
728*38fd1498Szrj
729*38fd1498Szrj const_local_iterator
730*38fd1498Szrj begin(size_type __n) const
731*38fd1498Szrj { return _M_h.begin(__n); }
732*38fd1498Szrj
733*38fd1498Szrj const_local_iterator
734*38fd1498Szrj cbegin(size_type __n) const
735*38fd1498Szrj { return _M_h.cbegin(__n); }
736*38fd1498Szrj //@}
737*38fd1498Szrj
738*38fd1498Szrj //@{
739*38fd1498Szrj /**
740*38fd1498Szrj * @brief Returns a read-only (constant) iterator pointing to one past
741*38fd1498Szrj * the last bucket elements.
742*38fd1498Szrj * @param __n The bucket index.
743*38fd1498Szrj * @return A read-only local iterator.
744*38fd1498Szrj */
745*38fd1498Szrj local_iterator
746*38fd1498Szrj end(size_type __n)
747*38fd1498Szrj { return _M_h.end(__n); }
748*38fd1498Szrj
749*38fd1498Szrj const_local_iterator
750*38fd1498Szrj end(size_type __n) const
751*38fd1498Szrj { return _M_h.end(__n); }
752*38fd1498Szrj
753*38fd1498Szrj const_local_iterator
754*38fd1498Szrj cend(size_type __n) const
755*38fd1498Szrj { return _M_h.cend(__n); }
756*38fd1498Szrj //@}
757*38fd1498Szrj
758*38fd1498Szrj // hash policy.
759*38fd1498Szrj
760*38fd1498Szrj /// Returns the average number of elements per bucket.
761*38fd1498Szrj float
762*38fd1498Szrj load_factor() const noexcept
763*38fd1498Szrj { return _M_h.load_factor(); }
764*38fd1498Szrj
765*38fd1498Szrj /// Returns a positive number that the %unordered_set tries to keep the
766*38fd1498Szrj /// load factor less than or equal to.
767*38fd1498Szrj float
768*38fd1498Szrj max_load_factor() const noexcept
769*38fd1498Szrj { return _M_h.max_load_factor(); }
770*38fd1498Szrj
771*38fd1498Szrj /**
772*38fd1498Szrj * @brief Change the %unordered_set maximum load factor.
773*38fd1498Szrj * @param __z The new maximum load factor.
774*38fd1498Szrj */
775*38fd1498Szrj void
776*38fd1498Szrj max_load_factor(float __z)
777*38fd1498Szrj { _M_h.max_load_factor(__z); }
778*38fd1498Szrj
779*38fd1498Szrj /**
780*38fd1498Szrj * @brief May rehash the %unordered_set.
781*38fd1498Szrj * @param __n The new number of buckets.
782*38fd1498Szrj *
783*38fd1498Szrj * Rehash will occur only if the new number of buckets respect the
784*38fd1498Szrj * %unordered_set maximum load factor.
785*38fd1498Szrj */
786*38fd1498Szrj void
787*38fd1498Szrj rehash(size_type __n)
788*38fd1498Szrj { _M_h.rehash(__n); }
789*38fd1498Szrj
790*38fd1498Szrj /**
791*38fd1498Szrj * @brief Prepare the %unordered_set for a specified number of
792*38fd1498Szrj * elements.
793*38fd1498Szrj * @param __n Number of elements required.
794*38fd1498Szrj *
795*38fd1498Szrj * Same as rehash(ceil(n / max_load_factor())).
796*38fd1498Szrj */
797*38fd1498Szrj void
798*38fd1498Szrj reserve(size_type __n)
799*38fd1498Szrj { _M_h.reserve(__n); }
800*38fd1498Szrj
801*38fd1498Szrj template<typename _Value1, typename _Hash1, typename _Pred1,
802*38fd1498Szrj typename _Alloc1>
803*38fd1498Szrj friend bool
804*38fd1498Szrj operator==(const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&,
805*38fd1498Szrj const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&);
806*38fd1498Szrj };
807*38fd1498Szrj
808*38fd1498Szrj #if __cpp_deduction_guides >= 201606
809*38fd1498Szrj
810*38fd1498Szrj template<typename _InputIterator,
811*38fd1498Szrj typename _Hash =
812*38fd1498Szrj hash<typename iterator_traits<_InputIterator>::value_type>,
813*38fd1498Szrj typename _Pred =
814*38fd1498Szrj equal_to<typename iterator_traits<_InputIterator>::value_type>,
815*38fd1498Szrj typename _Allocator =
816*38fd1498Szrj allocator<typename iterator_traits<_InputIterator>::value_type>,
817*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
818*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
819*38fd1498Szrj unordered_set(_InputIterator, _InputIterator,
820*38fd1498Szrj unordered_set<int>::size_type = {},
821*38fd1498Szrj _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
822*38fd1498Szrj -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
823*38fd1498Szrj _Hash, _Pred, _Allocator>;
824*38fd1498Szrj
825*38fd1498Szrj template<typename _Tp, typename _Hash = hash<_Tp>,
826*38fd1498Szrj typename _Pred = equal_to<_Tp>,
827*38fd1498Szrj typename _Allocator = allocator<_Tp>,
828*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
829*38fd1498Szrj unordered_set(initializer_list<_Tp>,
830*38fd1498Szrj unordered_set<int>::size_type = {},
831*38fd1498Szrj _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
832*38fd1498Szrj -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
833*38fd1498Szrj
834*38fd1498Szrj template<typename _InputIterator, typename _Allocator,
835*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
836*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
837*38fd1498Szrj unordered_set(_InputIterator, _InputIterator,
838*38fd1498Szrj unordered_set<int>::size_type, _Allocator)
839*38fd1498Szrj -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
840*38fd1498Szrj hash<
841*38fd1498Szrj typename iterator_traits<_InputIterator>::value_type>,
842*38fd1498Szrj equal_to<
843*38fd1498Szrj typename iterator_traits<_InputIterator>::value_type>,
844*38fd1498Szrj _Allocator>;
845*38fd1498Szrj
846*38fd1498Szrj template<typename _InputIterator, typename _Hash, typename _Allocator,
847*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
848*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
849*38fd1498Szrj unordered_set(_InputIterator, _InputIterator,
850*38fd1498Szrj unordered_set<int>::size_type,
851*38fd1498Szrj _Hash, _Allocator)
852*38fd1498Szrj -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
853*38fd1498Szrj _Hash,
854*38fd1498Szrj equal_to<
855*38fd1498Szrj typename iterator_traits<_InputIterator>::value_type>,
856*38fd1498Szrj _Allocator>;
857*38fd1498Szrj
858*38fd1498Szrj template<typename _Tp, typename _Allocator,
859*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
860*38fd1498Szrj unordered_set(initializer_list<_Tp>,
861*38fd1498Szrj unordered_set<int>::size_type, _Allocator)
862*38fd1498Szrj -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
863*38fd1498Szrj
864*38fd1498Szrj template<typename _Tp, typename _Hash, typename _Allocator,
865*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
866*38fd1498Szrj unordered_set(initializer_list<_Tp>,
867*38fd1498Szrj unordered_set<int>::size_type, _Hash, _Allocator)
868*38fd1498Szrj -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
869*38fd1498Szrj
870*38fd1498Szrj #endif
871*38fd1498Szrj
872*38fd1498Szrj /**
873*38fd1498Szrj * @brief A standard container composed of equivalent keys
874*38fd1498Szrj * (possibly containing multiple of each key value) in which the
875*38fd1498Szrj * elements' keys are the elements themselves.
876*38fd1498Szrj *
877*38fd1498Szrj * @ingroup unordered_associative_containers
878*38fd1498Szrj *
879*38fd1498Szrj * @tparam _Value Type of key objects.
880*38fd1498Szrj * @tparam _Hash Hashing function object type, defaults to hash<_Value>.
881*38fd1498Szrj * @tparam _Pred Predicate function object type, defaults
882*38fd1498Szrj * to equal_to<_Value>.
883*38fd1498Szrj * @tparam _Alloc Allocator type, defaults to allocator<_Key>.
884*38fd1498Szrj *
885*38fd1498Szrj * Meets the requirements of a <a href="tables.html#65">container</a>, and
886*38fd1498Szrj * <a href="tables.html#xx">unordered associative container</a>
887*38fd1498Szrj *
888*38fd1498Szrj * Base is _Hashtable, dispatched at compile time via template
889*38fd1498Szrj * alias __umset_hashtable.
890*38fd1498Szrj */
891*38fd1498Szrj template<typename _Value,
892*38fd1498Szrj typename _Hash = hash<_Value>,
893*38fd1498Szrj typename _Pred = equal_to<_Value>,
894*38fd1498Szrj typename _Alloc = allocator<_Value>>
895*38fd1498Szrj class unordered_multiset
896*38fd1498Szrj {
897*38fd1498Szrj typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
898*38fd1498Szrj _Hashtable _M_h;
899*38fd1498Szrj
900*38fd1498Szrj public:
901*38fd1498Szrj // typedefs:
902*38fd1498Szrj //@{
903*38fd1498Szrj /// Public typedefs.
904*38fd1498Szrj typedef typename _Hashtable::key_type key_type;
905*38fd1498Szrj typedef typename _Hashtable::value_type value_type;
906*38fd1498Szrj typedef typename _Hashtable::hasher hasher;
907*38fd1498Szrj typedef typename _Hashtable::key_equal key_equal;
908*38fd1498Szrj typedef typename _Hashtable::allocator_type allocator_type;
909*38fd1498Szrj //@}
910*38fd1498Szrj
911*38fd1498Szrj //@{
912*38fd1498Szrj /// Iterator-related typedefs.
913*38fd1498Szrj typedef typename _Hashtable::pointer pointer;
914*38fd1498Szrj typedef typename _Hashtable::const_pointer const_pointer;
915*38fd1498Szrj typedef typename _Hashtable::reference reference;
916*38fd1498Szrj typedef typename _Hashtable::const_reference const_reference;
917*38fd1498Szrj typedef typename _Hashtable::iterator iterator;
918*38fd1498Szrj typedef typename _Hashtable::const_iterator const_iterator;
919*38fd1498Szrj typedef typename _Hashtable::local_iterator local_iterator;
920*38fd1498Szrj typedef typename _Hashtable::const_local_iterator const_local_iterator;
921*38fd1498Szrj typedef typename _Hashtable::size_type size_type;
922*38fd1498Szrj typedef typename _Hashtable::difference_type difference_type;
923*38fd1498Szrj //@}
924*38fd1498Szrj
925*38fd1498Szrj #if __cplusplus > 201402L
926*38fd1498Szrj using node_type = typename _Hashtable::node_type;
927*38fd1498Szrj #endif
928*38fd1498Szrj
929*38fd1498Szrj // construct/destroy/copy
930*38fd1498Szrj
931*38fd1498Szrj /// Default constructor.
932*38fd1498Szrj unordered_multiset() = default;
933*38fd1498Szrj
934*38fd1498Szrj /**
935*38fd1498Szrj * @brief Default constructor creates no elements.
936*38fd1498Szrj * @param __n Minimal initial number of buckets.
937*38fd1498Szrj * @param __hf A hash functor.
938*38fd1498Szrj * @param __eql A key equality functor.
939*38fd1498Szrj * @param __a An allocator object.
940*38fd1498Szrj */
941*38fd1498Szrj explicit
942*38fd1498Szrj unordered_multiset(size_type __n,
943*38fd1498Szrj const hasher& __hf = hasher(),
944*38fd1498Szrj const key_equal& __eql = key_equal(),
945*38fd1498Szrj const allocator_type& __a = allocator_type())
946*38fd1498Szrj : _M_h(__n, __hf, __eql, __a)
947*38fd1498Szrj { }
948*38fd1498Szrj
949*38fd1498Szrj /**
950*38fd1498Szrj * @brief Builds an %unordered_multiset from a range.
951*38fd1498Szrj * @param __first An input iterator.
952*38fd1498Szrj * @param __last An input iterator.
953*38fd1498Szrj * @param __n Minimal initial number of buckets.
954*38fd1498Szrj * @param __hf A hash functor.
955*38fd1498Szrj * @param __eql A key equality functor.
956*38fd1498Szrj * @param __a An allocator object.
957*38fd1498Szrj *
958*38fd1498Szrj * Create an %unordered_multiset consisting of copies of the elements
959*38fd1498Szrj * from [__first,__last). This is linear in N (where N is
960*38fd1498Szrj * distance(__first,__last)).
961*38fd1498Szrj */
962*38fd1498Szrj template<typename _InputIterator>
963*38fd1498Szrj unordered_multiset(_InputIterator __first, _InputIterator __last,
964*38fd1498Szrj size_type __n = 0,
965*38fd1498Szrj const hasher& __hf = hasher(),
966*38fd1498Szrj const key_equal& __eql = key_equal(),
967*38fd1498Szrj const allocator_type& __a = allocator_type())
968*38fd1498Szrj : _M_h(__first, __last, __n, __hf, __eql, __a)
969*38fd1498Szrj { }
970*38fd1498Szrj
971*38fd1498Szrj /// Copy constructor.
972*38fd1498Szrj unordered_multiset(const unordered_multiset&) = default;
973*38fd1498Szrj
974*38fd1498Szrj /// Move constructor.
975*38fd1498Szrj unordered_multiset(unordered_multiset&&) = default;
976*38fd1498Szrj
977*38fd1498Szrj /**
978*38fd1498Szrj * @brief Builds an %unordered_multiset from an initializer_list.
979*38fd1498Szrj * @param __l An initializer_list.
980*38fd1498Szrj * @param __n Minimal initial number of buckets.
981*38fd1498Szrj * @param __hf A hash functor.
982*38fd1498Szrj * @param __eql A key equality functor.
983*38fd1498Szrj * @param __a An allocator object.
984*38fd1498Szrj *
985*38fd1498Szrj * Create an %unordered_multiset consisting of copies of the elements in
986*38fd1498Szrj * the list. This is linear in N (where N is @a __l.size()).
987*38fd1498Szrj */
988*38fd1498Szrj unordered_multiset(initializer_list<value_type> __l,
989*38fd1498Szrj size_type __n = 0,
990*38fd1498Szrj const hasher& __hf = hasher(),
991*38fd1498Szrj const key_equal& __eql = key_equal(),
992*38fd1498Szrj const allocator_type& __a = allocator_type())
993*38fd1498Szrj : _M_h(__l, __n, __hf, __eql, __a)
994*38fd1498Szrj { }
995*38fd1498Szrj
996*38fd1498Szrj /// Copy assignment operator.
997*38fd1498Szrj unordered_multiset&
998*38fd1498Szrj operator=(const unordered_multiset&) = default;
999*38fd1498Szrj
1000*38fd1498Szrj /// Move assignment operator.
1001*38fd1498Szrj unordered_multiset&
1002*38fd1498Szrj operator=(unordered_multiset&&) = default;
1003*38fd1498Szrj
1004*38fd1498Szrj /**
1005*38fd1498Szrj * @brief Creates an %unordered_multiset with no elements.
1006*38fd1498Szrj * @param __a An allocator object.
1007*38fd1498Szrj */
1008*38fd1498Szrj explicit
1009*38fd1498Szrj unordered_multiset(const allocator_type& __a)
1010*38fd1498Szrj : _M_h(__a)
1011*38fd1498Szrj { }
1012*38fd1498Szrj
1013*38fd1498Szrj /*
1014*38fd1498Szrj * @brief Copy constructor with allocator argument.
1015*38fd1498Szrj * @param __uset Input %unordered_multiset to copy.
1016*38fd1498Szrj * @param __a An allocator object.
1017*38fd1498Szrj */
1018*38fd1498Szrj unordered_multiset(const unordered_multiset& __umset,
1019*38fd1498Szrj const allocator_type& __a)
1020*38fd1498Szrj : _M_h(__umset._M_h, __a)
1021*38fd1498Szrj { }
1022*38fd1498Szrj
1023*38fd1498Szrj /*
1024*38fd1498Szrj * @brief Move constructor with allocator argument.
1025*38fd1498Szrj * @param __umset Input %unordered_multiset to move.
1026*38fd1498Szrj * @param __a An allocator object.
1027*38fd1498Szrj */
1028*38fd1498Szrj unordered_multiset(unordered_multiset&& __umset,
1029*38fd1498Szrj const allocator_type& __a)
1030*38fd1498Szrj : _M_h(std::move(__umset._M_h), __a)
1031*38fd1498Szrj { }
1032*38fd1498Szrj
1033*38fd1498Szrj unordered_multiset(size_type __n, const allocator_type& __a)
1034*38fd1498Szrj : unordered_multiset(__n, hasher(), key_equal(), __a)
1035*38fd1498Szrj { }
1036*38fd1498Szrj
1037*38fd1498Szrj unordered_multiset(size_type __n, const hasher& __hf,
1038*38fd1498Szrj const allocator_type& __a)
1039*38fd1498Szrj : unordered_multiset(__n, __hf, key_equal(), __a)
1040*38fd1498Szrj { }
1041*38fd1498Szrj
1042*38fd1498Szrj template<typename _InputIterator>
1043*38fd1498Szrj unordered_multiset(_InputIterator __first, _InputIterator __last,
1044*38fd1498Szrj size_type __n,
1045*38fd1498Szrj const allocator_type& __a)
1046*38fd1498Szrj : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a)
1047*38fd1498Szrj { }
1048*38fd1498Szrj
1049*38fd1498Szrj template<typename _InputIterator>
1050*38fd1498Szrj unordered_multiset(_InputIterator __first, _InputIterator __last,
1051*38fd1498Szrj size_type __n, const hasher& __hf,
1052*38fd1498Szrj const allocator_type& __a)
1053*38fd1498Szrj : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
1054*38fd1498Szrj { }
1055*38fd1498Szrj
1056*38fd1498Szrj unordered_multiset(initializer_list<value_type> __l,
1057*38fd1498Szrj size_type __n,
1058*38fd1498Szrj const allocator_type& __a)
1059*38fd1498Szrj : unordered_multiset(__l, __n, hasher(), key_equal(), __a)
1060*38fd1498Szrj { }
1061*38fd1498Szrj
1062*38fd1498Szrj unordered_multiset(initializer_list<value_type> __l,
1063*38fd1498Szrj size_type __n, const hasher& __hf,
1064*38fd1498Szrj const allocator_type& __a)
1065*38fd1498Szrj : unordered_multiset(__l, __n, __hf, key_equal(), __a)
1066*38fd1498Szrj { }
1067*38fd1498Szrj
1068*38fd1498Szrj /**
1069*38fd1498Szrj * @brief %Unordered_multiset list assignment operator.
1070*38fd1498Szrj * @param __l An initializer_list.
1071*38fd1498Szrj *
1072*38fd1498Szrj * This function fills an %unordered_multiset with copies of the elements
1073*38fd1498Szrj * in the initializer list @a __l.
1074*38fd1498Szrj *
1075*38fd1498Szrj * Note that the assignment completely changes the %unordered_multiset
1076*38fd1498Szrj * and that the resulting %unordered_multiset's size is the same as the
1077*38fd1498Szrj * number of elements assigned.
1078*38fd1498Szrj */
1079*38fd1498Szrj unordered_multiset&
1080*38fd1498Szrj operator=(initializer_list<value_type> __l)
1081*38fd1498Szrj {
1082*38fd1498Szrj _M_h = __l;
1083*38fd1498Szrj return *this;
1084*38fd1498Szrj }
1085*38fd1498Szrj
1086*38fd1498Szrj /// Returns the allocator object used by the %unordered_multiset.
1087*38fd1498Szrj allocator_type
1088*38fd1498Szrj get_allocator() const noexcept
1089*38fd1498Szrj { return _M_h.get_allocator(); }
1090*38fd1498Szrj
1091*38fd1498Szrj // size and capacity:
1092*38fd1498Szrj
1093*38fd1498Szrj /// Returns true if the %unordered_multiset is empty.
1094*38fd1498Szrj bool
1095*38fd1498Szrj empty() const noexcept
1096*38fd1498Szrj { return _M_h.empty(); }
1097*38fd1498Szrj
1098*38fd1498Szrj /// Returns the size of the %unordered_multiset.
1099*38fd1498Szrj size_type
1100*38fd1498Szrj size() const noexcept
1101*38fd1498Szrj { return _M_h.size(); }
1102*38fd1498Szrj
1103*38fd1498Szrj /// Returns the maximum size of the %unordered_multiset.
1104*38fd1498Szrj size_type
1105*38fd1498Szrj max_size() const noexcept
1106*38fd1498Szrj { return _M_h.max_size(); }
1107*38fd1498Szrj
1108*38fd1498Szrj // iterators.
1109*38fd1498Szrj
1110*38fd1498Szrj //@{
1111*38fd1498Szrj /**
1112*38fd1498Szrj * Returns a read-only (constant) iterator that points to the first
1113*38fd1498Szrj * element in the %unordered_multiset.
1114*38fd1498Szrj */
1115*38fd1498Szrj iterator
1116*38fd1498Szrj begin() noexcept
1117*38fd1498Szrj { return _M_h.begin(); }
1118*38fd1498Szrj
1119*38fd1498Szrj const_iterator
1120*38fd1498Szrj begin() const noexcept
1121*38fd1498Szrj { return _M_h.begin(); }
1122*38fd1498Szrj //@}
1123*38fd1498Szrj
1124*38fd1498Szrj //@{
1125*38fd1498Szrj /**
1126*38fd1498Szrj * Returns a read-only (constant) iterator that points one past the last
1127*38fd1498Szrj * element in the %unordered_multiset.
1128*38fd1498Szrj */
1129*38fd1498Szrj iterator
1130*38fd1498Szrj end() noexcept
1131*38fd1498Szrj { return _M_h.end(); }
1132*38fd1498Szrj
1133*38fd1498Szrj const_iterator
1134*38fd1498Szrj end() const noexcept
1135*38fd1498Szrj { return _M_h.end(); }
1136*38fd1498Szrj //@}
1137*38fd1498Szrj
1138*38fd1498Szrj /**
1139*38fd1498Szrj * Returns a read-only (constant) iterator that points to the first
1140*38fd1498Szrj * element in the %unordered_multiset.
1141*38fd1498Szrj */
1142*38fd1498Szrj const_iterator
1143*38fd1498Szrj cbegin() const noexcept
1144*38fd1498Szrj { return _M_h.begin(); }
1145*38fd1498Szrj
1146*38fd1498Szrj /**
1147*38fd1498Szrj * Returns a read-only (constant) iterator that points one past the last
1148*38fd1498Szrj * element in the %unordered_multiset.
1149*38fd1498Szrj */
1150*38fd1498Szrj const_iterator
1151*38fd1498Szrj cend() const noexcept
1152*38fd1498Szrj { return _M_h.end(); }
1153*38fd1498Szrj
1154*38fd1498Szrj // modifiers.
1155*38fd1498Szrj
1156*38fd1498Szrj /**
1157*38fd1498Szrj * @brief Builds and insert an element into the %unordered_multiset.
1158*38fd1498Szrj * @param __args Arguments used to generate an element.
1159*38fd1498Szrj * @return An iterator that points to the inserted element.
1160*38fd1498Szrj *
1161*38fd1498Szrj * Insertion requires amortized constant time.
1162*38fd1498Szrj */
1163*38fd1498Szrj template<typename... _Args>
1164*38fd1498Szrj iterator
1165*38fd1498Szrj emplace(_Args&&... __args)
1166*38fd1498Szrj { return _M_h.emplace(std::forward<_Args>(__args)...); }
1167*38fd1498Szrj
1168*38fd1498Szrj /**
1169*38fd1498Szrj * @brief Inserts an element into the %unordered_multiset.
1170*38fd1498Szrj * @param __pos An iterator that serves as a hint as to where the
1171*38fd1498Szrj * element should be inserted.
1172*38fd1498Szrj * @param __args Arguments used to generate the element to be
1173*38fd1498Szrj * inserted.
1174*38fd1498Szrj * @return An iterator that points to the inserted element.
1175*38fd1498Szrj *
1176*38fd1498Szrj * Note that the first parameter is only a hint and can potentially
1177*38fd1498Szrj * improve the performance of the insertion process. A bad hint would
1178*38fd1498Szrj * cause no gains in efficiency.
1179*38fd1498Szrj *
1180*38fd1498Szrj * For more on @a hinting, see:
1181*38fd1498Szrj * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
1182*38fd1498Szrj *
1183*38fd1498Szrj * Insertion requires amortized constant time.
1184*38fd1498Szrj */
1185*38fd1498Szrj template<typename... _Args>
1186*38fd1498Szrj iterator
1187*38fd1498Szrj emplace_hint(const_iterator __pos, _Args&&... __args)
1188*38fd1498Szrj { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
1189*38fd1498Szrj
1190*38fd1498Szrj //@{
1191*38fd1498Szrj /**
1192*38fd1498Szrj * @brief Inserts an element into the %unordered_multiset.
1193*38fd1498Szrj * @param __x Element to be inserted.
1194*38fd1498Szrj * @return An iterator that points to the inserted element.
1195*38fd1498Szrj *
1196*38fd1498Szrj * Insertion requires amortized constant time.
1197*38fd1498Szrj */
1198*38fd1498Szrj iterator
1199*38fd1498Szrj insert(const value_type& __x)
1200*38fd1498Szrj { return _M_h.insert(__x); }
1201*38fd1498Szrj
1202*38fd1498Szrj iterator
1203*38fd1498Szrj insert(value_type&& __x)
1204*38fd1498Szrj { return _M_h.insert(std::move(__x)); }
1205*38fd1498Szrj //@}
1206*38fd1498Szrj
1207*38fd1498Szrj //@{
1208*38fd1498Szrj /**
1209*38fd1498Szrj * @brief Inserts an element into the %unordered_multiset.
1210*38fd1498Szrj * @param __hint An iterator that serves as a hint as to where the
1211*38fd1498Szrj * element should be inserted.
1212*38fd1498Szrj * @param __x Element to be inserted.
1213*38fd1498Szrj * @return An iterator that points to the inserted element.
1214*38fd1498Szrj *
1215*38fd1498Szrj * Note that the first parameter is only a hint and can potentially
1216*38fd1498Szrj * improve the performance of the insertion process. A bad hint would
1217*38fd1498Szrj * cause no gains in efficiency.
1218*38fd1498Szrj *
1219*38fd1498Szrj * For more on @a hinting, see:
1220*38fd1498Szrj * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints
1221*38fd1498Szrj *
1222*38fd1498Szrj * Insertion requires amortized constant.
1223*38fd1498Szrj */
1224*38fd1498Szrj iterator
1225*38fd1498Szrj insert(const_iterator __hint, const value_type& __x)
1226*38fd1498Szrj { return _M_h.insert(__hint, __x); }
1227*38fd1498Szrj
1228*38fd1498Szrj iterator
1229*38fd1498Szrj insert(const_iterator __hint, value_type&& __x)
1230*38fd1498Szrj { return _M_h.insert(__hint, std::move(__x)); }
1231*38fd1498Szrj //@}
1232*38fd1498Szrj
1233*38fd1498Szrj /**
1234*38fd1498Szrj * @brief A template function that inserts a range of elements.
1235*38fd1498Szrj * @param __first Iterator pointing to the start of the range to be
1236*38fd1498Szrj * inserted.
1237*38fd1498Szrj * @param __last Iterator pointing to the end of the range.
1238*38fd1498Szrj *
1239*38fd1498Szrj * Complexity similar to that of the range constructor.
1240*38fd1498Szrj */
1241*38fd1498Szrj template<typename _InputIterator>
1242*38fd1498Szrj void
1243*38fd1498Szrj insert(_InputIterator __first, _InputIterator __last)
1244*38fd1498Szrj { _M_h.insert(__first, __last); }
1245*38fd1498Szrj
1246*38fd1498Szrj /**
1247*38fd1498Szrj * @brief Inserts a list of elements into the %unordered_multiset.
1248*38fd1498Szrj * @param __l A std::initializer_list<value_type> of elements to be
1249*38fd1498Szrj * inserted.
1250*38fd1498Szrj *
1251*38fd1498Szrj * Complexity similar to that of the range constructor.
1252*38fd1498Szrj */
1253*38fd1498Szrj void
1254*38fd1498Szrj insert(initializer_list<value_type> __l)
1255*38fd1498Szrj { _M_h.insert(__l); }
1256*38fd1498Szrj
1257*38fd1498Szrj #if __cplusplus > 201402L
1258*38fd1498Szrj /// Extract a node.
1259*38fd1498Szrj node_type
1260*38fd1498Szrj extract(const_iterator __pos)
1261*38fd1498Szrj {
1262*38fd1498Szrj __glibcxx_assert(__pos != end());
1263*38fd1498Szrj return _M_h.extract(__pos);
1264*38fd1498Szrj }
1265*38fd1498Szrj
1266*38fd1498Szrj /// Extract a node.
1267*38fd1498Szrj node_type
1268*38fd1498Szrj extract(const key_type& __key)
1269*38fd1498Szrj { return _M_h.extract(__key); }
1270*38fd1498Szrj
1271*38fd1498Szrj /// Re-insert an extracted node.
1272*38fd1498Szrj iterator
1273*38fd1498Szrj insert(node_type&& __nh)
1274*38fd1498Szrj { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); }
1275*38fd1498Szrj
1276*38fd1498Szrj /// Re-insert an extracted node.
1277*38fd1498Szrj iterator
1278*38fd1498Szrj insert(const_iterator __hint, node_type&& __nh)
1279*38fd1498Szrj { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); }
1280*38fd1498Szrj #endif // C++17
1281*38fd1498Szrj
1282*38fd1498Szrj //@{
1283*38fd1498Szrj /**
1284*38fd1498Szrj * @brief Erases an element from an %unordered_multiset.
1285*38fd1498Szrj * @param __position An iterator pointing to the element to be erased.
1286*38fd1498Szrj * @return An iterator pointing to the element immediately following
1287*38fd1498Szrj * @a __position prior to the element being erased. If no such
1288*38fd1498Szrj * element exists, end() is returned.
1289*38fd1498Szrj *
1290*38fd1498Szrj * This function erases an element, pointed to by the given iterator,
1291*38fd1498Szrj * from an %unordered_multiset.
1292*38fd1498Szrj *
1293*38fd1498Szrj * Note that this function only erases the element, and that if the
1294*38fd1498Szrj * element is itself a pointer, the pointed-to memory is not touched in
1295*38fd1498Szrj * any way. Managing the pointer is the user's responsibility.
1296*38fd1498Szrj */
1297*38fd1498Szrj iterator
1298*38fd1498Szrj erase(const_iterator __position)
1299*38fd1498Szrj { return _M_h.erase(__position); }
1300*38fd1498Szrj
1301*38fd1498Szrj // LWG 2059.
1302*38fd1498Szrj iterator
1303*38fd1498Szrj erase(iterator __position)
1304*38fd1498Szrj { return _M_h.erase(__position); }
1305*38fd1498Szrj //@}
1306*38fd1498Szrj
1307*38fd1498Szrj
1308*38fd1498Szrj /**
1309*38fd1498Szrj * @brief Erases elements according to the provided key.
1310*38fd1498Szrj * @param __x Key of element to be erased.
1311*38fd1498Szrj * @return The number of elements erased.
1312*38fd1498Szrj *
1313*38fd1498Szrj * This function erases all the elements located by the given key from
1314*38fd1498Szrj * an %unordered_multiset.
1315*38fd1498Szrj *
1316*38fd1498Szrj * Note that this function only erases the element, and that if the
1317*38fd1498Szrj * element is itself a pointer, the pointed-to memory is not touched in
1318*38fd1498Szrj * any way. Managing the pointer is the user's responsibility.
1319*38fd1498Szrj */
1320*38fd1498Szrj size_type
1321*38fd1498Szrj erase(const key_type& __x)
1322*38fd1498Szrj { return _M_h.erase(__x); }
1323*38fd1498Szrj
1324*38fd1498Szrj /**
1325*38fd1498Szrj * @brief Erases a [__first,__last) range of elements from an
1326*38fd1498Szrj * %unordered_multiset.
1327*38fd1498Szrj * @param __first Iterator pointing to the start of the range to be
1328*38fd1498Szrj * erased.
1329*38fd1498Szrj * @param __last Iterator pointing to the end of the range to
1330*38fd1498Szrj * be erased.
1331*38fd1498Szrj * @return The iterator @a __last.
1332*38fd1498Szrj *
1333*38fd1498Szrj * This function erases a sequence of elements from an
1334*38fd1498Szrj * %unordered_multiset.
1335*38fd1498Szrj *
1336*38fd1498Szrj * Note that this function only erases the element, and that if
1337*38fd1498Szrj * the element is itself a pointer, the pointed-to memory is not touched
1338*38fd1498Szrj * in any way. Managing the pointer is the user's responsibility.
1339*38fd1498Szrj */
1340*38fd1498Szrj iterator
1341*38fd1498Szrj erase(const_iterator __first, const_iterator __last)
1342*38fd1498Szrj { return _M_h.erase(__first, __last); }
1343*38fd1498Szrj
1344*38fd1498Szrj /**
1345*38fd1498Szrj * Erases all elements in an %unordered_multiset.
1346*38fd1498Szrj *
1347*38fd1498Szrj * Note that this function only erases the elements, and that if the
1348*38fd1498Szrj * elements themselves are pointers, the pointed-to memory is not touched
1349*38fd1498Szrj * in any way. Managing the pointer is the user's responsibility.
1350*38fd1498Szrj */
1351*38fd1498Szrj void
1352*38fd1498Szrj clear() noexcept
1353*38fd1498Szrj { _M_h.clear(); }
1354*38fd1498Szrj
1355*38fd1498Szrj /**
1356*38fd1498Szrj * @brief Swaps data with another %unordered_multiset.
1357*38fd1498Szrj * @param __x An %unordered_multiset of the same element and allocator
1358*38fd1498Szrj * types.
1359*38fd1498Szrj *
1360*38fd1498Szrj * This exchanges the elements between two sets in constant time.
1361*38fd1498Szrj * Note that the global std::swap() function is specialized such that
1362*38fd1498Szrj * std::swap(s1,s2) will feed to this function.
1363*38fd1498Szrj */
1364*38fd1498Szrj void
1365*38fd1498Szrj swap(unordered_multiset& __x)
1366*38fd1498Szrj noexcept( noexcept(_M_h.swap(__x._M_h)) )
1367*38fd1498Szrj { _M_h.swap(__x._M_h); }
1368*38fd1498Szrj
1369*38fd1498Szrj #if __cplusplus > 201402L
1370*38fd1498Szrj template<typename, typename, typename>
1371*38fd1498Szrj friend class std::_Hash_merge_helper;
1372*38fd1498Szrj
1373*38fd1498Szrj template<typename _H2, typename _P2>
1374*38fd1498Szrj void
1375*38fd1498Szrj merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source)
1376*38fd1498Szrj {
1377*38fd1498Szrj using _Merge_helper
1378*38fd1498Szrj = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1379*38fd1498Szrj _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1380*38fd1498Szrj }
1381*38fd1498Szrj
1382*38fd1498Szrj template<typename _H2, typename _P2>
1383*38fd1498Szrj void
1384*38fd1498Szrj merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
1385*38fd1498Szrj { merge(__source); }
1386*38fd1498Szrj
1387*38fd1498Szrj template<typename _H2, typename _P2>
1388*38fd1498Szrj void
1389*38fd1498Szrj merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source)
1390*38fd1498Szrj {
1391*38fd1498Szrj using _Merge_helper
1392*38fd1498Szrj = _Hash_merge_helper<unordered_multiset, _H2, _P2>;
1393*38fd1498Szrj _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source));
1394*38fd1498Szrj }
1395*38fd1498Szrj
1396*38fd1498Szrj template<typename _H2, typename _P2>
1397*38fd1498Szrj void
1398*38fd1498Szrj merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
1399*38fd1498Szrj { merge(__source); }
1400*38fd1498Szrj #endif // C++17
1401*38fd1498Szrj
1402*38fd1498Szrj // observers.
1403*38fd1498Szrj
1404*38fd1498Szrj /// Returns the hash functor object with which the %unordered_multiset
1405*38fd1498Szrj /// was constructed.
1406*38fd1498Szrj hasher
1407*38fd1498Szrj hash_function() const
1408*38fd1498Szrj { return _M_h.hash_function(); }
1409*38fd1498Szrj
1410*38fd1498Szrj /// Returns the key comparison object with which the %unordered_multiset
1411*38fd1498Szrj /// was constructed.
1412*38fd1498Szrj key_equal
1413*38fd1498Szrj key_eq() const
1414*38fd1498Szrj { return _M_h.key_eq(); }
1415*38fd1498Szrj
1416*38fd1498Szrj // lookup.
1417*38fd1498Szrj
1418*38fd1498Szrj //@{
1419*38fd1498Szrj /**
1420*38fd1498Szrj * @brief Tries to locate an element in an %unordered_multiset.
1421*38fd1498Szrj * @param __x Element to be located.
1422*38fd1498Szrj * @return Iterator pointing to sought-after element, or end() if not
1423*38fd1498Szrj * found.
1424*38fd1498Szrj *
1425*38fd1498Szrj * This function takes a key and tries to locate the element with which
1426*38fd1498Szrj * the key matches. If successful the function returns an iterator
1427*38fd1498Szrj * pointing to the sought after element. If unsuccessful it returns the
1428*38fd1498Szrj * past-the-end ( @c end() ) iterator.
1429*38fd1498Szrj */
1430*38fd1498Szrj iterator
1431*38fd1498Szrj find(const key_type& __x)
1432*38fd1498Szrj { return _M_h.find(__x); }
1433*38fd1498Szrj
1434*38fd1498Szrj const_iterator
1435*38fd1498Szrj find(const key_type& __x) const
1436*38fd1498Szrj { return _M_h.find(__x); }
1437*38fd1498Szrj //@}
1438*38fd1498Szrj
1439*38fd1498Szrj /**
1440*38fd1498Szrj * @brief Finds the number of elements.
1441*38fd1498Szrj * @param __x Element to located.
1442*38fd1498Szrj * @return Number of elements with specified key.
1443*38fd1498Szrj */
1444*38fd1498Szrj size_type
1445*38fd1498Szrj count(const key_type& __x) const
1446*38fd1498Szrj { return _M_h.count(__x); }
1447*38fd1498Szrj
1448*38fd1498Szrj //@{
1449*38fd1498Szrj /**
1450*38fd1498Szrj * @brief Finds a subsequence matching given key.
1451*38fd1498Szrj * @param __x Key to be located.
1452*38fd1498Szrj * @return Pair of iterators that possibly points to the subsequence
1453*38fd1498Szrj * matching given key.
1454*38fd1498Szrj */
1455*38fd1498Szrj std::pair<iterator, iterator>
1456*38fd1498Szrj equal_range(const key_type& __x)
1457*38fd1498Szrj { return _M_h.equal_range(__x); }
1458*38fd1498Szrj
1459*38fd1498Szrj std::pair<const_iterator, const_iterator>
1460*38fd1498Szrj equal_range(const key_type& __x) const
1461*38fd1498Szrj { return _M_h.equal_range(__x); }
1462*38fd1498Szrj //@}
1463*38fd1498Szrj
1464*38fd1498Szrj // bucket interface.
1465*38fd1498Szrj
1466*38fd1498Szrj /// Returns the number of buckets of the %unordered_multiset.
1467*38fd1498Szrj size_type
1468*38fd1498Szrj bucket_count() const noexcept
1469*38fd1498Szrj { return _M_h.bucket_count(); }
1470*38fd1498Szrj
1471*38fd1498Szrj /// Returns the maximum number of buckets of the %unordered_multiset.
1472*38fd1498Szrj size_type
1473*38fd1498Szrj max_bucket_count() const noexcept
1474*38fd1498Szrj { return _M_h.max_bucket_count(); }
1475*38fd1498Szrj
1476*38fd1498Szrj /*
1477*38fd1498Szrj * @brief Returns the number of elements in a given bucket.
1478*38fd1498Szrj * @param __n A bucket index.
1479*38fd1498Szrj * @return The number of elements in the bucket.
1480*38fd1498Szrj */
1481*38fd1498Szrj size_type
1482*38fd1498Szrj bucket_size(size_type __n) const
1483*38fd1498Szrj { return _M_h.bucket_size(__n); }
1484*38fd1498Szrj
1485*38fd1498Szrj /*
1486*38fd1498Szrj * @brief Returns the bucket index of a given element.
1487*38fd1498Szrj * @param __key A key instance.
1488*38fd1498Szrj * @return The key bucket index.
1489*38fd1498Szrj */
1490*38fd1498Szrj size_type
1491*38fd1498Szrj bucket(const key_type& __key) const
1492*38fd1498Szrj { return _M_h.bucket(__key); }
1493*38fd1498Szrj
1494*38fd1498Szrj //@{
1495*38fd1498Szrj /**
1496*38fd1498Szrj * @brief Returns a read-only (constant) iterator pointing to the first
1497*38fd1498Szrj * bucket element.
1498*38fd1498Szrj * @param __n The bucket index.
1499*38fd1498Szrj * @return A read-only local iterator.
1500*38fd1498Szrj */
1501*38fd1498Szrj local_iterator
1502*38fd1498Szrj begin(size_type __n)
1503*38fd1498Szrj { return _M_h.begin(__n); }
1504*38fd1498Szrj
1505*38fd1498Szrj const_local_iterator
1506*38fd1498Szrj begin(size_type __n) const
1507*38fd1498Szrj { return _M_h.begin(__n); }
1508*38fd1498Szrj
1509*38fd1498Szrj const_local_iterator
1510*38fd1498Szrj cbegin(size_type __n) const
1511*38fd1498Szrj { return _M_h.cbegin(__n); }
1512*38fd1498Szrj //@}
1513*38fd1498Szrj
1514*38fd1498Szrj //@{
1515*38fd1498Szrj /**
1516*38fd1498Szrj * @brief Returns a read-only (constant) iterator pointing to one past
1517*38fd1498Szrj * the last bucket elements.
1518*38fd1498Szrj * @param __n The bucket index.
1519*38fd1498Szrj * @return A read-only local iterator.
1520*38fd1498Szrj */
1521*38fd1498Szrj local_iterator
1522*38fd1498Szrj end(size_type __n)
1523*38fd1498Szrj { return _M_h.end(__n); }
1524*38fd1498Szrj
1525*38fd1498Szrj const_local_iterator
1526*38fd1498Szrj end(size_type __n) const
1527*38fd1498Szrj { return _M_h.end(__n); }
1528*38fd1498Szrj
1529*38fd1498Szrj const_local_iterator
1530*38fd1498Szrj cend(size_type __n) const
1531*38fd1498Szrj { return _M_h.cend(__n); }
1532*38fd1498Szrj //@}
1533*38fd1498Szrj
1534*38fd1498Szrj // hash policy.
1535*38fd1498Szrj
1536*38fd1498Szrj /// Returns the average number of elements per bucket.
1537*38fd1498Szrj float
1538*38fd1498Szrj load_factor() const noexcept
1539*38fd1498Szrj { return _M_h.load_factor(); }
1540*38fd1498Szrj
1541*38fd1498Szrj /// Returns a positive number that the %unordered_multiset tries to keep the
1542*38fd1498Szrj /// load factor less than or equal to.
1543*38fd1498Szrj float
1544*38fd1498Szrj max_load_factor() const noexcept
1545*38fd1498Szrj { return _M_h.max_load_factor(); }
1546*38fd1498Szrj
1547*38fd1498Szrj /**
1548*38fd1498Szrj * @brief Change the %unordered_multiset maximum load factor.
1549*38fd1498Szrj * @param __z The new maximum load factor.
1550*38fd1498Szrj */
1551*38fd1498Szrj void
1552*38fd1498Szrj max_load_factor(float __z)
1553*38fd1498Szrj { _M_h.max_load_factor(__z); }
1554*38fd1498Szrj
1555*38fd1498Szrj /**
1556*38fd1498Szrj * @brief May rehash the %unordered_multiset.
1557*38fd1498Szrj * @param __n The new number of buckets.
1558*38fd1498Szrj *
1559*38fd1498Szrj * Rehash will occur only if the new number of buckets respect the
1560*38fd1498Szrj * %unordered_multiset maximum load factor.
1561*38fd1498Szrj */
1562*38fd1498Szrj void
1563*38fd1498Szrj rehash(size_type __n)
1564*38fd1498Szrj { _M_h.rehash(__n); }
1565*38fd1498Szrj
1566*38fd1498Szrj /**
1567*38fd1498Szrj * @brief Prepare the %unordered_multiset for a specified number of
1568*38fd1498Szrj * elements.
1569*38fd1498Szrj * @param __n Number of elements required.
1570*38fd1498Szrj *
1571*38fd1498Szrj * Same as rehash(ceil(n / max_load_factor())).
1572*38fd1498Szrj */
1573*38fd1498Szrj void
1574*38fd1498Szrj reserve(size_type __n)
1575*38fd1498Szrj { _M_h.reserve(__n); }
1576*38fd1498Szrj
1577*38fd1498Szrj template<typename _Value1, typename _Hash1, typename _Pred1,
1578*38fd1498Szrj typename _Alloc1>
1579*38fd1498Szrj friend bool
1580*38fd1498Szrj operator==(const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&,
1581*38fd1498Szrj const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&);
1582*38fd1498Szrj };
1583*38fd1498Szrj
1584*38fd1498Szrj
1585*38fd1498Szrj #if __cpp_deduction_guides >= 201606
1586*38fd1498Szrj
1587*38fd1498Szrj template<typename _InputIterator,
1588*38fd1498Szrj typename _Hash =
1589*38fd1498Szrj hash<typename iterator_traits<_InputIterator>::value_type>,
1590*38fd1498Szrj typename _Pred =
1591*38fd1498Szrj equal_to<typename iterator_traits<_InputIterator>::value_type>,
1592*38fd1498Szrj typename _Allocator =
1593*38fd1498Szrj allocator<typename iterator_traits<_InputIterator>::value_type>,
1594*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
1595*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1596*38fd1498Szrj unordered_multiset(_InputIterator, _InputIterator,
1597*38fd1498Szrj unordered_multiset<int>::size_type = {},
1598*38fd1498Szrj _Hash = _Hash(), _Pred = _Pred(),
1599*38fd1498Szrj _Allocator = _Allocator())
1600*38fd1498Szrj -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1601*38fd1498Szrj _Hash, _Pred, _Allocator>;
1602*38fd1498Szrj
1603*38fd1498Szrj template<typename _Tp, typename _Hash = hash<_Tp>,
1604*38fd1498Szrj typename _Pred = equal_to<_Tp>,
1605*38fd1498Szrj typename _Allocator = allocator<_Tp>,
1606*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1607*38fd1498Szrj unordered_multiset(initializer_list<_Tp>,
1608*38fd1498Szrj unordered_multiset<int>::size_type = {},
1609*38fd1498Szrj _Hash = _Hash(), _Pred = _Pred(),
1610*38fd1498Szrj _Allocator = _Allocator())
1611*38fd1498Szrj -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
1612*38fd1498Szrj
1613*38fd1498Szrj template<typename _InputIterator, typename _Allocator,
1614*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
1615*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1616*38fd1498Szrj unordered_multiset(_InputIterator, _InputIterator,
1617*38fd1498Szrj unordered_multiset<int>::size_type, _Allocator)
1618*38fd1498Szrj -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1619*38fd1498Szrj hash<typename
1620*38fd1498Szrj iterator_traits<_InputIterator>::value_type>,
1621*38fd1498Szrj equal_to<typename
1622*38fd1498Szrj iterator_traits<_InputIterator>::value_type>,
1623*38fd1498Szrj _Allocator>;
1624*38fd1498Szrj
1625*38fd1498Szrj template<typename _InputIterator, typename _Hash, typename _Allocator,
1626*38fd1498Szrj typename = _RequireInputIter<_InputIterator>,
1627*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1628*38fd1498Szrj unordered_multiset(_InputIterator, _InputIterator,
1629*38fd1498Szrj unordered_multiset<int>::size_type,
1630*38fd1498Szrj _Hash, _Allocator)
1631*38fd1498Szrj -> unordered_multiset<typename
1632*38fd1498Szrj iterator_traits<_InputIterator>::value_type,
1633*38fd1498Szrj _Hash,
1634*38fd1498Szrj equal_to<
1635*38fd1498Szrj typename
1636*38fd1498Szrj iterator_traits<_InputIterator>::value_type>,
1637*38fd1498Szrj _Allocator>;
1638*38fd1498Szrj
1639*38fd1498Szrj template<typename _Tp, typename _Allocator,
1640*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1641*38fd1498Szrj unordered_multiset(initializer_list<_Tp>,
1642*38fd1498Szrj unordered_multiset<int>::size_type, _Allocator)
1643*38fd1498Szrj -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1644*38fd1498Szrj
1645*38fd1498Szrj template<typename _Tp, typename _Hash, typename _Allocator,
1646*38fd1498Szrj typename = _RequireAllocator<_Allocator>>
1647*38fd1498Szrj unordered_multiset(initializer_list<_Tp>,
1648*38fd1498Szrj unordered_multiset<int>::size_type, _Hash, _Allocator)
1649*38fd1498Szrj -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1650*38fd1498Szrj
1651*38fd1498Szrj #endif
1652*38fd1498Szrj
1653*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1654*38fd1498Szrj inline void
1655*38fd1498Szrj swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1656*38fd1498Szrj unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1657*38fd1498Szrj noexcept(noexcept(__x.swap(__y)))
1658*38fd1498Szrj { __x.swap(__y); }
1659*38fd1498Szrj
1660*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1661*38fd1498Szrj inline void
1662*38fd1498Szrj swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1663*38fd1498Szrj unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1664*38fd1498Szrj noexcept(noexcept(__x.swap(__y)))
1665*38fd1498Szrj { __x.swap(__y); }
1666*38fd1498Szrj
1667*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1668*38fd1498Szrj inline bool
1669*38fd1498Szrj operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1670*38fd1498Szrj const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1671*38fd1498Szrj { return __x._M_h._M_equal(__y._M_h); }
1672*38fd1498Szrj
1673*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1674*38fd1498Szrj inline bool
1675*38fd1498Szrj operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1676*38fd1498Szrj const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1677*38fd1498Szrj { return !(__x == __y); }
1678*38fd1498Szrj
1679*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1680*38fd1498Szrj inline bool
1681*38fd1498Szrj operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1682*38fd1498Szrj const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1683*38fd1498Szrj { return __x._M_h._M_equal(__y._M_h); }
1684*38fd1498Szrj
1685*38fd1498Szrj template<class _Value, class _Hash, class _Pred, class _Alloc>
1686*38fd1498Szrj inline bool
1687*38fd1498Szrj operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1688*38fd1498Szrj const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1689*38fd1498Szrj { return !(__x == __y); }
1690*38fd1498Szrj
1691*38fd1498Szrj _GLIBCXX_END_NAMESPACE_CONTAINER
1692*38fd1498Szrj
1693*38fd1498Szrj #if __cplusplus > 201402L
1694*38fd1498Szrj // Allow std::unordered_set access to internals of compatible sets.
1695*38fd1498Szrj template<typename _Val, typename _Hash1, typename _Eq1, typename _Alloc,
1696*38fd1498Szrj typename _Hash2, typename _Eq2>
1697*38fd1498Szrj struct _Hash_merge_helper<
1698*38fd1498Szrj _GLIBCXX_STD_C::unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2>
1699*38fd1498Szrj {
1700*38fd1498Szrj private:
1701*38fd1498Szrj template<typename... _Tp>
1702*38fd1498Szrj using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
1703*38fd1498Szrj template<typename... _Tp>
1704*38fd1498Szrj using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
1705*38fd1498Szrj
1706*38fd1498Szrj friend unordered_set<_Val, _Hash1, _Eq1, _Alloc>;
1707*38fd1498Szrj
1708*38fd1498Szrj static auto&
1709*38fd1498Szrj _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set)
1710*38fd1498Szrj { return __set._M_h; }
1711*38fd1498Szrj
1712*38fd1498Szrj static auto&
1713*38fd1498Szrj _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set)
1714*38fd1498Szrj { return __set._M_h; }
1715*38fd1498Szrj };
1716*38fd1498Szrj
1717*38fd1498Szrj // Allow std::unordered_multiset access to internals of compatible sets.
1718*38fd1498Szrj template<typename _Val, typename _Hash1, typename _Eq1, typename _Alloc,
1719*38fd1498Szrj typename _Hash2, typename _Eq2>
1720*38fd1498Szrj struct _Hash_merge_helper<
1721*38fd1498Szrj _GLIBCXX_STD_C::unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>,
1722*38fd1498Szrj _Hash2, _Eq2>
1723*38fd1498Szrj {
1724*38fd1498Szrj private:
1725*38fd1498Szrj template<typename... _Tp>
1726*38fd1498Szrj using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
1727*38fd1498Szrj template<typename... _Tp>
1728*38fd1498Szrj using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
1729*38fd1498Szrj
1730*38fd1498Szrj friend unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>;
1731*38fd1498Szrj
1732*38fd1498Szrj static auto&
1733*38fd1498Szrj _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set)
1734*38fd1498Szrj { return __set._M_h; }
1735*38fd1498Szrj
1736*38fd1498Szrj static auto&
1737*38fd1498Szrj _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set)
1738*38fd1498Szrj { return __set._M_h; }
1739*38fd1498Szrj };
1740*38fd1498Szrj #endif // C++17
1741*38fd1498Szrj
1742*38fd1498Szrj _GLIBCXX_END_NAMESPACE_VERSION
1743*38fd1498Szrj } // namespace std
1744*38fd1498Szrj
1745*38fd1498Szrj #endif /* _UNORDERED_SET_H */
1746