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