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