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