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