xref: /freebsd/contrib/llvm-project/libcxx/include/unordered_set (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric// -*- C++ -*-
2*0b57cec5SDimitry Andric//===-------------------------- unordered_set -----------------------------===//
3*0b57cec5SDimitry Andric//
4*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*0b57cec5SDimitry Andric//
8*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
9*0b57cec5SDimitry Andric
10*0b57cec5SDimitry Andric#ifndef _LIBCPP_UNORDERED_SET
11*0b57cec5SDimitry Andric#define _LIBCPP_UNORDERED_SET
12*0b57cec5SDimitry Andric
13*0b57cec5SDimitry Andric/*
14*0b57cec5SDimitry Andric
15*0b57cec5SDimitry Andric    unordered_set synopsis
16*0b57cec5SDimitry Andric
17*0b57cec5SDimitry Andric#include <initializer_list>
18*0b57cec5SDimitry Andric
19*0b57cec5SDimitry Andricnamespace std
20*0b57cec5SDimitry Andric{
21*0b57cec5SDimitry Andric
22*0b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
23*0b57cec5SDimitry Andric          class Alloc = allocator<Value>>
24*0b57cec5SDimitry Andricclass unordered_set
25*0b57cec5SDimitry Andric{
26*0b57cec5SDimitry Andricpublic:
27*0b57cec5SDimitry Andric    // types
28*0b57cec5SDimitry Andric    typedef Value                                                      key_type;
29*0b57cec5SDimitry Andric    typedef key_type                                                   value_type;
30*0b57cec5SDimitry Andric    typedef Hash                                                       hasher;
31*0b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
32*0b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
33*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
34*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
35*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
36*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
37*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
38*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
39*0b57cec5SDimitry Andric
40*0b57cec5SDimitry Andric    typedef /unspecified/ iterator;
41*0b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
42*0b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
43*0b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
44*0b57cec5SDimitry Andric
45*0b57cec5SDimitry Andric    typedef unspecified node_type unspecified;                            // C++17
46*0b57cec5SDimitry Andric    typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type;   // C++17
47*0b57cec5SDimitry Andric
48*0b57cec5SDimitry Andric    unordered_set()
49*0b57cec5SDimitry Andric        noexcept(
50*0b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
51*0b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
52*0b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
53*0b57cec5SDimitry Andric    explicit unordered_set(size_type n, const hasher& hf = hasher(),
54*0b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
55*0b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
56*0b57cec5SDimitry Andric    template <class InputIterator>
57*0b57cec5SDimitry Andric        unordered_set(InputIterator f, InputIterator l,
58*0b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
59*0b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
60*0b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
61*0b57cec5SDimitry Andric    explicit unordered_set(const allocator_type&);
62*0b57cec5SDimitry Andric    unordered_set(const unordered_set&);
63*0b57cec5SDimitry Andric    unordered_set(const unordered_set&, const Allocator&);
64*0b57cec5SDimitry Andric    unordered_set(unordered_set&&)
65*0b57cec5SDimitry Andric        noexcept(
66*0b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
67*0b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
68*0b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
69*0b57cec5SDimitry Andric    unordered_set(unordered_set&&, const Allocator&);
70*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type>, size_type n = 0,
71*0b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
72*0b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
73*0b57cec5SDimitry Andric    unordered_set(size_type n, const allocator_type& a); // C++14
74*0b57cec5SDimitry Andric    unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
75*0b57cec5SDimitry Andric    template <class InputIterator>
76*0b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
77*0b57cec5SDimitry Andric    template <class InputIterator>
78*0b57cec5SDimitry Andric      unordered_set(InputIterator f, InputIterator l, size_type n,
79*0b57cec5SDimitry Andric                    const hasher& hf,  const allocator_type& a); // C++14
80*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
81*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> il, size_type n,
82*0b57cec5SDimitry Andric                  const hasher& hf,  const allocator_type& a); // C++14
83*0b57cec5SDimitry Andric    ~unordered_set();
84*0b57cec5SDimitry Andric    unordered_set& operator=(const unordered_set&);
85*0b57cec5SDimitry Andric    unordered_set& operator=(unordered_set&&)
86*0b57cec5SDimitry Andric        noexcept(
87*0b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
88*0b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
89*0b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
90*0b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
91*0b57cec5SDimitry Andric    unordered_set& operator=(initializer_list<value_type>);
92*0b57cec5SDimitry Andric
93*0b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
94*0b57cec5SDimitry Andric
95*0b57cec5SDimitry Andric    bool      empty() const noexcept;
96*0b57cec5SDimitry Andric    size_type size() const noexcept;
97*0b57cec5SDimitry Andric    size_type max_size() const noexcept;
98*0b57cec5SDimitry Andric
99*0b57cec5SDimitry Andric    iterator       begin() noexcept;
100*0b57cec5SDimitry Andric    iterator       end() noexcept;
101*0b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
102*0b57cec5SDimitry Andric    const_iterator end()    const noexcept;
103*0b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
104*0b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
105*0b57cec5SDimitry Andric
106*0b57cec5SDimitry Andric    template <class... Args>
107*0b57cec5SDimitry Andric        pair<iterator, bool> emplace(Args&&... args);
108*0b57cec5SDimitry Andric    template <class... Args>
109*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
110*0b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& obj);
111*0b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& obj);
112*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
113*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
114*0b57cec5SDimitry Andric    template <class InputIterator>
115*0b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
116*0b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
117*0b57cec5SDimitry Andric
118*0b57cec5SDimitry Andric    node_type extract(const_iterator position);                       // C++17
119*0b57cec5SDimitry Andric    node_type extract(const key_type& x);                             // C++17
120*0b57cec5SDimitry Andric    insert_return_type insert(node_type&& nh);                        // C++17
121*0b57cec5SDimitry Andric    iterator           insert(const_iterator hint, node_type&& nh);   // C++17
122*0b57cec5SDimitry Andric
123*0b57cec5SDimitry Andric    iterator erase(const_iterator position);
124*0b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
125*0b57cec5SDimitry Andric    size_type erase(const key_type& k);
126*0b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
127*0b57cec5SDimitry Andric    void clear() noexcept;
128*0b57cec5SDimitry Andric
129*0b57cec5SDimitry Andric    template<class H2, class P2>
130*0b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
131*0b57cec5SDimitry Andric    template<class H2, class P2>
132*0b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
133*0b57cec5SDimitry Andric    template<class H2, class P2>
134*0b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
135*0b57cec5SDimitry Andric    template<class H2, class P2>
136*0b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
137*0b57cec5SDimitry Andric
138*0b57cec5SDimitry Andric    void swap(unordered_set&)
139*0b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
140*0b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
141*0b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
142*0b57cec5SDimitry Andric
143*0b57cec5SDimitry Andric    hasher hash_function() const;
144*0b57cec5SDimitry Andric    key_equal key_eq() const;
145*0b57cec5SDimitry Andric
146*0b57cec5SDimitry Andric    iterator       find(const key_type& k);
147*0b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
148*0b57cec5SDimitry Andric    size_type count(const key_type& k) const;
149*0b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
150*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
151*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
152*0b57cec5SDimitry Andric
153*0b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
154*0b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
155*0b57cec5SDimitry Andric
156*0b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
157*0b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
158*0b57cec5SDimitry Andric
159*0b57cec5SDimitry Andric    local_iterator       begin(size_type n);
160*0b57cec5SDimitry Andric    local_iterator       end(size_type n);
161*0b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
162*0b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
163*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
164*0b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
165*0b57cec5SDimitry Andric
166*0b57cec5SDimitry Andric    float load_factor() const noexcept;
167*0b57cec5SDimitry Andric    float max_load_factor() const noexcept;
168*0b57cec5SDimitry Andric    void max_load_factor(float z);
169*0b57cec5SDimitry Andric    void rehash(size_type n);
170*0b57cec5SDimitry Andric    void reserve(size_type n);
171*0b57cec5SDimitry Andric};
172*0b57cec5SDimitry Andric
173*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
174*0b57cec5SDimitry Andric    void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
175*0b57cec5SDimitry Andric              unordered_set<Value, Hash, Pred, Alloc>& y)
176*0b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
177*0b57cec5SDimitry Andric
178*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
179*0b57cec5SDimitry Andric    bool
180*0b57cec5SDimitry Andric    operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
181*0b57cec5SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y);
182*0b57cec5SDimitry Andric
183*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
184*0b57cec5SDimitry Andric    bool
185*0b57cec5SDimitry Andric    operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
186*0b57cec5SDimitry Andric               const unordered_set<Value, Hash, Pred, Alloc>& y);
187*0b57cec5SDimitry Andric
188*0b57cec5SDimitry Andrictemplate <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
189*0b57cec5SDimitry Andric          class Alloc = allocator<Value>>
190*0b57cec5SDimitry Andricclass unordered_multiset
191*0b57cec5SDimitry Andric{
192*0b57cec5SDimitry Andricpublic:
193*0b57cec5SDimitry Andric    // types
194*0b57cec5SDimitry Andric    typedef Value                                                      key_type;
195*0b57cec5SDimitry Andric    typedef key_type                                                   value_type;
196*0b57cec5SDimitry Andric    typedef Hash                                                       hasher;
197*0b57cec5SDimitry Andric    typedef Pred                                                       key_equal;
198*0b57cec5SDimitry Andric    typedef Alloc                                                      allocator_type;
199*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
200*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
201*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::pointer         pointer;
202*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
203*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::size_type       size_type;
204*0b57cec5SDimitry Andric    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
205*0b57cec5SDimitry Andric
206*0b57cec5SDimitry Andric    typedef /unspecified/ iterator;
207*0b57cec5SDimitry Andric    typedef /unspecified/ const_iterator;
208*0b57cec5SDimitry Andric    typedef /unspecified/ local_iterator;
209*0b57cec5SDimitry Andric    typedef /unspecified/ const_local_iterator;
210*0b57cec5SDimitry Andric
211*0b57cec5SDimitry Andric    typedef unspecified node_type unspecified;   // C++17
212*0b57cec5SDimitry Andric
213*0b57cec5SDimitry Andric    unordered_multiset()
214*0b57cec5SDimitry Andric        noexcept(
215*0b57cec5SDimitry Andric            is_nothrow_default_constructible<hasher>::value &&
216*0b57cec5SDimitry Andric            is_nothrow_default_constructible<key_equal>::value &&
217*0b57cec5SDimitry Andric            is_nothrow_default_constructible<allocator_type>::value);
218*0b57cec5SDimitry Andric    explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
219*0b57cec5SDimitry Andric                           const key_equal& eql = key_equal(),
220*0b57cec5SDimitry Andric                           const allocator_type& a = allocator_type());
221*0b57cec5SDimitry Andric    template <class InputIterator>
222*0b57cec5SDimitry Andric        unordered_multiset(InputIterator f, InputIterator l,
223*0b57cec5SDimitry Andric                      size_type n = 0, const hasher& hf = hasher(),
224*0b57cec5SDimitry Andric                      const key_equal& eql = key_equal(),
225*0b57cec5SDimitry Andric                      const allocator_type& a = allocator_type());
226*0b57cec5SDimitry Andric    explicit unordered_multiset(const allocator_type&);
227*0b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&);
228*0b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset&, const Allocator&);
229*0b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&)
230*0b57cec5SDimitry Andric        noexcept(
231*0b57cec5SDimitry Andric            is_nothrow_move_constructible<hasher>::value &&
232*0b57cec5SDimitry Andric            is_nothrow_move_constructible<key_equal>::value &&
233*0b57cec5SDimitry Andric            is_nothrow_move_constructible<allocator_type>::value);
234*0b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&&, const Allocator&);
235*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
236*0b57cec5SDimitry Andric                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
237*0b57cec5SDimitry Andric                  const allocator_type& a = allocator_type());
238*0b57cec5SDimitry Andric    unordered_multiset(size_type n, const allocator_type& a); // C++14
239*0b57cec5SDimitry Andric    unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
240*0b57cec5SDimitry Andric    template <class InputIterator>
241*0b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
242*0b57cec5SDimitry Andric    template <class InputIterator>
243*0b57cec5SDimitry Andric      unordered_multiset(InputIterator f, InputIterator l, size_type n,
244*0b57cec5SDimitry Andric                         const hasher& hf, const allocator_type& a); // C++14
245*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
246*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> il, size_type n,
247*0b57cec5SDimitry Andric                       const hasher& hf,  const allocator_type& a); // C++14
248*0b57cec5SDimitry Andric    ~unordered_multiset();
249*0b57cec5SDimitry Andric    unordered_multiset& operator=(const unordered_multiset&);
250*0b57cec5SDimitry Andric    unordered_multiset& operator=(unordered_multiset&&)
251*0b57cec5SDimitry Andric        noexcept(
252*0b57cec5SDimitry Andric            allocator_type::propagate_on_container_move_assignment::value &&
253*0b57cec5SDimitry Andric            is_nothrow_move_assignable<allocator_type>::value &&
254*0b57cec5SDimitry Andric            is_nothrow_move_assignable<hasher>::value &&
255*0b57cec5SDimitry Andric            is_nothrow_move_assignable<key_equal>::value);
256*0b57cec5SDimitry Andric    unordered_multiset& operator=(initializer_list<value_type>);
257*0b57cec5SDimitry Andric
258*0b57cec5SDimitry Andric    allocator_type get_allocator() const noexcept;
259*0b57cec5SDimitry Andric
260*0b57cec5SDimitry Andric    bool      empty() const noexcept;
261*0b57cec5SDimitry Andric    size_type size() const noexcept;
262*0b57cec5SDimitry Andric    size_type max_size() const noexcept;
263*0b57cec5SDimitry Andric
264*0b57cec5SDimitry Andric    iterator       begin() noexcept;
265*0b57cec5SDimitry Andric    iterator       end() noexcept;
266*0b57cec5SDimitry Andric    const_iterator begin()  const noexcept;
267*0b57cec5SDimitry Andric    const_iterator end()    const noexcept;
268*0b57cec5SDimitry Andric    const_iterator cbegin() const noexcept;
269*0b57cec5SDimitry Andric    const_iterator cend()   const noexcept;
270*0b57cec5SDimitry Andric
271*0b57cec5SDimitry Andric    template <class... Args>
272*0b57cec5SDimitry Andric        iterator emplace(Args&&... args);
273*0b57cec5SDimitry Andric    template <class... Args>
274*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator position, Args&&... args);
275*0b57cec5SDimitry Andric    iterator insert(const value_type& obj);
276*0b57cec5SDimitry Andric    iterator insert(value_type&& obj);
277*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, const value_type& obj);
278*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, value_type&& obj);
279*0b57cec5SDimitry Andric    template <class InputIterator>
280*0b57cec5SDimitry Andric        void insert(InputIterator first, InputIterator last);
281*0b57cec5SDimitry Andric    void insert(initializer_list<value_type>);
282*0b57cec5SDimitry Andric
283*0b57cec5SDimitry Andric    node_type extract(const_iterator position);             // C++17
284*0b57cec5SDimitry Andric    node_type extract(const key_type& x);                   // C++17
285*0b57cec5SDimitry Andric    iterator insert(node_type&& nh);                        // C++17
286*0b57cec5SDimitry Andric    iterator insert(const_iterator hint, node_type&& nh);   // C++17
287*0b57cec5SDimitry Andric
288*0b57cec5SDimitry Andric    iterator erase(const_iterator position);
289*0b57cec5SDimitry Andric    iterator erase(iterator position);  // C++14
290*0b57cec5SDimitry Andric    size_type erase(const key_type& k);
291*0b57cec5SDimitry Andric    iterator erase(const_iterator first, const_iterator last);
292*0b57cec5SDimitry Andric    void clear() noexcept;
293*0b57cec5SDimitry Andric
294*0b57cec5SDimitry Andric    template<class H2, class P2>
295*0b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>& source);    // C++17
296*0b57cec5SDimitry Andric    template<class H2, class P2>
297*0b57cec5SDimitry Andric      void merge(unordered_multiset<Key, H2, P2, Allocator>&& source);   // C++17
298*0b57cec5SDimitry Andric    template<class H2, class P2>
299*0b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>& source);         // C++17
300*0b57cec5SDimitry Andric    template<class H2, class P2>
301*0b57cec5SDimitry Andric      void merge(unordered_set<Key, H2, P2, Allocator>&& source);        // C++17
302*0b57cec5SDimitry Andric
303*0b57cec5SDimitry Andric    void swap(unordered_multiset&)
304*0b57cec5SDimitry Andric       noexcept(allocator_traits<Allocator>::is_always_equal::value &&
305*0b57cec5SDimitry Andric                 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
306*0b57cec5SDimitry Andric                 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
307*0b57cec5SDimitry Andric
308*0b57cec5SDimitry Andric    hasher hash_function() const;
309*0b57cec5SDimitry Andric    key_equal key_eq() const;
310*0b57cec5SDimitry Andric
311*0b57cec5SDimitry Andric    iterator       find(const key_type& k);
312*0b57cec5SDimitry Andric    const_iterator find(const key_type& k) const;
313*0b57cec5SDimitry Andric    size_type count(const key_type& k) const;
314*0b57cec5SDimitry Andric    bool contains(const key_type& k) const; // C++20
315*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& k);
316*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
317*0b57cec5SDimitry Andric
318*0b57cec5SDimitry Andric    size_type bucket_count() const noexcept;
319*0b57cec5SDimitry Andric    size_type max_bucket_count() const noexcept;
320*0b57cec5SDimitry Andric
321*0b57cec5SDimitry Andric    size_type bucket_size(size_type n) const;
322*0b57cec5SDimitry Andric    size_type bucket(const key_type& k) const;
323*0b57cec5SDimitry Andric
324*0b57cec5SDimitry Andric    local_iterator       begin(size_type n);
325*0b57cec5SDimitry Andric    local_iterator       end(size_type n);
326*0b57cec5SDimitry Andric    const_local_iterator begin(size_type n) const;
327*0b57cec5SDimitry Andric    const_local_iterator end(size_type n) const;
328*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type n) const;
329*0b57cec5SDimitry Andric    const_local_iterator cend(size_type n) const;
330*0b57cec5SDimitry Andric
331*0b57cec5SDimitry Andric    float load_factor() const noexcept;
332*0b57cec5SDimitry Andric    float max_load_factor() const noexcept;
333*0b57cec5SDimitry Andric    void max_load_factor(float z);
334*0b57cec5SDimitry Andric    void rehash(size_type n);
335*0b57cec5SDimitry Andric    void reserve(size_type n);
336*0b57cec5SDimitry Andric};
337*0b57cec5SDimitry Andric
338*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
339*0b57cec5SDimitry Andric    void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
340*0b57cec5SDimitry Andric              unordered_multiset<Value, Hash, Pred, Alloc>& y)
341*0b57cec5SDimitry Andric              noexcept(noexcept(x.swap(y)));
342*0b57cec5SDimitry Andric
343*0b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
344*0b57cec5SDimitry Andric    void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred);       // C++20
345*0b57cec5SDimitry Andric
346*0b57cec5SDimitry Andrictemplate <class K, class T, class H, class P, class A, class Predicate>
347*0b57cec5SDimitry Andric    void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred);  // C++20
348*0b57cec5SDimitry Andric
349*0b57cec5SDimitry Andric
350*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
351*0b57cec5SDimitry Andric    bool
352*0b57cec5SDimitry Andric    operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
353*0b57cec5SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
354*0b57cec5SDimitry Andric
355*0b57cec5SDimitry Andrictemplate <class Value, class Hash, class Pred, class Alloc>
356*0b57cec5SDimitry Andric    bool
357*0b57cec5SDimitry Andric    operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
358*0b57cec5SDimitry Andric               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
359*0b57cec5SDimitry Andric}  // std
360*0b57cec5SDimitry Andric
361*0b57cec5SDimitry Andric*/
362*0b57cec5SDimitry Andric
363*0b57cec5SDimitry Andric#include <__config>
364*0b57cec5SDimitry Andric#include <__hash_table>
365*0b57cec5SDimitry Andric#include <__node_handle>
366*0b57cec5SDimitry Andric#include <functional>
367*0b57cec5SDimitry Andric#include <version>
368*0b57cec5SDimitry Andric
369*0b57cec5SDimitry Andric#include <__debug>
370*0b57cec5SDimitry Andric
371*0b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
372*0b57cec5SDimitry Andric#pragma GCC system_header
373*0b57cec5SDimitry Andric#endif
374*0b57cec5SDimitry Andric
375*0b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
376*0b57cec5SDimitry Andric
377*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
378*0b57cec5SDimitry Andricclass unordered_multiset;
379*0b57cec5SDimitry Andric
380*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
381*0b57cec5SDimitry Andric          class _Alloc = allocator<_Value> >
382*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_set
383*0b57cec5SDimitry Andric{
384*0b57cec5SDimitry Andricpublic:
385*0b57cec5SDimitry Andric    // types
386*0b57cec5SDimitry Andric    typedef _Value                                                     key_type;
387*0b57cec5SDimitry Andric    typedef key_type                                                   value_type;
388*0b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type                           hasher;
389*0b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type                           key_equal;
390*0b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type                          allocator_type;
391*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
392*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
393*0b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
394*0b57cec5SDimitry Andric                  "Invalid allocator::value_type");
395*0b57cec5SDimitry Andric
396*0b57cec5SDimitry Andricprivate:
397*0b57cec5SDimitry Andric    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
398*0b57cec5SDimitry Andric
399*0b57cec5SDimitry Andric    __table __table_;
400*0b57cec5SDimitry Andric
401*0b57cec5SDimitry Andricpublic:
402*0b57cec5SDimitry Andric    typedef typename __table::pointer         pointer;
403*0b57cec5SDimitry Andric    typedef typename __table::const_pointer   const_pointer;
404*0b57cec5SDimitry Andric    typedef typename __table::size_type       size_type;
405*0b57cec5SDimitry Andric    typedef typename __table::difference_type difference_type;
406*0b57cec5SDimitry Andric
407*0b57cec5SDimitry Andric    typedef typename __table::const_iterator       iterator;
408*0b57cec5SDimitry Andric    typedef typename __table::const_iterator       const_iterator;
409*0b57cec5SDimitry Andric    typedef typename __table::const_local_iterator local_iterator;
410*0b57cec5SDimitry Andric    typedef typename __table::const_local_iterator const_local_iterator;
411*0b57cec5SDimitry Andric
412*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
413*0b57cec5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
414*0b57cec5SDimitry Andric    typedef __insert_return_type<iterator, node_type> insert_return_type;
415*0b57cec5SDimitry Andric#endif
416*0b57cec5SDimitry Andric
417*0b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
418*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
419*0b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
420*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
421*0b57cec5SDimitry Andric
422*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
423*0b57cec5SDimitry Andric    unordered_set()
424*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
425*0b57cec5SDimitry Andric        {
426*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
427*0b57cec5SDimitry Andric            __get_db()->__insert_c(this);
428*0b57cec5SDimitry Andric#endif
429*0b57cec5SDimitry Andric        }
430*0b57cec5SDimitry Andric    explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
431*0b57cec5SDimitry Andric                           const key_equal& __eql = key_equal());
432*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
433*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
434*0b57cec5SDimitry Andric    unordered_set(size_type __n, const allocator_type& __a)
435*0b57cec5SDimitry Andric        : unordered_set(__n, hasher(), key_equal(), __a) {}
436*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
437*0b57cec5SDimitry Andric    unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
438*0b57cec5SDimitry Andric        : unordered_set(__n, __hf, key_equal(), __a) {}
439*0b57cec5SDimitry Andric#endif
440*0b57cec5SDimitry Andric    unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
441*0b57cec5SDimitry Andric                  const allocator_type& __a);
442*0b57cec5SDimitry Andric    template <class _InputIterator>
443*0b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last);
444*0b57cec5SDimitry Andric    template <class _InputIterator>
445*0b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
446*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
447*0b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
448*0b57cec5SDimitry Andric    template <class _InputIterator>
449*0b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
450*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf, const key_equal& __eql,
451*0b57cec5SDimitry Andric                      const allocator_type& __a);
452*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
453*0b57cec5SDimitry Andric    template <class _InputIterator>
454*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
455*0b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
456*0b57cec5SDimitry Andric                    size_type __n, const allocator_type& __a)
457*0b57cec5SDimitry Andric            : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
458*0b57cec5SDimitry Andric    template <class _InputIterator>
459*0b57cec5SDimitry Andric        unordered_set(_InputIterator __first, _InputIterator __last,
460*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf, const allocator_type& __a)
461*0b57cec5SDimitry Andric            : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
462*0b57cec5SDimitry Andric#endif
463*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
464*0b57cec5SDimitry Andric    explicit unordered_set(const allocator_type& __a);
465*0b57cec5SDimitry Andric    unordered_set(const unordered_set& __u);
466*0b57cec5SDimitry Andric    unordered_set(const unordered_set& __u, const allocator_type& __a);
467*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
468*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
469*0b57cec5SDimitry Andric    unordered_set(unordered_set&& __u)
470*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
471*0b57cec5SDimitry Andric    unordered_set(unordered_set&& __u, const allocator_type& __a);
472*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il);
473*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
474*0b57cec5SDimitry Andric                  const hasher& __hf = hasher(),
475*0b57cec5SDimitry Andric                  const key_equal& __eql = key_equal());
476*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
477*0b57cec5SDimitry Andric                  const hasher& __hf, const key_equal& __eql,
478*0b57cec5SDimitry Andric                  const allocator_type& __a);
479*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
480*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
481*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
482*0b57cec5SDimitry Andric                                                      const allocator_type& __a)
483*0b57cec5SDimitry Andric        : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
484*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
485*0b57cec5SDimitry Andric    unordered_set(initializer_list<value_type> __il, size_type __n,
486*0b57cec5SDimitry Andric                                  const hasher& __hf, const allocator_type& __a)
487*0b57cec5SDimitry Andric        : unordered_set(__il, __n, __hf, key_equal(), __a) {}
488*0b57cec5SDimitry Andric#endif
489*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
490*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
491*0b57cec5SDimitry Andric    ~unordered_set() {
492*0b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
493*0b57cec5SDimitry Andric    }
494*0b57cec5SDimitry Andric
495*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
496*0b57cec5SDimitry Andric    unordered_set& operator=(const unordered_set& __u)
497*0b57cec5SDimitry Andric    {
498*0b57cec5SDimitry Andric        __table_ = __u.__table_;
499*0b57cec5SDimitry Andric        return *this;
500*0b57cec5SDimitry Andric    }
501*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
502*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
503*0b57cec5SDimitry Andric    unordered_set& operator=(unordered_set&& __u)
504*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
505*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
506*0b57cec5SDimitry Andric    unordered_set& operator=(initializer_list<value_type> __il);
507*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
508*0b57cec5SDimitry Andric
509*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
510*0b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
511*0b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
512*0b57cec5SDimitry Andric
513*0b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
514*0b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
515*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
516*0b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
517*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
518*0b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
519*0b57cec5SDimitry Andric
520*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
521*0b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
522*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
523*0b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
524*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
525*0b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
526*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
527*0b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
528*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
529*0b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
530*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
531*0b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
532*0b57cec5SDimitry Andric
533*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
534*0b57cec5SDimitry Andric    template <class... _Args>
535*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
536*0b57cec5SDimitry Andric        pair<iterator, bool> emplace(_Args&&... __args)
537*0b57cec5SDimitry Andric            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
538*0b57cec5SDimitry Andric    template <class... _Args>
539*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
540*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
541*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator __p, _Args&&... __args)
542*0b57cec5SDimitry Andric        {
543*0b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
544*0b57cec5SDimitry Andric                "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
545*0b57cec5SDimitry Andric                " referring to this unordered_set");
546*0b57cec5SDimitry Andric            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
547*0b57cec5SDimitry Andric        }
548*0b57cec5SDimitry Andric#else
549*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator, _Args&&... __args)
550*0b57cec5SDimitry Andric            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
551*0b57cec5SDimitry Andric#endif
552*0b57cec5SDimitry Andric
553*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
554*0b57cec5SDimitry Andric    pair<iterator, bool> insert(value_type&& __x)
555*0b57cec5SDimitry Andric        {return __table_.__insert_unique(_VSTD::move(__x));}
556*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
557*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
558*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
559*0b57cec5SDimitry Andric        {
560*0b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
561*0b57cec5SDimitry Andric                "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
562*0b57cec5SDimitry Andric                " referring to this unordered_set");
563*0b57cec5SDimitry Andric            return insert(_VSTD::move(__x)).first;
564*0b57cec5SDimitry Andric        }
565*0b57cec5SDimitry Andric#else
566*0b57cec5SDimitry Andric    iterator insert(const_iterator, value_type&& __x)
567*0b57cec5SDimitry Andric        {return insert(_VSTD::move(__x)).first;}
568*0b57cec5SDimitry Andric#endif
569*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
570*0b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
571*0b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
572*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
573*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
574*0b57cec5SDimitry Andric    pair<iterator, bool> insert(const value_type& __x)
575*0b57cec5SDimitry Andric        {return __table_.__insert_unique(__x);}
576*0b57cec5SDimitry Andric
577*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
578*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
579*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
580*0b57cec5SDimitry Andric        {
581*0b57cec5SDimitry Andric            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
582*0b57cec5SDimitry Andric                "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
583*0b57cec5SDimitry Andric                " referring to this unordered_set");
584*0b57cec5SDimitry Andric            return insert(__x).first;
585*0b57cec5SDimitry Andric        }
586*0b57cec5SDimitry Andric#else
587*0b57cec5SDimitry Andric    iterator insert(const_iterator, const value_type& __x)
588*0b57cec5SDimitry Andric        {return insert(__x).first;}
589*0b57cec5SDimitry Andric#endif
590*0b57cec5SDimitry Andric    template <class _InputIterator>
591*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
592*0b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
593*0b57cec5SDimitry Andric
594*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
595*0b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p);}
596*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
597*0b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
598*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
599*0b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
600*0b57cec5SDimitry Andric        {return __table_.erase(__first, __last);}
601*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
602*0b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
603*0b57cec5SDimitry Andric
604*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
605*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
606*0b57cec5SDimitry Andric    insert_return_type insert(node_type&& __nh)
607*0b57cec5SDimitry Andric    {
608*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
609*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
610*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<
611*0b57cec5SDimitry Andric            node_type, insert_return_type>(_VSTD::move(__nh));
612*0b57cec5SDimitry Andric    }
613*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
614*0b57cec5SDimitry Andric    iterator insert(const_iterator __h, node_type&& __nh)
615*0b57cec5SDimitry Andric    {
616*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
617*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_set::insert()");
618*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_unique<node_type>(
619*0b57cec5SDimitry Andric            __h, _VSTD::move(__nh));
620*0b57cec5SDimitry Andric    }
621*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
622*0b57cec5SDimitry Andric    node_type extract(key_type const& __key)
623*0b57cec5SDimitry Andric    {
624*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
625*0b57cec5SDimitry Andric    }
626*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
627*0b57cec5SDimitry Andric    node_type extract(const_iterator __it)
628*0b57cec5SDimitry Andric    {
629*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__it);
630*0b57cec5SDimitry Andric    }
631*0b57cec5SDimitry Andric
632*0b57cec5SDimitry Andric    template<class _H2, class _P2>
633*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
634*0b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
635*0b57cec5SDimitry Andric    {
636*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
637*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
638*0b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
639*0b57cec5SDimitry Andric    }
640*0b57cec5SDimitry Andric    template<class _H2, class _P2>
641*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
642*0b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
643*0b57cec5SDimitry Andric    {
644*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
645*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
646*0b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
647*0b57cec5SDimitry Andric    }
648*0b57cec5SDimitry Andric    template<class _H2, class _P2>
649*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
650*0b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
651*0b57cec5SDimitry Andric    {
652*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
653*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
654*0b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
655*0b57cec5SDimitry Andric    }
656*0b57cec5SDimitry Andric    template<class _H2, class _P2>
657*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
658*0b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
659*0b57cec5SDimitry Andric    {
660*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
661*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
662*0b57cec5SDimitry Andric        __table_.__node_handle_merge_unique(__source.__table_);
663*0b57cec5SDimitry Andric    }
664*0b57cec5SDimitry Andric#endif
665*0b57cec5SDimitry Andric
666*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
667*0b57cec5SDimitry Andric    void swap(unordered_set& __u)
668*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
669*0b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
670*0b57cec5SDimitry Andric
671*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
672*0b57cec5SDimitry Andric    hasher hash_function() const {return __table_.hash_function();}
673*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
674*0b57cec5SDimitry Andric    key_equal key_eq() const {return __table_.key_eq();}
675*0b57cec5SDimitry Andric
676*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
677*0b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
678*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
679*0b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
680*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
681*0b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
682*0b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
683*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
684*0b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
685*0b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
686*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
687*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
688*0b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
689*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
690*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
691*0b57cec5SDimitry Andric        {return __table_.__equal_range_unique(__k);}
692*0b57cec5SDimitry Andric
693*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
694*0b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
695*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
696*0b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
697*0b57cec5SDimitry Andric
698*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
699*0b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
700*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
701*0b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
702*0b57cec5SDimitry Andric
703*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
704*0b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
705*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
706*0b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
707*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
708*0b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
709*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
710*0b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
711*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
712*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
713*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
714*0b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
715*0b57cec5SDimitry Andric
716*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
717*0b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
718*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
719*0b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
720*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
721*0b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
722*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
723*0b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
724*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
725*0b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
726*0b57cec5SDimitry Andric
727*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
728*0b57cec5SDimitry Andric
729*0b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
730*0b57cec5SDimitry Andric        {return __table_.__dereferenceable(__i);}
731*0b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
732*0b57cec5SDimitry Andric        {return __table_.__decrementable(__i);}
733*0b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
734*0b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
735*0b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
736*0b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
737*0b57cec5SDimitry Andric
738*0b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
739*0b57cec5SDimitry Andric
740*0b57cec5SDimitry Andric};
741*0b57cec5SDimitry Andric
742*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
743*0b57cec5SDimitry Andrictemplate<class _InputIterator,
744*0b57cec5SDimitry Andric         class _Hash = hash<__iter_value_type<_InputIterator>>,
745*0b57cec5SDimitry Andric         class _Pred = equal_to<__iter_value_type<_InputIterator>>,
746*0b57cec5SDimitry Andric         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
747*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
748*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
749*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
750*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
751*0b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
752*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
753*0b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
754*0b57cec5SDimitry Andric
755*0b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>,
756*0b57cec5SDimitry Andric         class _Pred = equal_to<_Tp>,
757*0b57cec5SDimitry Andric         class _Allocator = allocator<_Tp>,
758*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
759*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
760*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
761*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
762*0b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
763*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
764*0b57cec5SDimitry Andric  -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
765*0b57cec5SDimitry Andric
766*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
767*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
768*0b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator,
769*0b57cec5SDimitry Andric              typename allocator_traits<_Allocator>::size_type, _Allocator)
770*0b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>,
771*0b57cec5SDimitry Andric                   hash<__iter_value_type<_InputIterator>>,
772*0b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
773*0b57cec5SDimitry Andric                   _Allocator>;
774*0b57cec5SDimitry Andric
775*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
776*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
777*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
778*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
779*0b57cec5SDimitry Andricunordered_set(_InputIterator, _InputIterator,
780*0b57cec5SDimitry Andric              typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
781*0b57cec5SDimitry Andric  -> unordered_set<__iter_value_type<_InputIterator>, _Hash,
782*0b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
783*0b57cec5SDimitry Andric                   _Allocator>;
784*0b57cec5SDimitry Andric
785*0b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator,
786*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
787*0b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
788*0b57cec5SDimitry Andric  -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
789*0b57cec5SDimitry Andric
790*0b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator,
791*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
792*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
793*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
794*0b57cec5SDimitry Andricunordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
795*0b57cec5SDimitry Andric  -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
796*0b57cec5SDimitry Andric#endif
797*0b57cec5SDimitry Andric
798*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
799*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
800*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
801*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
802*0b57cec5SDimitry Andric{
803*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
804*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
805*0b57cec5SDimitry Andric#endif
806*0b57cec5SDimitry Andric    __table_.rehash(__n);
807*0b57cec5SDimitry Andric}
808*0b57cec5SDimitry Andric
809*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
810*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
811*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
812*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
813*0b57cec5SDimitry Andric{
814*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
815*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
816*0b57cec5SDimitry Andric#endif
817*0b57cec5SDimitry Andric    __table_.rehash(__n);
818*0b57cec5SDimitry Andric}
819*0b57cec5SDimitry Andric
820*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
821*0b57cec5SDimitry Andrictemplate <class _InputIterator>
822*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
823*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
824*0b57cec5SDimitry Andric{
825*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
826*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
827*0b57cec5SDimitry Andric#endif
828*0b57cec5SDimitry Andric    insert(__first, __last);
829*0b57cec5SDimitry Andric}
830*0b57cec5SDimitry Andric
831*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
832*0b57cec5SDimitry Andrictemplate <class _InputIterator>
833*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
834*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
835*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
836*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
837*0b57cec5SDimitry Andric{
838*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
839*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
840*0b57cec5SDimitry Andric#endif
841*0b57cec5SDimitry Andric    __table_.rehash(__n);
842*0b57cec5SDimitry Andric    insert(__first, __last);
843*0b57cec5SDimitry Andric}
844*0b57cec5SDimitry Andric
845*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
846*0b57cec5SDimitry Andrictemplate <class _InputIterator>
847*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
848*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
849*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
850*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
851*0b57cec5SDimitry Andric{
852*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
853*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
854*0b57cec5SDimitry Andric#endif
855*0b57cec5SDimitry Andric    __table_.rehash(__n);
856*0b57cec5SDimitry Andric    insert(__first, __last);
857*0b57cec5SDimitry Andric}
858*0b57cec5SDimitry Andric
859*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
860*0b57cec5SDimitry Andricinline
861*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
862*0b57cec5SDimitry Andric        const allocator_type& __a)
863*0b57cec5SDimitry Andric    : __table_(__a)
864*0b57cec5SDimitry Andric{
865*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
866*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
867*0b57cec5SDimitry Andric#endif
868*0b57cec5SDimitry Andric}
869*0b57cec5SDimitry Andric
870*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
871*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
872*0b57cec5SDimitry Andric        const unordered_set& __u)
873*0b57cec5SDimitry Andric    : __table_(__u.__table_)
874*0b57cec5SDimitry Andric{
875*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
876*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
877*0b57cec5SDimitry Andric#endif
878*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
879*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
880*0b57cec5SDimitry Andric}
881*0b57cec5SDimitry Andric
882*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
883*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
884*0b57cec5SDimitry Andric        const unordered_set& __u, const allocator_type& __a)
885*0b57cec5SDimitry Andric    : __table_(__u.__table_, __a)
886*0b57cec5SDimitry Andric{
887*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
888*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
889*0b57cec5SDimitry Andric#endif
890*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
891*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
892*0b57cec5SDimitry Andric}
893*0b57cec5SDimitry Andric
894*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
895*0b57cec5SDimitry Andric
896*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
897*0b57cec5SDimitry Andricinline
898*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
899*0b57cec5SDimitry Andric        unordered_set&& __u)
900*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
901*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
902*0b57cec5SDimitry Andric{
903*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
904*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
905*0b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
906*0b57cec5SDimitry Andric#endif
907*0b57cec5SDimitry Andric}
908*0b57cec5SDimitry Andric
909*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
910*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
911*0b57cec5SDimitry Andric        unordered_set&& __u, const allocator_type& __a)
912*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), __a)
913*0b57cec5SDimitry Andric{
914*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
915*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
916*0b57cec5SDimitry Andric#endif
917*0b57cec5SDimitry Andric    if (__a != __u.get_allocator())
918*0b57cec5SDimitry Andric    {
919*0b57cec5SDimitry Andric        iterator __i = __u.begin();
920*0b57cec5SDimitry Andric        while (__u.size() != 0)
921*0b57cec5SDimitry Andric            __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
922*0b57cec5SDimitry Andric    }
923*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
924*0b57cec5SDimitry Andric    else
925*0b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
926*0b57cec5SDimitry Andric#endif
927*0b57cec5SDimitry Andric}
928*0b57cec5SDimitry Andric
929*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
930*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
931*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
932*0b57cec5SDimitry Andric{
933*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
934*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
935*0b57cec5SDimitry Andric#endif
936*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
937*0b57cec5SDimitry Andric}
938*0b57cec5SDimitry Andric
939*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
940*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
941*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
942*0b57cec5SDimitry Andric        const key_equal& __eql)
943*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
944*0b57cec5SDimitry Andric{
945*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
946*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
947*0b57cec5SDimitry Andric#endif
948*0b57cec5SDimitry Andric    __table_.rehash(__n);
949*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
950*0b57cec5SDimitry Andric}
951*0b57cec5SDimitry Andric
952*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
953*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
954*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
955*0b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
956*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
957*0b57cec5SDimitry Andric{
958*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
959*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
960*0b57cec5SDimitry Andric#endif
961*0b57cec5SDimitry Andric    __table_.rehash(__n);
962*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
963*0b57cec5SDimitry Andric}
964*0b57cec5SDimitry Andric
965*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
966*0b57cec5SDimitry Andricinline
967*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>&
968*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
969*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
970*0b57cec5SDimitry Andric{
971*0b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
972*0b57cec5SDimitry Andric    return *this;
973*0b57cec5SDimitry Andric}
974*0b57cec5SDimitry Andric
975*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
976*0b57cec5SDimitry Andricinline
977*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>&
978*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
979*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
980*0b57cec5SDimitry Andric{
981*0b57cec5SDimitry Andric    __table_.__assign_unique(__il.begin(), __il.end());
982*0b57cec5SDimitry Andric    return *this;
983*0b57cec5SDimitry Andric}
984*0b57cec5SDimitry Andric
985*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
986*0b57cec5SDimitry Andric
987*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
988*0b57cec5SDimitry Andrictemplate <class _InputIterator>
989*0b57cec5SDimitry Andricinline
990*0b57cec5SDimitry Andricvoid
991*0b57cec5SDimitry Andricunordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
992*0b57cec5SDimitry Andric                                                    _InputIterator __last)
993*0b57cec5SDimitry Andric{
994*0b57cec5SDimitry Andric    for (; __first != __last; ++__first)
995*0b57cec5SDimitry Andric        __table_.__insert_unique(*__first);
996*0b57cec5SDimitry Andric}
997*0b57cec5SDimitry Andric
998*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
999*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1000*0b57cec5SDimitry Andricvoid
1001*0b57cec5SDimitry Andricswap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1002*0b57cec5SDimitry Andric     unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1003*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1004*0b57cec5SDimitry Andric{
1005*0b57cec5SDimitry Andric    __x.swap(__y);
1006*0b57cec5SDimitry Andric}
1007*0b57cec5SDimitry Andric
1008*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1009*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1010*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1011*0b57cec5SDimitry Andricvoid erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
1012*0b57cec5SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
1013*0b57cec5SDimitry Andric#endif
1014*0b57cec5SDimitry Andric
1015*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1016*0b57cec5SDimitry Andricbool
1017*0b57cec5SDimitry Andricoperator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1018*0b57cec5SDimitry Andric           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1019*0b57cec5SDimitry Andric{
1020*0b57cec5SDimitry Andric    if (__x.size() != __y.size())
1021*0b57cec5SDimitry Andric        return false;
1022*0b57cec5SDimitry Andric    typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
1023*0b57cec5SDimitry Andric                                                                 const_iterator;
1024*0b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
1025*0b57cec5SDimitry Andric            __i != __ex; ++__i)
1026*0b57cec5SDimitry Andric    {
1027*0b57cec5SDimitry Andric        const_iterator __j = __y.find(*__i);
1028*0b57cec5SDimitry Andric        if (__j == __ey || !(*__i == *__j))
1029*0b57cec5SDimitry Andric            return false;
1030*0b57cec5SDimitry Andric    }
1031*0b57cec5SDimitry Andric    return true;
1032*0b57cec5SDimitry Andric}
1033*0b57cec5SDimitry Andric
1034*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1035*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1036*0b57cec5SDimitry Andricbool
1037*0b57cec5SDimitry Andricoperator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1038*0b57cec5SDimitry Andric           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1039*0b57cec5SDimitry Andric{
1040*0b57cec5SDimitry Andric    return !(__x == __y);
1041*0b57cec5SDimitry Andric}
1042*0b57cec5SDimitry Andric
1043*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
1044*0b57cec5SDimitry Andric          class _Alloc = allocator<_Value> >
1045*0b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS unordered_multiset
1046*0b57cec5SDimitry Andric{
1047*0b57cec5SDimitry Andricpublic:
1048*0b57cec5SDimitry Andric    // types
1049*0b57cec5SDimitry Andric    typedef _Value                                                     key_type;
1050*0b57cec5SDimitry Andric    typedef key_type                                                   value_type;
1051*0b57cec5SDimitry Andric    typedef typename __identity<_Hash>::type                           hasher;
1052*0b57cec5SDimitry Andric    typedef typename __identity<_Pred>::type                           key_equal;
1053*0b57cec5SDimitry Andric    typedef typename __identity<_Alloc>::type                          allocator_type;
1054*0b57cec5SDimitry Andric    typedef value_type&                                                reference;
1055*0b57cec5SDimitry Andric    typedef const value_type&                                          const_reference;
1056*0b57cec5SDimitry Andric    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1057*0b57cec5SDimitry Andric                  "Invalid allocator::value_type");
1058*0b57cec5SDimitry Andric
1059*0b57cec5SDimitry Andricprivate:
1060*0b57cec5SDimitry Andric    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
1061*0b57cec5SDimitry Andric
1062*0b57cec5SDimitry Andric    __table __table_;
1063*0b57cec5SDimitry Andric
1064*0b57cec5SDimitry Andricpublic:
1065*0b57cec5SDimitry Andric    typedef typename __table::pointer         pointer;
1066*0b57cec5SDimitry Andric    typedef typename __table::const_pointer   const_pointer;
1067*0b57cec5SDimitry Andric    typedef typename __table::size_type       size_type;
1068*0b57cec5SDimitry Andric    typedef typename __table::difference_type difference_type;
1069*0b57cec5SDimitry Andric
1070*0b57cec5SDimitry Andric    typedef typename __table::const_iterator       iterator;
1071*0b57cec5SDimitry Andric    typedef typename __table::const_iterator       const_iterator;
1072*0b57cec5SDimitry Andric    typedef typename __table::const_local_iterator local_iterator;
1073*0b57cec5SDimitry Andric    typedef typename __table::const_local_iterator const_local_iterator;
1074*0b57cec5SDimitry Andric
1075*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1076*0b57cec5SDimitry Andric    typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
1077*0b57cec5SDimitry Andric#endif
1078*0b57cec5SDimitry Andric
1079*0b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1080*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_set;
1081*0b57cec5SDimitry Andric    template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1082*0b57cec5SDimitry Andric        friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
1083*0b57cec5SDimitry Andric
1084*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1085*0b57cec5SDimitry Andric    unordered_multiset()
1086*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
1087*0b57cec5SDimitry Andric        {
1088*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1089*0b57cec5SDimitry Andric            __get_db()->__insert_c(this);
1090*0b57cec5SDimitry Andric#endif
1091*0b57cec5SDimitry Andric        }
1092*0b57cec5SDimitry Andric    explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
1093*0b57cec5SDimitry Andric                                const key_equal& __eql = key_equal());
1094*0b57cec5SDimitry Andric    unordered_multiset(size_type __n, const hasher& __hf,
1095*0b57cec5SDimitry Andric                       const key_equal& __eql, const allocator_type& __a);
1096*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
1097*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1098*0b57cec5SDimitry Andric    unordered_multiset(size_type __n, const allocator_type& __a)
1099*0b57cec5SDimitry Andric        : unordered_multiset(__n, hasher(), key_equal(), __a) {}
1100*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1101*0b57cec5SDimitry Andric    unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
1102*0b57cec5SDimitry Andric        : unordered_multiset(__n, __hf, key_equal(), __a) {}
1103*0b57cec5SDimitry Andric#endif
1104*0b57cec5SDimitry Andric    template <class _InputIterator>
1105*0b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last);
1106*0b57cec5SDimitry Andric    template <class _InputIterator>
1107*0b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last,
1108*0b57cec5SDimitry Andric                      size_type __n, const hasher& __hf = hasher(),
1109*0b57cec5SDimitry Andric                      const key_equal& __eql = key_equal());
1110*0b57cec5SDimitry Andric    template <class _InputIterator>
1111*0b57cec5SDimitry Andric        unordered_multiset(_InputIterator __first, _InputIterator __last,
1112*0b57cec5SDimitry Andric                      size_type __n , const hasher& __hf,
1113*0b57cec5SDimitry Andric                      const key_equal& __eql, const allocator_type& __a);
1114*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
1115*0b57cec5SDimitry Andric    template <class _InputIterator>
1116*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1117*0b57cec5SDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
1118*0b57cec5SDimitry Andric                       size_type __n, const allocator_type& __a)
1119*0b57cec5SDimitry Andric        : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
1120*0b57cec5SDimitry Andric    template <class _InputIterator>
1121*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1122*0b57cec5SDimitry Andric    unordered_multiset(_InputIterator __first, _InputIterator __last,
1123*0b57cec5SDimitry Andric                       size_type __n, const hasher& __hf, const allocator_type& __a)
1124*0b57cec5SDimitry Andric        : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
1125*0b57cec5SDimitry Andric#endif
1126*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1127*0b57cec5SDimitry Andric    explicit unordered_multiset(const allocator_type& __a);
1128*0b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset& __u);
1129*0b57cec5SDimitry Andric    unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
1130*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1131*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1132*0b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&& __u)
1133*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1134*0b57cec5SDimitry Andric    unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
1135*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il);
1136*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n,
1137*0b57cec5SDimitry Andric                       const hasher& __hf = hasher(),
1138*0b57cec5SDimitry Andric                       const key_equal& __eql = key_equal());
1139*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n,
1140*0b57cec5SDimitry Andric                       const hasher& __hf, const key_equal& __eql,
1141*0b57cec5SDimitry Andric                       const allocator_type& __a);
1142*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
1143*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1144*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1145*0b57cec5SDimitry Andric      : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
1146*0b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY
1147*0b57cec5SDimitry Andric    unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1148*0b57cec5SDimitry Andric      : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
1149*0b57cec5SDimitry Andric#endif
1150*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1151*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1152*0b57cec5SDimitry Andric    ~unordered_multiset() {
1153*0b57cec5SDimitry Andric        static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
1154*0b57cec5SDimitry Andric    }
1155*0b57cec5SDimitry Andric
1156*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1157*0b57cec5SDimitry Andric    unordered_multiset& operator=(const unordered_multiset& __u)
1158*0b57cec5SDimitry Andric    {
1159*0b57cec5SDimitry Andric        __table_ = __u.__table_;
1160*0b57cec5SDimitry Andric        return *this;
1161*0b57cec5SDimitry Andric    }
1162*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1163*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1164*0b57cec5SDimitry Andric    unordered_multiset& operator=(unordered_multiset&& __u)
1165*0b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1166*0b57cec5SDimitry Andric    unordered_multiset& operator=(initializer_list<value_type> __il);
1167*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1168*0b57cec5SDimitry Andric
1169*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1170*0b57cec5SDimitry Andric    allocator_type get_allocator() const _NOEXCEPT
1171*0b57cec5SDimitry Andric        {return allocator_type(__table_.__node_alloc());}
1172*0b57cec5SDimitry Andric
1173*0b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1174*0b57cec5SDimitry Andric    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
1175*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1176*0b57cec5SDimitry Andric    size_type size() const _NOEXCEPT  {return __table_.size();}
1177*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1178*0b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
1179*0b57cec5SDimitry Andric
1180*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1181*0b57cec5SDimitry Andric    iterator       begin() _NOEXCEPT        {return __table_.begin();}
1182*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1183*0b57cec5SDimitry Andric    iterator       end() _NOEXCEPT          {return __table_.end();}
1184*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1185*0b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
1186*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1187*0b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT {return __table_.end();}
1188*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1189*0b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
1190*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1191*0b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
1192*0b57cec5SDimitry Andric
1193*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1194*0b57cec5SDimitry Andric    template <class... _Args>
1195*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1196*0b57cec5SDimitry Andric        iterator emplace(_Args&&... __args)
1197*0b57cec5SDimitry Andric            {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
1198*0b57cec5SDimitry Andric    template <class... _Args>
1199*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1200*0b57cec5SDimitry Andric        iterator emplace_hint(const_iterator __p, _Args&&... __args)
1201*0b57cec5SDimitry Andric            {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
1202*0b57cec5SDimitry Andric
1203*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1204*0b57cec5SDimitry Andric    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
1205*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1206*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, value_type&& __x)
1207*0b57cec5SDimitry Andric        {return __table_.__insert_multi(__p, _VSTD::move(__x));}
1208*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1209*0b57cec5SDimitry Andric    void insert(initializer_list<value_type> __il)
1210*0b57cec5SDimitry Andric        {insert(__il.begin(), __il.end());}
1211*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1212*0b57cec5SDimitry Andric
1213*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1214*0b57cec5SDimitry Andric    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1215*0b57cec5SDimitry Andric
1216*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1217*0b57cec5SDimitry Andric    iterator insert(const_iterator __p, const value_type& __x)
1218*0b57cec5SDimitry Andric        {return __table_.__insert_multi(__p, __x);}
1219*0b57cec5SDimitry Andric
1220*0b57cec5SDimitry Andric    template <class _InputIterator>
1221*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1222*0b57cec5SDimitry Andric        void insert(_InputIterator __first, _InputIterator __last);
1223*0b57cec5SDimitry Andric
1224*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
1225*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1226*0b57cec5SDimitry Andric    iterator insert(node_type&& __nh)
1227*0b57cec5SDimitry Andric    {
1228*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1229*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
1230*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
1231*0b57cec5SDimitry Andric            _VSTD::move(__nh));
1232*0b57cec5SDimitry Andric    }
1233*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1234*0b57cec5SDimitry Andric    iterator insert(const_iterator __hint, node_type&& __nh)
1235*0b57cec5SDimitry Andric    {
1236*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1237*0b57cec5SDimitry Andric            "node_type with incompatible allocator passed to unordered_multiset::insert()");
1238*0b57cec5SDimitry Andric        return __table_.template __node_handle_insert_multi<node_type>(
1239*0b57cec5SDimitry Andric            __hint, _VSTD::move(__nh));
1240*0b57cec5SDimitry Andric    }
1241*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1242*0b57cec5SDimitry Andric    node_type extract(const_iterator __position)
1243*0b57cec5SDimitry Andric    {
1244*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(
1245*0b57cec5SDimitry Andric            __position);
1246*0b57cec5SDimitry Andric    }
1247*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1248*0b57cec5SDimitry Andric    node_type extract(key_type const& __key)
1249*0b57cec5SDimitry Andric    {
1250*0b57cec5SDimitry Andric        return __table_.template __node_handle_extract<node_type>(__key);
1251*0b57cec5SDimitry Andric    }
1252*0b57cec5SDimitry Andric
1253*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1254*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1255*0b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
1256*0b57cec5SDimitry Andric    {
1257*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1258*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1259*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1260*0b57cec5SDimitry Andric    }
1261*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1262*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1263*0b57cec5SDimitry Andric    void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
1264*0b57cec5SDimitry Andric    {
1265*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1266*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1267*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1268*0b57cec5SDimitry Andric    }
1269*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1270*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1271*0b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
1272*0b57cec5SDimitry Andric    {
1273*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1274*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1275*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1276*0b57cec5SDimitry Andric    }
1277*0b57cec5SDimitry Andric    template <class _H2, class _P2>
1278*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1279*0b57cec5SDimitry Andric    void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
1280*0b57cec5SDimitry Andric    {
1281*0b57cec5SDimitry Andric        _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1282*0b57cec5SDimitry Andric                       "merging container with incompatible allocator");
1283*0b57cec5SDimitry Andric        return __table_.__node_handle_merge_multi(__source.__table_);
1284*0b57cec5SDimitry Andric    }
1285*0b57cec5SDimitry Andric#endif
1286*0b57cec5SDimitry Andric
1287*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1288*0b57cec5SDimitry Andric    iterator erase(const_iterator __p) {return __table_.erase(__p);}
1289*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1290*0b57cec5SDimitry Andric    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
1291*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1292*0b57cec5SDimitry Andric    iterator erase(const_iterator __first, const_iterator __last)
1293*0b57cec5SDimitry Andric        {return __table_.erase(__first, __last);}
1294*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1295*0b57cec5SDimitry Andric    void clear() _NOEXCEPT {__table_.clear();}
1296*0b57cec5SDimitry Andric
1297*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1298*0b57cec5SDimitry Andric    void swap(unordered_multiset& __u)
1299*0b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1300*0b57cec5SDimitry Andric        {__table_.swap(__u.__table_);}
1301*0b57cec5SDimitry Andric
1302*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1303*0b57cec5SDimitry Andric    hasher hash_function() const {return __table_.hash_function();}
1304*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1305*0b57cec5SDimitry Andric    key_equal key_eq() const {return __table_.key_eq();}
1306*0b57cec5SDimitry Andric
1307*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1308*0b57cec5SDimitry Andric    iterator       find(const key_type& __k)       {return __table_.find(__k);}
1309*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1310*0b57cec5SDimitry Andric    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
1311*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1312*0b57cec5SDimitry Andric    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
1313*0b57cec5SDimitry Andric    #if _LIBCPP_STD_VER > 17
1314*0b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
1315*0b57cec5SDimitry Andric        bool contains(const key_type& __k) const {return find(__k) != end();}
1316*0b57cec5SDimitry Andric    #endif // _LIBCPP_STD_VER > 17
1317*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1318*0b57cec5SDimitry Andric    pair<iterator, iterator>             equal_range(const key_type& __k)
1319*0b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
1320*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1321*0b57cec5SDimitry Andric    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1322*0b57cec5SDimitry Andric        {return __table_.__equal_range_multi(__k);}
1323*0b57cec5SDimitry Andric
1324*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1325*0b57cec5SDimitry Andric    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
1326*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1327*0b57cec5SDimitry Andric    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
1328*0b57cec5SDimitry Andric
1329*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1330*0b57cec5SDimitry Andric    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
1331*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1332*0b57cec5SDimitry Andric    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1333*0b57cec5SDimitry Andric
1334*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1335*0b57cec5SDimitry Andric    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
1336*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1337*0b57cec5SDimitry Andric    local_iterator       end(size_type __n)          {return __table_.end(__n);}
1338*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1339*0b57cec5SDimitry Andric    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
1340*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1341*0b57cec5SDimitry Andric    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
1342*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1343*0b57cec5SDimitry Andric    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
1344*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1345*0b57cec5SDimitry Andric    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
1346*0b57cec5SDimitry Andric
1347*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1348*0b57cec5SDimitry Andric    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
1349*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1350*0b57cec5SDimitry Andric    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
1351*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1352*0b57cec5SDimitry Andric    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
1353*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1354*0b57cec5SDimitry Andric    void rehash(size_type __n) {__table_.rehash(__n);}
1355*0b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1356*0b57cec5SDimitry Andric    void reserve(size_type __n) {__table_.reserve(__n);}
1357*0b57cec5SDimitry Andric
1358*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1359*0b57cec5SDimitry Andric
1360*0b57cec5SDimitry Andric    bool __dereferenceable(const const_iterator* __i) const
1361*0b57cec5SDimitry Andric        {return __table_.__dereferenceable(__i);}
1362*0b57cec5SDimitry Andric    bool __decrementable(const const_iterator* __i) const
1363*0b57cec5SDimitry Andric        {return __table_.__decrementable(__i);}
1364*0b57cec5SDimitry Andric    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1365*0b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
1366*0b57cec5SDimitry Andric    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1367*0b57cec5SDimitry Andric        {return __table_.__addable(__i, __n);}
1368*0b57cec5SDimitry Andric
1369*0b57cec5SDimitry Andric#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1370*0b57cec5SDimitry Andric
1371*0b57cec5SDimitry Andric};
1372*0b57cec5SDimitry Andric
1373*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1374*0b57cec5SDimitry Andrictemplate<class _InputIterator,
1375*0b57cec5SDimitry Andric         class _Hash = hash<__iter_value_type<_InputIterator>>,
1376*0b57cec5SDimitry Andric         class _Pred = equal_to<__iter_value_type<_InputIterator>>,
1377*0b57cec5SDimitry Andric         class _Allocator = allocator<__iter_value_type<_InputIterator>>,
1378*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1379*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1380*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
1381*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1382*0b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0,
1383*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1384*0b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
1385*0b57cec5SDimitry Andric
1386*0b57cec5SDimitry Andrictemplate<class _Tp, class _Hash = hash<_Tp>,
1387*0b57cec5SDimitry Andric         class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>,
1388*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1389*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1390*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Pred>::value>,
1391*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1392*0b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0,
1393*0b57cec5SDimitry Andric              _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1394*0b57cec5SDimitry Andric  -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
1395*0b57cec5SDimitry Andric
1396*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Allocator,
1397*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1398*0b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator)
1399*0b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>,
1400*0b57cec5SDimitry Andric                   hash<__iter_value_type<_InputIterator>>,
1401*0b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
1402*0b57cec5SDimitry Andric                   _Allocator>;
1403*0b57cec5SDimitry Andric
1404*0b57cec5SDimitry Andrictemplate<class _InputIterator, class _Hash, class _Allocator,
1405*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1406*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1407*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1408*0b57cec5SDimitry Andricunordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type,
1409*0b57cec5SDimitry Andric              _Hash, _Allocator)
1410*0b57cec5SDimitry Andric  -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash,
1411*0b57cec5SDimitry Andric                   equal_to<__iter_value_type<_InputIterator>>,
1412*0b57cec5SDimitry Andric                   _Allocator>;
1413*0b57cec5SDimitry Andric
1414*0b57cec5SDimitry Andrictemplate<class _Tp, class _Allocator,
1415*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1416*0b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
1417*0b57cec5SDimitry Andric  -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1418*0b57cec5SDimitry Andric
1419*0b57cec5SDimitry Andrictemplate<class _Tp, class _Hash, class _Allocator,
1420*0b57cec5SDimitry Andric         class = _EnableIf<!__is_allocator<_Hash>::value>,
1421*0b57cec5SDimitry Andric         class = _EnableIf<!is_integral<_Hash>::value>,
1422*0b57cec5SDimitry Andric         class = _EnableIf<__is_allocator<_Allocator>::value>>
1423*0b57cec5SDimitry Andricunordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1424*0b57cec5SDimitry Andric  -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1425*0b57cec5SDimitry Andric#endif
1426*0b57cec5SDimitry Andric
1427*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1428*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1429*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql)
1430*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1431*0b57cec5SDimitry Andric{
1432*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1433*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1434*0b57cec5SDimitry Andric#endif
1435*0b57cec5SDimitry Andric    __table_.rehash(__n);
1436*0b57cec5SDimitry Andric}
1437*0b57cec5SDimitry Andric
1438*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1439*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1440*0b57cec5SDimitry Andric        size_type __n, const hasher& __hf, const key_equal& __eql,
1441*0b57cec5SDimitry Andric        const allocator_type& __a)
1442*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
1443*0b57cec5SDimitry Andric{
1444*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1445*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1446*0b57cec5SDimitry Andric#endif
1447*0b57cec5SDimitry Andric    __table_.rehash(__n);
1448*0b57cec5SDimitry Andric}
1449*0b57cec5SDimitry Andric
1450*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1451*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1452*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1453*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last)
1454*0b57cec5SDimitry Andric{
1455*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1456*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1457*0b57cec5SDimitry Andric#endif
1458*0b57cec5SDimitry Andric    insert(__first, __last);
1459*0b57cec5SDimitry Andric}
1460*0b57cec5SDimitry Andric
1461*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1462*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1463*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1464*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
1465*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql)
1466*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1467*0b57cec5SDimitry Andric{
1468*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1469*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1470*0b57cec5SDimitry Andric#endif
1471*0b57cec5SDimitry Andric    __table_.rehash(__n);
1472*0b57cec5SDimitry Andric    insert(__first, __last);
1473*0b57cec5SDimitry Andric}
1474*0b57cec5SDimitry Andric
1475*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1476*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1477*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1478*0b57cec5SDimitry Andric        _InputIterator __first, _InputIterator __last, size_type __n,
1479*0b57cec5SDimitry Andric        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1480*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
1481*0b57cec5SDimitry Andric{
1482*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1483*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1484*0b57cec5SDimitry Andric#endif
1485*0b57cec5SDimitry Andric    __table_.rehash(__n);
1486*0b57cec5SDimitry Andric    insert(__first, __last);
1487*0b57cec5SDimitry Andric}
1488*0b57cec5SDimitry Andric
1489*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1490*0b57cec5SDimitry Andricinline
1491*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1492*0b57cec5SDimitry Andric        const allocator_type& __a)
1493*0b57cec5SDimitry Andric    : __table_(__a)
1494*0b57cec5SDimitry Andric{
1495*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1496*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1497*0b57cec5SDimitry Andric#endif
1498*0b57cec5SDimitry Andric}
1499*0b57cec5SDimitry Andric
1500*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1501*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1502*0b57cec5SDimitry Andric        const unordered_multiset& __u)
1503*0b57cec5SDimitry Andric    : __table_(__u.__table_)
1504*0b57cec5SDimitry Andric{
1505*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1506*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1507*0b57cec5SDimitry Andric#endif
1508*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
1509*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
1510*0b57cec5SDimitry Andric}
1511*0b57cec5SDimitry Andric
1512*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1513*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1514*0b57cec5SDimitry Andric        const unordered_multiset& __u, const allocator_type& __a)
1515*0b57cec5SDimitry Andric    : __table_(__u.__table_, __a)
1516*0b57cec5SDimitry Andric{
1517*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1518*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1519*0b57cec5SDimitry Andric#endif
1520*0b57cec5SDimitry Andric    __table_.rehash(__u.bucket_count());
1521*0b57cec5SDimitry Andric    insert(__u.begin(), __u.end());
1522*0b57cec5SDimitry Andric}
1523*0b57cec5SDimitry Andric
1524*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1525*0b57cec5SDimitry Andric
1526*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1527*0b57cec5SDimitry Andricinline
1528*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1529*0b57cec5SDimitry Andric        unordered_multiset&& __u)
1530*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
1531*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_))
1532*0b57cec5SDimitry Andric{
1533*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1534*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1535*0b57cec5SDimitry Andric    __get_db()->swap(this, &__u);
1536*0b57cec5SDimitry Andric#endif
1537*0b57cec5SDimitry Andric}
1538*0b57cec5SDimitry Andric
1539*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1540*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1541*0b57cec5SDimitry Andric        unordered_multiset&& __u, const allocator_type& __a)
1542*0b57cec5SDimitry Andric    : __table_(_VSTD::move(__u.__table_), __a)
1543*0b57cec5SDimitry Andric{
1544*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1545*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1546*0b57cec5SDimitry Andric#endif
1547*0b57cec5SDimitry Andric    if (__a != __u.get_allocator())
1548*0b57cec5SDimitry Andric    {
1549*0b57cec5SDimitry Andric        iterator __i = __u.begin();
1550*0b57cec5SDimitry Andric        while (__u.size() != 0)
1551*0b57cec5SDimitry Andric            __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
1552*0b57cec5SDimitry Andric    }
1553*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1554*0b57cec5SDimitry Andric    else
1555*0b57cec5SDimitry Andric        __get_db()->swap(this, &__u);
1556*0b57cec5SDimitry Andric#endif
1557*0b57cec5SDimitry Andric}
1558*0b57cec5SDimitry Andric
1559*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1560*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1561*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
1562*0b57cec5SDimitry Andric{
1563*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1564*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1565*0b57cec5SDimitry Andric#endif
1566*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1567*0b57cec5SDimitry Andric}
1568*0b57cec5SDimitry Andric
1569*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1570*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1571*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1572*0b57cec5SDimitry Andric        const key_equal& __eql)
1573*0b57cec5SDimitry Andric    : __table_(__hf, __eql)
1574*0b57cec5SDimitry Andric{
1575*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1576*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1577*0b57cec5SDimitry Andric#endif
1578*0b57cec5SDimitry Andric    __table_.rehash(__n);
1579*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1580*0b57cec5SDimitry Andric}
1581*0b57cec5SDimitry Andric
1582*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1583*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1584*0b57cec5SDimitry Andric        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1585*0b57cec5SDimitry Andric        const key_equal& __eql, const allocator_type& __a)
1586*0b57cec5SDimitry Andric    : __table_(__hf, __eql, __a)
1587*0b57cec5SDimitry Andric{
1588*0b57cec5SDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2
1589*0b57cec5SDimitry Andric    __get_db()->__insert_c(this);
1590*0b57cec5SDimitry Andric#endif
1591*0b57cec5SDimitry Andric    __table_.rehash(__n);
1592*0b57cec5SDimitry Andric    insert(__il.begin(), __il.end());
1593*0b57cec5SDimitry Andric}
1594*0b57cec5SDimitry Andric
1595*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1596*0b57cec5SDimitry Andricinline
1597*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1598*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1599*0b57cec5SDimitry Andric        unordered_multiset&& __u)
1600*0b57cec5SDimitry Andric    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
1601*0b57cec5SDimitry Andric{
1602*0b57cec5SDimitry Andric    __table_ = _VSTD::move(__u.__table_);
1603*0b57cec5SDimitry Andric    return *this;
1604*0b57cec5SDimitry Andric}
1605*0b57cec5SDimitry Andric
1606*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1607*0b57cec5SDimitry Andricinline
1608*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1609*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1610*0b57cec5SDimitry Andric        initializer_list<value_type> __il)
1611*0b57cec5SDimitry Andric{
1612*0b57cec5SDimitry Andric    __table_.__assign_multi(__il.begin(), __il.end());
1613*0b57cec5SDimitry Andric    return *this;
1614*0b57cec5SDimitry Andric}
1615*0b57cec5SDimitry Andric
1616*0b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1617*0b57cec5SDimitry Andric
1618*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1619*0b57cec5SDimitry Andrictemplate <class _InputIterator>
1620*0b57cec5SDimitry Andricinline
1621*0b57cec5SDimitry Andricvoid
1622*0b57cec5SDimitry Andricunordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1623*0b57cec5SDimitry Andric                                                         _InputIterator __last)
1624*0b57cec5SDimitry Andric{
1625*0b57cec5SDimitry Andric    for (; __first != __last; ++__first)
1626*0b57cec5SDimitry Andric        __table_.__insert_multi(*__first);
1627*0b57cec5SDimitry Andric}
1628*0b57cec5SDimitry Andric
1629*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1630*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1631*0b57cec5SDimitry Andricvoid
1632*0b57cec5SDimitry Andricswap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1633*0b57cec5SDimitry Andric     unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1634*0b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
1635*0b57cec5SDimitry Andric{
1636*0b57cec5SDimitry Andric    __x.swap(__y);
1637*0b57cec5SDimitry Andric}
1638*0b57cec5SDimitry Andric
1639*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
1640*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1641*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1642*0b57cec5SDimitry Andricvoid erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
1643*0b57cec5SDimitry Andric{ __libcpp_erase_if_container(__c, __pred); }
1644*0b57cec5SDimitry Andric#endif
1645*0b57cec5SDimitry Andric
1646*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1647*0b57cec5SDimitry Andricbool
1648*0b57cec5SDimitry Andricoperator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1649*0b57cec5SDimitry Andric           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1650*0b57cec5SDimitry Andric{
1651*0b57cec5SDimitry Andric    if (__x.size() != __y.size())
1652*0b57cec5SDimitry Andric        return false;
1653*0b57cec5SDimitry Andric    typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
1654*0b57cec5SDimitry Andric                                                                 const_iterator;
1655*0b57cec5SDimitry Andric    typedef pair<const_iterator, const_iterator> _EqRng;
1656*0b57cec5SDimitry Andric    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
1657*0b57cec5SDimitry Andric    {
1658*0b57cec5SDimitry Andric        _EqRng __xeq = __x.equal_range(*__i);
1659*0b57cec5SDimitry Andric        _EqRng __yeq = __y.equal_range(*__i);
1660*0b57cec5SDimitry Andric        if (_VSTD::distance(__xeq.first, __xeq.second) !=
1661*0b57cec5SDimitry Andric            _VSTD::distance(__yeq.first, __yeq.second) ||
1662*0b57cec5SDimitry Andric                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
1663*0b57cec5SDimitry Andric            return false;
1664*0b57cec5SDimitry Andric        __i = __xeq.second;
1665*0b57cec5SDimitry Andric    }
1666*0b57cec5SDimitry Andric    return true;
1667*0b57cec5SDimitry Andric}
1668*0b57cec5SDimitry Andric
1669*0b57cec5SDimitry Andrictemplate <class _Value, class _Hash, class _Pred, class _Alloc>
1670*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1671*0b57cec5SDimitry Andricbool
1672*0b57cec5SDimitry Andricoperator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1673*0b57cec5SDimitry Andric           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1674*0b57cec5SDimitry Andric{
1675*0b57cec5SDimitry Andric    return !(__x == __y);
1676*0b57cec5SDimitry Andric}
1677*0b57cec5SDimitry Andric
1678*0b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
1679*0b57cec5SDimitry Andric
1680*0b57cec5SDimitry Andric#endif  // _LIBCPP_UNORDERED_SET
1681