Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- unordered_map -----------------------------===// |
| 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_MAP |
| 12 | #define _LIBCPP_UNORDERED_MAP |
| 13 | |
| 14 | /* |
| 15 | |
| 16 | unordered_map synopsis |
| 17 | |
| 18 | #include <initializer_list> |
| 19 | |
| 20 | namespace std |
| 21 | { |
| 22 | |
| 23 | template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, |
| 24 | class Alloc = allocator<pair<const Key, T>>> |
| 25 | class unordered_map |
| 26 | { |
| 27 | public: |
| 28 | // types |
| 29 | typedef Key key_type; |
| 30 | typedef T mapped_type; |
| 31 | typedef Hash hasher; |
| 32 | typedef Pred key_equal; |
| 33 | typedef Alloc allocator_type; |
| 34 | typedef pair<const key_type, mapped_type> value_type; |
| 35 | typedef value_type& reference; |
| 36 | typedef const value_type& const_reference; |
| 37 | typedef typename allocator_traits<allocator_type>::pointer pointer; |
| 38 | typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; |
| 39 | typedef typename allocator_traits<allocator_type>::size_type size_type; |
| 40 | typedef typename allocator_traits<allocator_type>::difference_type difference_type; |
| 41 | |
| 42 | typedef /unspecified/ iterator; |
| 43 | typedef /unspecified/ const_iterator; |
| 44 | typedef /unspecified/ local_iterator; |
| 45 | typedef /unspecified/ const_local_iterator; |
| 46 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 47 | unordered_map() |
| 48 | noexcept( |
| 49 | is_nothrow_default_constructible<hasher>::value && |
| 50 | is_nothrow_default_constructible<key_equal>::value && |
| 51 | is_nothrow_default_constructible<allocator_type>::value); |
| 52 | explicit unordered_map(size_type n, const hasher& hf = hasher(), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 53 | const key_equal& eql = key_equal(), |
| 54 | const allocator_type& a = allocator_type()); |
| 55 | template <class InputIterator> |
| 56 | unordered_map(InputIterator f, InputIterator l, |
| 57 | size_type n = 0, const hasher& hf = hasher(), |
| 58 | const key_equal& eql = key_equal(), |
| 59 | const allocator_type& a = allocator_type()); |
| 60 | explicit unordered_map(const allocator_type&); |
| 61 | unordered_map(const unordered_map&); |
| 62 | unordered_map(const unordered_map&, const Allocator&); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 63 | unordered_map(unordered_map&&) |
| 64 | noexcept( |
| 65 | is_nothrow_move_constructible<hasher>::value && |
| 66 | is_nothrow_move_constructible<key_equal>::value && |
| 67 | is_nothrow_move_constructible<allocator_type>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 68 | unordered_map(unordered_map&&, const Allocator&); |
| 69 | unordered_map(initializer_list<value_type>, size_type n = 0, |
| 70 | const hasher& hf = hasher(), const key_equal& eql = key_equal(), |
| 71 | const allocator_type& a = allocator_type()); |
Marshall Clow | 6dff618 | 2013-09-12 03:00:31 +0000 | [diff] [blame] | 72 | unordered_map(size_type n, const allocator_type& a) |
| 73 | : unordered_map(n, hasher(), key_equal(), a) {} // C++14 |
| 74 | unordered_map(size_type n, const hasher& hf, const allocator_type& a) |
| 75 | : unordered_map(n, hf, key_equal(), a) {} // C++14 |
| 76 | template <class InputIterator> |
| 77 | unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) |
| 78 | : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 |
| 79 | template <class InputIterator> |
| 80 | unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, |
| 81 | const allocator_type& a) |
| 82 | : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 |
| 83 | unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a) |
| 84 | : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 |
| 85 | unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, |
| 86 | const allocator_type& a) |
| 87 | : unordered_map(il, n, hf, key_equal(), a) {} // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 88 | ~unordered_map(); |
| 89 | unordered_map& operator=(const unordered_map&); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 90 | unordered_map& operator=(unordered_map&&) |
| 91 | noexcept( |
| 92 | allocator_type::propagate_on_container_move_assignment::value && |
| 93 | is_nothrow_move_assignable<allocator_type>::value && |
| 94 | is_nothrow_move_assignable<hasher>::value && |
| 95 | is_nothrow_move_assignable<key_equal>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 96 | unordered_map& operator=(initializer_list<value_type>); |
| 97 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 98 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 99 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 100 | bool empty() const noexcept; |
| 101 | size_type size() const noexcept; |
| 102 | size_type max_size() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 103 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 104 | iterator begin() noexcept; |
| 105 | iterator end() noexcept; |
| 106 | const_iterator begin() const noexcept; |
| 107 | const_iterator end() const noexcept; |
| 108 | const_iterator cbegin() const noexcept; |
| 109 | const_iterator cend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | |
| 111 | template <class... Args> |
| 112 | pair<iterator, bool> emplace(Args&&... args); |
| 113 | template <class... Args> |
| 114 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 115 | pair<iterator, bool> insert(const value_type& obj); |
| 116 | template <class P> |
| 117 | pair<iterator, bool> insert(P&& obj); |
| 118 | iterator insert(const_iterator hint, const value_type& obj); |
| 119 | template <class P> |
| 120 | iterator insert(const_iterator hint, P&& obj); |
| 121 | template <class InputIterator> |
| 122 | void insert(InputIterator first, InputIterator last); |
| 123 | void insert(initializer_list<value_type>); |
| 124 | |
Marshall Clow | 0ce05a9 | 2015-07-07 05:45:35 +0000 | [diff] [blame] | 125 | template <class... Args> |
| 126 | pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 |
| 127 | template <class... Args> |
| 128 | pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 |
| 129 | template <class... Args> |
| 130 | iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 |
| 131 | template <class... Args> |
| 132 | iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 |
| 133 | template <class M> |
| 134 | pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 |
| 135 | template <class M> |
| 136 | pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 |
| 137 | template <class M> |
| 138 | iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 |
| 139 | template <class M> |
| 140 | iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 |
| 141 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 142 | iterator erase(const_iterator position); |
Marshall Clow | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 143 | iterator erase(iterator position); // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | size_type erase(const key_type& k); |
| 145 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 146 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 148 | void swap(unordered_map&) |
| 149 | noexcept( |
| 150 | (!allocator_type::propagate_on_container_swap::value || |
| 151 | __is_nothrow_swappable<allocator_type>::value) && |
| 152 | __is_nothrow_swappable<hasher>::value && |
| 153 | __is_nothrow_swappable<key_equal>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 154 | |
| 155 | hasher hash_function() const; |
| 156 | key_equal key_eq() const; |
| 157 | |
| 158 | iterator find(const key_type& k); |
| 159 | const_iterator find(const key_type& k) const; |
| 160 | size_type count(const key_type& k) const; |
| 161 | pair<iterator, iterator> equal_range(const key_type& k); |
| 162 | pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 163 | |
| 164 | mapped_type& operator[](const key_type& k); |
| 165 | mapped_type& operator[](key_type&& k); |
| 166 | |
| 167 | mapped_type& at(const key_type& k); |
| 168 | const mapped_type& at(const key_type& k) const; |
| 169 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 170 | size_type bucket_count() const noexcept; |
| 171 | size_type max_bucket_count() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 172 | |
| 173 | size_type bucket_size(size_type n) const; |
| 174 | size_type bucket(const key_type& k) const; |
| 175 | |
| 176 | local_iterator begin(size_type n); |
| 177 | local_iterator end(size_type n); |
| 178 | const_local_iterator begin(size_type n) const; |
| 179 | const_local_iterator end(size_type n) const; |
| 180 | const_local_iterator cbegin(size_type n) const; |
| 181 | const_local_iterator cend(size_type n) const; |
| 182 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 183 | float load_factor() const noexcept; |
| 184 | float max_load_factor() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 185 | void max_load_factor(float z); |
| 186 | void rehash(size_type n); |
| 187 | void reserve(size_type n); |
| 188 | }; |
| 189 | |
| 190 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 191 | void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 192 | unordered_map<Key, T, Hash, Pred, Alloc>& y) |
| 193 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 194 | |
| 195 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 196 | bool |
| 197 | operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x, |
| 198 | const unordered_map<Key, T, Hash, Pred, Alloc>& y); |
| 199 | |
| 200 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 201 | bool |
| 202 | operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x, |
| 203 | const unordered_map<Key, T, Hash, Pred, Alloc>& y); |
| 204 | |
| 205 | template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, |
| 206 | class Alloc = allocator<pair<const Key, T>>> |
| 207 | class unordered_multimap |
| 208 | { |
| 209 | public: |
| 210 | // types |
| 211 | typedef Key key_type; |
| 212 | typedef T mapped_type; |
| 213 | typedef Hash hasher; |
| 214 | typedef Pred key_equal; |
| 215 | typedef Alloc allocator_type; |
| 216 | typedef pair<const key_type, mapped_type> value_type; |
| 217 | typedef value_type& reference; |
| 218 | typedef const value_type& const_reference; |
| 219 | typedef typename allocator_traits<allocator_type>::pointer pointer; |
| 220 | typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; |
| 221 | typedef typename allocator_traits<allocator_type>::size_type size_type; |
| 222 | typedef typename allocator_traits<allocator_type>::difference_type difference_type; |
| 223 | |
| 224 | typedef /unspecified/ iterator; |
| 225 | typedef /unspecified/ const_iterator; |
| 226 | typedef /unspecified/ local_iterator; |
| 227 | typedef /unspecified/ const_local_iterator; |
| 228 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 229 | unordered_multimap() |
| 230 | noexcept( |
| 231 | is_nothrow_default_constructible<hasher>::value && |
| 232 | is_nothrow_default_constructible<key_equal>::value && |
| 233 | is_nothrow_default_constructible<allocator_type>::value); |
| 234 | explicit unordered_multimap(size_type n, const hasher& hf = hasher(), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 235 | const key_equal& eql = key_equal(), |
| 236 | const allocator_type& a = allocator_type()); |
| 237 | template <class InputIterator> |
| 238 | unordered_multimap(InputIterator f, InputIterator l, |
| 239 | size_type n = 0, const hasher& hf = hasher(), |
| 240 | const key_equal& eql = key_equal(), |
| 241 | const allocator_type& a = allocator_type()); |
| 242 | explicit unordered_multimap(const allocator_type&); |
| 243 | unordered_multimap(const unordered_multimap&); |
| 244 | unordered_multimap(const unordered_multimap&, const Allocator&); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 245 | unordered_multimap(unordered_multimap&&) |
| 246 | noexcept( |
| 247 | is_nothrow_move_constructible<hasher>::value && |
| 248 | is_nothrow_move_constructible<key_equal>::value && |
| 249 | is_nothrow_move_constructible<allocator_type>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 250 | unordered_multimap(unordered_multimap&&, const Allocator&); |
| 251 | unordered_multimap(initializer_list<value_type>, size_type n = 0, |
| 252 | const hasher& hf = hasher(), const key_equal& eql = key_equal(), |
| 253 | const allocator_type& a = allocator_type()); |
Marshall Clow | 6dff618 | 2013-09-12 03:00:31 +0000 | [diff] [blame] | 254 | unordered_multimap(size_type n, const allocator_type& a) |
| 255 | : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 |
| 256 | unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) |
| 257 | : unordered_multimap(n, hf, key_equal(), a) {} // C++14 |
| 258 | template <class InputIterator> |
| 259 | unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) |
| 260 | : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 |
| 261 | template <class InputIterator> |
| 262 | unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, |
| 263 | const allocator_type& a) |
| 264 | : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 |
| 265 | unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a) |
| 266 | : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 |
| 267 | unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, |
| 268 | const allocator_type& a) |
| 269 | : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 270 | ~unordered_multimap(); |
| 271 | unordered_multimap& operator=(const unordered_multimap&); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 272 | unordered_multimap& operator=(unordered_multimap&&) |
| 273 | noexcept( |
| 274 | allocator_type::propagate_on_container_move_assignment::value && |
| 275 | is_nothrow_move_assignable<allocator_type>::value && |
| 276 | is_nothrow_move_assignable<hasher>::value && |
| 277 | is_nothrow_move_assignable<key_equal>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 278 | unordered_multimap& operator=(initializer_list<value_type>); |
| 279 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 280 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 281 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 282 | bool empty() const noexcept; |
| 283 | size_type size() const noexcept; |
| 284 | size_type max_size() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 285 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 286 | iterator begin() noexcept; |
| 287 | iterator end() noexcept; |
| 288 | const_iterator begin() const noexcept; |
| 289 | const_iterator end() const noexcept; |
| 290 | const_iterator cbegin() const noexcept; |
| 291 | const_iterator cend() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 292 | |
| 293 | template <class... Args> |
| 294 | iterator emplace(Args&&... args); |
| 295 | template <class... Args> |
| 296 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 297 | iterator insert(const value_type& obj); |
| 298 | template <class P> |
| 299 | iterator insert(P&& obj); |
| 300 | iterator insert(const_iterator hint, const value_type& obj); |
| 301 | template <class P> |
| 302 | iterator insert(const_iterator hint, P&& obj); |
| 303 | template <class InputIterator> |
| 304 | void insert(InputIterator first, InputIterator last); |
| 305 | void insert(initializer_list<value_type>); |
| 306 | |
| 307 | iterator erase(const_iterator position); |
Marshall Clow | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 308 | iterator erase(iterator position); // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 309 | size_type erase(const key_type& k); |
| 310 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 311 | void clear() noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 312 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 313 | void swap(unordered_multimap&) |
| 314 | noexcept( |
| 315 | (!allocator_type::propagate_on_container_swap::value || |
| 316 | __is_nothrow_swappable<allocator_type>::value) && |
| 317 | __is_nothrow_swappable<hasher>::value && |
| 318 | __is_nothrow_swappable<key_equal>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 319 | |
| 320 | hasher hash_function() const; |
| 321 | key_equal key_eq() const; |
| 322 | |
| 323 | iterator find(const key_type& k); |
| 324 | const_iterator find(const key_type& k) const; |
| 325 | size_type count(const key_type& k) const; |
| 326 | pair<iterator, iterator> equal_range(const key_type& k); |
| 327 | pair<const_iterator, const_iterator> equal_range(const key_type& k) const; |
| 328 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 329 | size_type bucket_count() const noexcept; |
| 330 | size_type max_bucket_count() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 331 | |
| 332 | size_type bucket_size(size_type n) const; |
| 333 | size_type bucket(const key_type& k) const; |
| 334 | |
| 335 | local_iterator begin(size_type n); |
| 336 | local_iterator end(size_type n); |
| 337 | const_local_iterator begin(size_type n) const; |
| 338 | const_local_iterator end(size_type n) const; |
| 339 | const_local_iterator cbegin(size_type n) const; |
| 340 | const_local_iterator cend(size_type n) const; |
| 341 | |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 342 | float load_factor() const noexcept; |
| 343 | float max_load_factor() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 344 | void max_load_factor(float z); |
| 345 | void rehash(size_type n); |
| 346 | void reserve(size_type n); |
| 347 | }; |
| 348 | |
| 349 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 350 | void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 351 | unordered_multimap<Key, T, Hash, Pred, Alloc>& y) |
| 352 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 353 | |
| 354 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 355 | bool |
| 356 | operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, |
| 357 | const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); |
| 358 | |
| 359 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 360 | bool |
| 361 | operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, |
| 362 | const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); |
| 363 | |
| 364 | } // std |
| 365 | |
| 366 | */ |
| 367 | |
| 368 | #include <__config> |
| 369 | #include <__hash_table> |
| 370 | #include <functional> |
| 371 | #include <stdexcept> |
| 372 | |
Eric Fiselier | b953610 | 2014-08-10 23:53:08 +0000 | [diff] [blame] | 373 | #include <__debug> |
| 374 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 375 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 376 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 377 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 378 | |
| 379 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 380 | |
Eric Fiselier | 3a0e430 | 2015-06-13 07:08:02 +0000 | [diff] [blame] | 381 | template <class _Key, class _Cp, class _Hash, |
| 382 | bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value |
Howard Hinnant | d4cf215 | 2011-12-11 20:31:33 +0000 | [diff] [blame] | 383 | > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | class __unordered_map_hasher |
| 385 | : private _Hash |
| 386 | { |
| 387 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 388 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 389 | __unordered_map_hasher() |
| 390 | _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) |
| 391 | : _Hash() {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 392 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 393 | __unordered_map_hasher(const _Hash& __h) |
| 394 | _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) |
| 395 | : _Hash(__h) {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 396 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 397 | const _Hash& hash_function() const _NOEXCEPT {return *this;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 398 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 399 | size_t operator()(const _Cp& __x) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 400 | {return static_cast<const _Hash&>(*this)(__x.__cc.first);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 401 | _LIBCPP_INLINE_VISIBILITY |
| 402 | size_t operator()(const _Key& __x) const |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 403 | {return static_cast<const _Hash&>(*this)(__x);} |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 404 | void swap(__unordered_map_hasher&__y) |
| 405 | _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) |
| 406 | { |
| 407 | using _VSTD::swap; |
| 408 | swap(static_cast<const _Hash&>(*this), static_cast<const _Hash&>(__y)); |
| 409 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 410 | }; |
| 411 | |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 412 | template <class _Key, class _Cp, class _Hash> |
| 413 | class __unordered_map_hasher<_Key, _Cp, _Hash, false> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 414 | { |
| 415 | _Hash __hash_; |
| 416 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 417 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 418 | __unordered_map_hasher() |
| 419 | _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) |
| 420 | : __hash_() {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 421 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 422 | __unordered_map_hasher(const _Hash& __h) |
| 423 | _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value) |
| 424 | : __hash_(__h) {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 425 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 426 | const _Hash& hash_function() const _NOEXCEPT {return __hash_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 427 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 428 | size_t operator()(const _Cp& __x) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 429 | {return __hash_(__x.__cc.first);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 430 | _LIBCPP_INLINE_VISIBILITY |
| 431 | size_t operator()(const _Key& __x) const |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 432 | {return __hash_(__x);} |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 433 | void swap(__unordered_map_hasher&__y) |
| 434 | _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) |
| 435 | { |
| 436 | using _VSTD::swap; |
| 437 | swap(__hash_, __y.__hash_); |
| 438 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 439 | }; |
| 440 | |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 441 | template <class _Key, class _Cp, class _Hash, bool __b> |
| 442 | inline _LIBCPP_INLINE_VISIBILITY |
| 443 | void |
| 444 | swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x, |
| 445 | __unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y) |
| 446 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 447 | { |
| 448 | __x.swap(__y); |
| 449 | } |
| 450 | |
Eric Fiselier | 3a0e430 | 2015-06-13 07:08:02 +0000 | [diff] [blame] | 451 | template <class _Key, class _Cp, class _Pred, |
| 452 | bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value |
Howard Hinnant | d4cf215 | 2011-12-11 20:31:33 +0000 | [diff] [blame] | 453 | > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 454 | class __unordered_map_equal |
| 455 | : private _Pred |
| 456 | { |
| 457 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 458 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 459 | __unordered_map_equal() |
| 460 | _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) |
| 461 | : _Pred() {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 462 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 463 | __unordered_map_equal(const _Pred& __p) |
| 464 | _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) |
| 465 | : _Pred(__p) {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 466 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 467 | const _Pred& key_eq() const _NOEXCEPT {return *this;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 468 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 469 | bool operator()(const _Cp& __x, const _Cp& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 470 | {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 471 | _LIBCPP_INLINE_VISIBILITY |
| 472 | bool operator()(const _Cp& __x, const _Key& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 473 | {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 474 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 475 | bool operator()(const _Key& __x, const _Cp& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 476 | {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);} |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 477 | void swap(__unordered_map_equal&__y) |
| 478 | _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) |
| 479 | { |
| 480 | using _VSTD::swap; |
| 481 | swap(static_cast<const _Pred&>(*this), static_cast<const _Pred&>(__y)); |
| 482 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 483 | }; |
| 484 | |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 485 | template <class _Key, class _Cp, class _Pred> |
| 486 | class __unordered_map_equal<_Key, _Cp, _Pred, false> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | { |
| 488 | _Pred __pred_; |
| 489 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 490 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 491 | __unordered_map_equal() |
| 492 | _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) |
| 493 | : __pred_() {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 494 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 495 | __unordered_map_equal(const _Pred& __p) |
| 496 | _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value) |
| 497 | : __pred_(__p) {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 498 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 499 | const _Pred& key_eq() const _NOEXCEPT {return __pred_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 500 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 501 | bool operator()(const _Cp& __x, const _Cp& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 502 | {return __pred_(__x.__cc.first, __y.__cc.first);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 503 | _LIBCPP_INLINE_VISIBILITY |
| 504 | bool operator()(const _Cp& __x, const _Key& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 505 | {return __pred_(__x.__cc.first, __y);} |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 506 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f8880d0 | 2011-12-12 17:26:24 +0000 | [diff] [blame] | 507 | bool operator()(const _Key& __x, const _Cp& __y) const |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 508 | {return __pred_(__x, __y.__cc.first);} |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 509 | void swap(__unordered_map_equal&__y) |
| 510 | _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) |
| 511 | { |
| 512 | using _VSTD::swap; |
| 513 | swap(__pred_, __y.__pred_); |
| 514 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 515 | }; |
| 516 | |
Marshall Clow | 7d914d1 | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 517 | template <class _Key, class _Cp, class _Pred, bool __b> |
| 518 | inline _LIBCPP_INLINE_VISIBILITY |
| 519 | void |
| 520 | swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x, |
| 521 | __unordered_map_equal<_Key, _Cp, _Pred, __b>& __y) |
| 522 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 523 | { |
| 524 | __x.swap(__y); |
| 525 | } |
| 526 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 527 | template <class _Alloc> |
| 528 | class __hash_map_node_destructor |
| 529 | { |
| 530 | typedef _Alloc allocator_type; |
| 531 | typedef allocator_traits<allocator_type> __alloc_traits; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 532 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 533 | public: |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 534 | |
| 535 | typedef typename __alloc_traits::pointer pointer; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 536 | private: |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 537 | |
| 538 | allocator_type& __na_; |
| 539 | |
| 540 | __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); |
| 541 | |
| 542 | public: |
| 543 | bool __first_constructed; |
| 544 | bool __second_constructed; |
| 545 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 546 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 547 | explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 548 | : __na_(__na), |
| 549 | __first_constructed(false), |
| 550 | __second_constructed(false) |
| 551 | {} |
| 552 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 553 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 554 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 555 | __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 556 | _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | : __na_(__x.__na_), |
| 558 | __first_constructed(__x.__value_constructed), |
| 559 | __second_constructed(__x.__value_constructed) |
| 560 | { |
| 561 | __x.__value_constructed = false; |
| 562 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 563 | #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 564 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 565 | __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) |
| 566 | : __na_(__x.__na_), |
| 567 | __first_constructed(__x.__value_constructed), |
| 568 | __second_constructed(__x.__value_constructed) |
| 569 | { |
| 570 | const_cast<bool&>(__x.__value_constructed) = false; |
| 571 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 572 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 573 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 574 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 575 | void operator()(pointer __p) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 576 | { |
| 577 | if (__second_constructed) |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 578 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 579 | if (__first_constructed) |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 580 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 581 | if (__p) |
| 582 | __alloc_traits::deallocate(__na_, __p, 1); |
| 583 | } |
| 584 | }; |
| 585 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 586 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 587 | template <class _Key, class _Tp> |
| 588 | union __hash_value_type |
| 589 | { |
| 590 | typedef _Key key_type; |
| 591 | typedef _Tp mapped_type; |
| 592 | typedef pair<const key_type, mapped_type> value_type; |
| 593 | typedef pair<key_type, mapped_type> __nc_value_type; |
| 594 | |
| 595 | value_type __cc; |
| 596 | __nc_value_type __nc; |
| 597 | |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 598 | _LIBCPP_INLINE_VISIBILITY |
| 599 | __hash_value_type& operator=(const __hash_value_type& __v) |
| 600 | {__nc = __v.__cc; return *this;} |
| 601 | |
| 602 | _LIBCPP_INLINE_VISIBILITY |
| 603 | __hash_value_type& operator=(__hash_value_type&& __v) |
Marshall Clow | cd13782 | 2015-05-06 12:11:22 +0000 | [diff] [blame] | 604 | {__nc = _VSTD::move(__v.__nc); return *this;} |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 605 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 606 | template <class _ValueTp, |
| 607 | class = typename enable_if< |
| 608 | __is_same_uncvref<_ValueTp, value_type>::value |
| 609 | >::type |
| 610 | > |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 611 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 612 | __hash_value_type& operator=(_ValueTp&& __v) { |
| 613 | __nc = _VSTD::forward<_ValueTp>(__v); return *this; |
| 614 | } |
| 615 | |
| 616 | private: |
| 617 | __hash_value_type(const __hash_value_type& __v) = delete; |
| 618 | __hash_value_type(__hash_value_type&& __v) = delete; |
| 619 | template <class ..._Args> |
| 620 | explicit __hash_value_type(_Args&& ...__args) = delete; |
| 621 | |
| 622 | ~__hash_value_type() = delete; |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 623 | }; |
| 624 | |
| 625 | #else |
| 626 | |
| 627 | template <class _Key, class _Tp> |
| 628 | struct __hash_value_type |
| 629 | { |
| 630 | typedef _Key key_type; |
| 631 | typedef _Tp mapped_type; |
| 632 | typedef pair<const key_type, mapped_type> value_type; |
| 633 | |
| 634 | value_type __cc; |
| 635 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 636 | private: |
| 637 | ~__hash_value_type(); |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 638 | }; |
| 639 | |
| 640 | #endif |
| 641 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 642 | template <class _HashIterator> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 643 | class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 644 | { |
| 645 | _HashIterator __i_; |
| 646 | |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 647 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; |
| 648 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 649 | public: |
| 650 | typedef forward_iterator_tag iterator_category; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 651 | typedef typename _NodeTypes::__map_value_type value_type; |
| 652 | typedef typename _NodeTypes::difference_type difference_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | typedef value_type& reference; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 654 | typedef typename _NodeTypes::__map_value_type_pointer pointer; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 655 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 656 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 657 | __hash_map_iterator() _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 658 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 659 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 660 | __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 661 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 662 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 663 | reference operator*() const {return __i_->__cc;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 664 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 665 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 666 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 667 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 668 | __hash_map_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 669 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 670 | __hash_map_iterator operator++(int) |
| 671 | { |
| 672 | __hash_map_iterator __t(*this); |
| 673 | ++(*this); |
| 674 | return __t; |
| 675 | } |
| 676 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 677 | friend _LIBCPP_INLINE_VISIBILITY |
| 678 | bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 679 | {return __x.__i_ == __y.__i_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 680 | friend _LIBCPP_INLINE_VISIBILITY |
| 681 | bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 682 | {return __x.__i_ != __y.__i_;} |
| 683 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 684 | template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; |
| 685 | template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; |
| 686 | template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; |
| 687 | template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; |
| 688 | template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | }; |
| 690 | |
| 691 | template <class _HashIterator> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 692 | class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 693 | { |
| 694 | _HashIterator __i_; |
| 695 | |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 696 | typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes; |
| 697 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 698 | public: |
| 699 | typedef forward_iterator_tag iterator_category; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 700 | typedef typename _NodeTypes::__map_value_type value_type; |
| 701 | typedef typename _NodeTypes::difference_type difference_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | typedef const value_type& reference; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 703 | typedef typename _NodeTypes::__const_map_value_type_pointer pointer; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 704 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 705 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 706 | __hash_map_const_iterator() _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 707 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 708 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 709 | __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 710 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 711 | __hash_map_const_iterator( |
| 712 | __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 713 | _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 714 | : __i_(__i.__i_) {} |
| 715 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 716 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 717 | reference operator*() const {return __i_->__cc;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 718 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 719 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 720 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 721 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 722 | __hash_map_const_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 723 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 724 | __hash_map_const_iterator operator++(int) |
| 725 | { |
| 726 | __hash_map_const_iterator __t(*this); |
| 727 | ++(*this); |
| 728 | return __t; |
| 729 | } |
| 730 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 731 | friend _LIBCPP_INLINE_VISIBILITY |
| 732 | bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 733 | {return __x.__i_ == __y.__i_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 734 | friend _LIBCPP_INLINE_VISIBILITY |
| 735 | bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 736 | {return __x.__i_ != __y.__i_;} |
| 737 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 738 | template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; |
| 739 | template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; |
| 740 | template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; |
| 741 | template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 742 | }; |
| 743 | |
| 744 | template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, |
| 745 | class _Alloc = allocator<pair<const _Key, _Tp> > > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 746 | class _LIBCPP_TYPE_VIS_ONLY unordered_map |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 747 | { |
| 748 | public: |
| 749 | // types |
| 750 | typedef _Key key_type; |
| 751 | typedef _Tp mapped_type; |
| 752 | typedef _Hash hasher; |
| 753 | typedef _Pred key_equal; |
| 754 | typedef _Alloc allocator_type; |
| 755 | typedef pair<const key_type, mapped_type> value_type; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 756 | typedef pair<key_type, mapped_type> __nc_value_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 757 | typedef value_type& reference; |
| 758 | typedef const value_type& const_reference; |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 759 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), |
| 760 | "Invalid allocator::value_type"); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 761 | |
| 762 | private: |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 763 | typedef __hash_value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 764 | typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; |
| 765 | typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; |
Marshall Clow | 66302c6 | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 766 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 767 | __value_type>::type __allocator_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 768 | |
| 769 | typedef __hash_table<__value_type, __hasher, |
| 770 | __key_equal, __allocator_type> __table; |
| 771 | |
| 772 | __table __table_; |
| 773 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 774 | typedef typename __table::_NodeTypes _NodeTypes; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 775 | typedef typename __table::__node_pointer __node_pointer; |
| 776 | typedef typename __table::__node_const_pointer __node_const_pointer; |
| 777 | typedef typename __table::__node_traits __node_traits; |
| 778 | typedef typename __table::__node_allocator __node_allocator; |
| 779 | typedef typename __table::__node __node; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 780 | typedef __hash_map_node_destructor<__node_allocator> _Dp; |
| 781 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 782 | typedef allocator_traits<allocator_type> __alloc_traits; |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 783 | |
| 784 | static_assert((is_same<typename __table::__container_value_type, value_type>::value), ""); |
| 785 | static_assert((is_same<typename __table::__node_value_type, __value_type>::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 786 | public: |
| 787 | typedef typename __alloc_traits::pointer pointer; |
| 788 | typedef typename __alloc_traits::const_pointer const_pointer; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 789 | typedef typename __table::size_type size_type; |
| 790 | typedef typename __table::difference_type difference_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 791 | |
| 792 | typedef __hash_map_iterator<typename __table::iterator> iterator; |
| 793 | typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; |
| 794 | typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; |
| 795 | typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; |
| 796 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 797 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 798 | unordered_map() |
| 799 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 800 | { |
| 801 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 802 | __get_db()->__insert_c(this); |
| 803 | #endif |
| 804 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 805 | explicit unordered_map(size_type __n, const hasher& __hf = hasher(), |
| 806 | const key_equal& __eql = key_equal()); |
| 807 | unordered_map(size_type __n, const hasher& __hf, |
| 808 | const key_equal& __eql, |
| 809 | const allocator_type& __a); |
| 810 | template <class _InputIterator> |
| 811 | unordered_map(_InputIterator __first, _InputIterator __last); |
| 812 | template <class _InputIterator> |
| 813 | unordered_map(_InputIterator __first, _InputIterator __last, |
| 814 | size_type __n, const hasher& __hf = hasher(), |
| 815 | const key_equal& __eql = key_equal()); |
| 816 | template <class _InputIterator> |
| 817 | unordered_map(_InputIterator __first, _InputIterator __last, |
| 818 | size_type __n, const hasher& __hf, |
| 819 | const key_equal& __eql, |
| 820 | const allocator_type& __a); |
| 821 | explicit unordered_map(const allocator_type& __a); |
| 822 | unordered_map(const unordered_map& __u); |
| 823 | unordered_map(const unordered_map& __u, const allocator_type& __a); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 824 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 825 | unordered_map(unordered_map&& __u) |
| 826 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 827 | unordered_map(unordered_map&& __u, const allocator_type& __a); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 828 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 829 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 830 | unordered_map(initializer_list<value_type> __il); |
| 831 | unordered_map(initializer_list<value_type> __il, size_type __n, |
| 832 | const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); |
| 833 | unordered_map(initializer_list<value_type> __il, size_type __n, |
| 834 | const hasher& __hf, const key_equal& __eql, |
| 835 | const allocator_type& __a); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 836 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Marshall Clow | 6dff618 | 2013-09-12 03:00:31 +0000 | [diff] [blame] | 837 | #if _LIBCPP_STD_VER > 11 |
| 838 | _LIBCPP_INLINE_VISIBILITY |
| 839 | unordered_map(size_type __n, const allocator_type& __a) |
| 840 | : unordered_map(__n, hasher(), key_equal(), __a) {} |
| 841 | _LIBCPP_INLINE_VISIBILITY |
| 842 | unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) |
| 843 | : unordered_map(__n, __hf, key_equal(), __a) {} |
| 844 | template <class _InputIterator> |
| 845 | _LIBCPP_INLINE_VISIBILITY |
| 846 | unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) |
| 847 | : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {} |
| 848 | template <class _InputIterator> |
| 849 | _LIBCPP_INLINE_VISIBILITY |
| 850 | unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, |
| 851 | const allocator_type& __a) |
| 852 | : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} |
| 853 | _LIBCPP_INLINE_VISIBILITY |
| 854 | unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 855 | : unordered_map(__il, __n, hasher(), key_equal(), __a) {} |
| 856 | _LIBCPP_INLINE_VISIBILITY |
| 857 | unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 858 | const allocator_type& __a) |
| 859 | : unordered_map(__il, __n, __hf, key_equal(), __a) {} |
| 860 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 861 | // ~unordered_map() = default; |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 862 | _LIBCPP_INLINE_VISIBILITY |
| 863 | unordered_map& operator=(const unordered_map& __u) |
| 864 | { |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 865 | #if __cplusplus >= 201103L |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 866 | __table_ = __u.__table_; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 867 | #else |
Marshall Clow | ebfc50e | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 868 | if (this != &__u) { |
| 869 | __table_.clear(); |
| 870 | __table_.hash_function() = __u.__table_.hash_function(); |
| 871 | __table_.key_eq() = __u.__table_.key_eq(); |
| 872 | __table_.max_load_factor() = __u.__table_.max_load_factor(); |
| 873 | __table_.__copy_assign_alloc(__u.__table_); |
| 874 | insert(__u.begin(), __u.end()); |
| 875 | } |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 876 | #endif |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 877 | return *this; |
| 878 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 879 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 880 | unordered_map& operator=(unordered_map&& __u) |
| 881 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 882 | #endif |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 883 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 884 | unordered_map& operator=(initializer_list<value_type> __il); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 885 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 886 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 887 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 888 | allocator_type get_allocator() const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 889 | {return allocator_type(__table_.__node_alloc());} |
| 890 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 891 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 892 | bool empty() const _NOEXCEPT {return __table_.size() == 0;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 893 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 894 | size_type size() const _NOEXCEPT {return __table_.size();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 895 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 896 | size_type max_size() const _NOEXCEPT {return __table_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 897 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 898 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 899 | iterator begin() _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 900 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 901 | iterator end() _NOEXCEPT {return __table_.end();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 902 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 903 | const_iterator begin() const _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 904 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 905 | const_iterator end() const _NOEXCEPT {return __table_.end();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 906 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 907 | const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 908 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 909 | const_iterator cend() const _NOEXCEPT {return __table_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 910 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 911 | #ifndef _LIBCPP_CXX03_LANG |
| 912 | template <class... _Args> |
| 913 | _LIBCPP_INLINE_VISIBILITY |
| 914 | pair<iterator, bool> emplace(_Args&&... __args) { |
| 915 | return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...); |
| 916 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 917 | |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 918 | template <class... _Args> |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 919 | _LIBCPP_INLINE_VISIBILITY |
| 920 | iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 921 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 922 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, |
| 923 | "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" |
| 924 | " referring to this unordered_map"); |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 925 | #endif |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 926 | return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; |
| 927 | } |
| 928 | |
| 929 | #endif // _LIBCPP_CXX03_LANG |
| 930 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 931 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 932 | pair<iterator, bool> insert(const value_type& __x) |
| 933 | {return __table_.__insert_unique(__x);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 934 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 935 | template <class _Pp, |
| 936 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 937 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 938 | pair<iterator, bool> insert(_Pp&& __x) |
| 939 | {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 940 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 941 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 942 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 943 | iterator insert(const_iterator __p, const value_type& __x) |
| 944 | { |
| 945 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, |
| 946 | "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" |
| 947 | " referring to this unordered_map"); |
| 948 | return insert(__x).first; |
| 949 | } |
| 950 | #else |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 951 | iterator insert(const_iterator, const value_type& __x) |
| 952 | {return insert(__x).first;} |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 953 | #endif |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 954 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 955 | template <class _Pp, |
| 956 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 957 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 958 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 959 | iterator insert(const_iterator __p, _Pp&& __x) |
| 960 | { |
| 961 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, |
| 962 | "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" |
| 963 | " referring to this unordered_map"); |
| 964 | return insert(_VSTD::forward<_Pp>(__x)).first; |
| 965 | } |
| 966 | #else |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 967 | iterator insert(const_iterator, _Pp&& __x) |
| 968 | {return insert(_VSTD::forward<_Pp>(__x)).first;} |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 969 | #endif |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 970 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 971 | template <class _InputIterator> |
| 972 | void insert(_InputIterator __first, _InputIterator __last); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 973 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 974 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 975 | void insert(initializer_list<value_type> __il) |
| 976 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 977 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 978 | |
Marshall Clow | 0ce05a9 | 2015-07-07 05:45:35 +0000 | [diff] [blame] | 979 | #if _LIBCPP_STD_VER > 14 |
| 980 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 981 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 982 | template <class... _Args> |
| 983 | _LIBCPP_INLINE_VISIBILITY |
| 984 | pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) |
| 985 | { |
| 986 | iterator __p = __table_.find(__k); |
| 987 | if ( __p != end()) |
| 988 | return _VSTD::make_pair(__p, false); |
| 989 | else |
| 990 | return _VSTD::make_pair( |
| 991 | emplace_hint(__p, |
| 992 | _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), |
| 993 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), |
| 994 | true); |
| 995 | } |
| 996 | |
| 997 | template <class... _Args> |
| 998 | _LIBCPP_INLINE_VISIBILITY |
| 999 | pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) |
| 1000 | { |
| 1001 | iterator __p = __table_.find(__k); |
| 1002 | if ( __p != end()) |
| 1003 | return _VSTD::make_pair(__p, false); |
| 1004 | else |
| 1005 | return _VSTD::make_pair( |
| 1006 | emplace_hint(__p, |
| 1007 | _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), |
| 1008 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)), |
| 1009 | true); |
| 1010 | } |
| 1011 | |
| 1012 | template <class... _Args> |
| 1013 | _LIBCPP_INLINE_VISIBILITY |
| 1014 | iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) |
| 1015 | { |
| 1016 | iterator __p = __table_.find(__k); |
| 1017 | if ( __p != end()) |
| 1018 | return __p; |
| 1019 | else |
| 1020 | return emplace_hint(__h, |
| 1021 | _VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k), |
| 1022 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
| 1023 | } |
| 1024 | |
| 1025 | template <class... _Args> |
| 1026 | _LIBCPP_INLINE_VISIBILITY |
| 1027 | iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) |
| 1028 | { |
| 1029 | iterator __p = __table_.find(__k); |
| 1030 | if ( __p != end()) |
| 1031 | return __p; |
| 1032 | else |
| 1033 | return emplace_hint(__h, |
| 1034 | _VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)), |
| 1035 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
| 1036 | } |
| 1037 | |
| 1038 | template <class _Vp> |
| 1039 | _LIBCPP_INLINE_VISIBILITY |
| 1040 | pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) |
| 1041 | { |
| 1042 | iterator __p = __table_.find(__k); |
| 1043 | if ( __p != end()) |
| 1044 | { |
| 1045 | __p->second = _VSTD::move(__v); |
| 1046 | return _VSTD::make_pair(__p, false); |
| 1047 | } |
| 1048 | return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); |
| 1049 | } |
| 1050 | |
| 1051 | template <class _Vp> |
| 1052 | _LIBCPP_INLINE_VISIBILITY |
| 1053 | pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) |
| 1054 | { |
| 1055 | iterator __p = __table_.find(__k); |
| 1056 | if ( __p != end()) |
| 1057 | { |
| 1058 | __p->second = _VSTD::move(__v); |
| 1059 | return _VSTD::make_pair(__p, false); |
| 1060 | } |
| 1061 | return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)), true); |
| 1062 | } |
| 1063 | |
| 1064 | template <class _Vp> |
| 1065 | _LIBCPP_INLINE_VISIBILITY |
| 1066 | iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) |
| 1067 | { |
| 1068 | iterator __p = __table_.find(__k); |
| 1069 | if ( __p != end()) |
| 1070 | { |
| 1071 | __p->second = _VSTD::move(__v); |
| 1072 | return __p; |
| 1073 | } |
| 1074 | return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); |
| 1075 | } |
| 1076 | |
| 1077 | template <class _Vp> |
| 1078 | _LIBCPP_INLINE_VISIBILITY |
| 1079 | iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) |
| 1080 | { |
| 1081 | iterator __p = __table_.find(__k); |
| 1082 | if ( __p != end()) |
| 1083 | { |
| 1084 | __p->second = _VSTD::move(__v); |
| 1085 | return __p; |
| 1086 | } |
| 1087 | return emplace_hint(__h, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)); |
| 1088 | } |
| 1089 | #endif |
| 1090 | #endif |
| 1091 | #endif |
| 1092 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1093 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1094 | iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1095 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 1096 | iterator erase(iterator __p) {return __table_.erase(__p.__i_);} |
| 1097 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1098 | size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1099 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1100 | iterator erase(const_iterator __first, const_iterator __last) |
| 1101 | {return __table_.erase(__first.__i_, __last.__i_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1102 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1103 | void clear() _NOEXCEPT {__table_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1104 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1105 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1106 | void swap(unordered_map& __u) |
| 1107 | _NOEXCEPT_(__is_nothrow_swappable<__table>::value) |
| 1108 | {__table_.swap(__u.__table_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1109 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1110 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1111 | hasher hash_function() const |
| 1112 | {return __table_.hash_function().hash_function();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1113 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1114 | key_equal key_eq() const |
| 1115 | {return __table_.key_eq().key_eq();} |
| 1116 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1117 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1118 | iterator find(const key_type& __k) {return __table_.find(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1119 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1120 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1121 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1122 | 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] | 1123 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1124 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 1125 | {return __table_.__equal_range_unique(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1126 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1127 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 1128 | {return __table_.__equal_range_unique(__k);} |
| 1129 | |
| 1130 | mapped_type& operator[](const key_type& __k); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1131 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1132 | mapped_type& operator[](key_type&& __k); |
| 1133 | #endif |
| 1134 | |
| 1135 | mapped_type& at(const key_type& __k); |
| 1136 | const mapped_type& at(const key_type& __k) const; |
| 1137 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1138 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1139 | size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1140 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1141 | size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1142 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1143 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1144 | size_type bucket_size(size_type __n) const |
| 1145 | {return __table_.bucket_size(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1146 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1147 | size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} |
| 1148 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1149 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1150 | local_iterator begin(size_type __n) {return __table_.begin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1151 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1152 | local_iterator end(size_type __n) {return __table_.end(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1153 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1154 | const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1155 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1156 | const_local_iterator end(size_type __n) const {return __table_.cend(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1157 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1158 | const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1159 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1160 | const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} |
| 1161 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1162 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1163 | float load_factor() const _NOEXCEPT {return __table_.load_factor();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1164 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1165 | float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1166 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1167 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1168 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1169 | void rehash(size_type __n) {__table_.rehash(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1170 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1171 | void reserve(size_type __n) {__table_.reserve(__n);} |
| 1172 | |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1173 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1174 | |
| 1175 | bool __dereferenceable(const const_iterator* __i) const |
| 1176 | {return __table_.__dereferenceable(&__i->__i_);} |
| 1177 | bool __decrementable(const const_iterator* __i) const |
| 1178 | {return __table_.__decrementable(&__i->__i_);} |
| 1179 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const |
| 1180 | {return __table_.__addable(&__i->__i_, __n);} |
| 1181 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 1182 | {return __table_.__addable(&__i->__i_, __n);} |
| 1183 | |
| 1184 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 |
| 1185 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 | private: |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1187 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1188 | __node_holder __construct_node_with_key(key_type&& __k); |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1189 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1190 | __node_holder __construct_node_with_key(const key_type& __k); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1191 | }; |
| 1192 | |
| 1193 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1194 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1195 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 1196 | : __table_(__hf, __eql) |
| 1197 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1198 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1199 | __get_db()->__insert_c(this); |
| 1200 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1201 | __table_.rehash(__n); |
| 1202 | } |
| 1203 | |
| 1204 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1205 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1206 | size_type __n, const hasher& __hf, const key_equal& __eql, |
| 1207 | const allocator_type& __a) |
| 1208 | : __table_(__hf, __eql, __a) |
| 1209 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1210 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1211 | __get_db()->__insert_c(this); |
| 1212 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1213 | __table_.rehash(__n); |
| 1214 | } |
| 1215 | |
| 1216 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1217 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1218 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1219 | const allocator_type& __a) |
| 1220 | : __table_(__a) |
| 1221 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1222 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1223 | __get_db()->__insert_c(this); |
| 1224 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1228 | template <class _InputIterator> |
| 1229 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1230 | _InputIterator __first, _InputIterator __last) |
| 1231 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1232 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1233 | __get_db()->__insert_c(this); |
| 1234 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1235 | insert(__first, __last); |
| 1236 | } |
| 1237 | |
| 1238 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1239 | template <class _InputIterator> |
| 1240 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1241 | _InputIterator __first, _InputIterator __last, size_type __n, |
| 1242 | const hasher& __hf, const key_equal& __eql) |
| 1243 | : __table_(__hf, __eql) |
| 1244 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1245 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1246 | __get_db()->__insert_c(this); |
| 1247 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1248 | __table_.rehash(__n); |
| 1249 | insert(__first, __last); |
| 1250 | } |
| 1251 | |
| 1252 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1253 | template <class _InputIterator> |
| 1254 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1255 | _InputIterator __first, _InputIterator __last, size_type __n, |
| 1256 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 1257 | : __table_(__hf, __eql, __a) |
| 1258 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1259 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1260 | __get_db()->__insert_c(this); |
| 1261 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1262 | __table_.rehash(__n); |
| 1263 | insert(__first, __last); |
| 1264 | } |
| 1265 | |
| 1266 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1267 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1268 | const unordered_map& __u) |
| 1269 | : __table_(__u.__table_) |
| 1270 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1271 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1272 | __get_db()->__insert_c(this); |
| 1273 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1274 | __table_.rehash(__u.bucket_count()); |
| 1275 | insert(__u.begin(), __u.end()); |
| 1276 | } |
| 1277 | |
| 1278 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1279 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1280 | const unordered_map& __u, const allocator_type& __a) |
| 1281 | : __table_(__u.__table_, __a) |
| 1282 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1283 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1284 | __get_db()->__insert_c(this); |
| 1285 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1286 | __table_.rehash(__u.bucket_count()); |
| 1287 | insert(__u.begin(), __u.end()); |
| 1288 | } |
| 1289 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1290 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1291 | |
| 1292 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1293 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1294 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1295 | unordered_map&& __u) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1296 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1297 | : __table_(_VSTD::move(__u.__table_)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1298 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1299 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1300 | __get_db()->__insert_c(this); |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 1301 | __get_db()->swap(this, &__u); |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1302 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1306 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1307 | unordered_map&& __u, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1308 | : __table_(_VSTD::move(__u.__table_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1309 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1310 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1311 | __get_db()->__insert_c(this); |
| 1312 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1313 | if (__a != __u.get_allocator()) |
| 1314 | { |
| 1315 | iterator __i = __u.begin(); |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1316 | while (__u.size() != 0) { |
| 1317 | __table_.__emplace_unique(_VSTD::move( |
| 1318 | __u.__table_.remove((__i++).__i_)->__value_.__nc)); |
| 1319 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1320 | } |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 1321 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1322 | else |
| 1323 | __get_db()->swap(this, &__u); |
| 1324 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1325 | } |
| 1326 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1327 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1328 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1329 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 1330 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1331 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1332 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1333 | initializer_list<value_type> __il) |
| 1334 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1335 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1336 | __get_db()->__insert_c(this); |
| 1337 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1338 | insert(__il.begin(), __il.end()); |
| 1339 | } |
| 1340 | |
| 1341 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1342 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1343 | initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 1344 | const key_equal& __eql) |
| 1345 | : __table_(__hf, __eql) |
| 1346 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1347 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1348 | __get_db()->__insert_c(this); |
| 1349 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1350 | __table_.rehash(__n); |
| 1351 | insert(__il.begin(), __il.end()); |
| 1352 | } |
| 1353 | |
| 1354 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1355 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1356 | initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 1357 | const key_equal& __eql, const allocator_type& __a) |
| 1358 | : __table_(__hf, __eql, __a) |
| 1359 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1360 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1361 | __get_db()->__insert_c(this); |
| 1362 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1363 | __table_.rehash(__n); |
| 1364 | insert(__il.begin(), __il.end()); |
| 1365 | } |
| 1366 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1367 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 1368 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1369 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1370 | |
| 1371 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1372 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1373 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 1374 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_map&& __u) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1375 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1376 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1377 | __table_ = _VSTD::move(__u.__table_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1378 | return *this; |
| 1379 | } |
| 1380 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1381 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1382 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1383 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 1384 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1385 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1386 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1387 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 1388 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=( |
| 1389 | initializer_list<value_type> __il) |
| 1390 | { |
| 1391 | __table_.__assign_unique(__il.begin(), __il.end()); |
| 1392 | return *this; |
| 1393 | } |
| 1394 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1395 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 1396 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1397 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1398 | |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1399 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1400 | typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| 1401 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k) |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1402 | { |
| 1403 | __node_allocator& __na = __table_.__node_alloc(); |
| 1404 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1405 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k)); |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1406 | __h.get_deleter().__first_constructed = true; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1407 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1408 | __h.get_deleter().__second_constructed = true; |
Howard Hinnant | 9a894d9 | 2013-08-22 18:29:50 +0000 | [diff] [blame] | 1409 | return __h; |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1410 | } |
| 1411 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1412 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1413 | |
| 1414 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1415 | typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1416 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1417 | { |
| 1418 | __node_allocator& __na = __table_.__node_alloc(); |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1419 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1420 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1421 | __h.get_deleter().__first_constructed = true; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1422 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1423 | __h.get_deleter().__second_constructed = true; |
Dimitry Andric | 8966350 | 2015-08-19 06:43:33 +0000 | [diff] [blame] | 1424 | return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1427 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1428 | template <class _InputIterator> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1429 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1430 | void |
| 1431 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, |
| 1432 | _InputIterator __last) |
| 1433 | { |
| 1434 | for (; __first != __last; ++__first) |
| 1435 | __table_.__insert_unique(*__first); |
| 1436 | } |
| 1437 | |
| 1438 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1439 | _Tp& |
| 1440 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) |
| 1441 | { |
| 1442 | iterator __i = find(__k); |
| 1443 | if (__i != end()) |
| 1444 | return __i->second; |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1445 | __node_holder __h = __construct_node_with_key(__k); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1446 | pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); |
| 1447 | __h.release(); |
| 1448 | return __r.first->second; |
| 1449 | } |
| 1450 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1451 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1452 | |
| 1453 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1454 | _Tp& |
| 1455 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) |
| 1456 | { |
| 1457 | iterator __i = find(__k); |
| 1458 | if (__i != end()) |
| 1459 | return __i->second; |
Howard Hinnant | b66e1c3 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1460 | __node_holder __h = __construct_node_with_key(_VSTD::move(__k)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1461 | pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); |
| 1462 | __h.release(); |
| 1463 | return __r.first->second; |
| 1464 | } |
| 1465 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1466 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1467 | |
| 1468 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1469 | _Tp& |
| 1470 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) |
| 1471 | { |
| 1472 | iterator __i = find(__k); |
| 1473 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1474 | if (__i == end()) |
| 1475 | throw out_of_range("unordered_map::at: key not found"); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1476 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1477 | return __i->second; |
| 1478 | } |
| 1479 | |
| 1480 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1481 | const _Tp& |
| 1482 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const |
| 1483 | { |
| 1484 | const_iterator __i = find(__k); |
| 1485 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1486 | if (__i == end()) |
| 1487 | throw out_of_range("unordered_map::at: key not found"); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1488 | #endif // _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1489 | return __i->second; |
| 1490 | } |
| 1491 | |
| 1492 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1493 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1494 | void |
| 1495 | swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 1496 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1497 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1498 | { |
| 1499 | __x.swap(__y); |
| 1500 | } |
| 1501 | |
| 1502 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1503 | bool |
| 1504 | operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 1505 | const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 1506 | { |
| 1507 | if (__x.size() != __y.size()) |
| 1508 | return false; |
| 1509 | typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator |
| 1510 | const_iterator; |
| 1511 | for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); |
| 1512 | __i != __ex; ++__i) |
| 1513 | { |
| 1514 | const_iterator __j = __y.find(__i->first); |
| 1515 | if (__j == __ey || !(*__i == *__j)) |
| 1516 | return false; |
| 1517 | } |
| 1518 | return true; |
| 1519 | } |
| 1520 | |
| 1521 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1522 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1523 | bool |
| 1524 | operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 1525 | const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 1526 | { |
| 1527 | return !(__x == __y); |
| 1528 | } |
| 1529 | |
| 1530 | template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, |
| 1531 | class _Alloc = allocator<pair<const _Key, _Tp> > > |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1532 | class _LIBCPP_TYPE_VIS_ONLY unordered_multimap |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1533 | { |
| 1534 | public: |
| 1535 | // types |
| 1536 | typedef _Key key_type; |
| 1537 | typedef _Tp mapped_type; |
| 1538 | typedef _Hash hasher; |
| 1539 | typedef _Pred key_equal; |
| 1540 | typedef _Alloc allocator_type; |
| 1541 | typedef pair<const key_type, mapped_type> value_type; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1542 | typedef pair<key_type, mapped_type> __nc_value_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1543 | typedef value_type& reference; |
| 1544 | typedef const value_type& const_reference; |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1545 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), |
| 1546 | "Invalid allocator::value_type"); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1547 | |
| 1548 | private: |
Howard Hinnant | ff7546e | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 1549 | typedef __hash_value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 9b128e0 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 1550 | typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; |
| 1551 | typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; |
Marshall Clow | 66302c6 | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 1552 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 1553 | __value_type>::type __allocator_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1554 | |
| 1555 | typedef __hash_table<__value_type, __hasher, |
| 1556 | __key_equal, __allocator_type> __table; |
| 1557 | |
| 1558 | __table __table_; |
| 1559 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1560 | typedef typename __table::_NodeTypes _NodeTypes; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1561 | typedef typename __table::__node_traits __node_traits; |
| 1562 | typedef typename __table::__node_allocator __node_allocator; |
| 1563 | typedef typename __table::__node __node; |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1564 | typedef __hash_map_node_destructor<__node_allocator> _Dp; |
| 1565 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1566 | typedef allocator_traits<allocator_type> __alloc_traits; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 1567 | static_assert((is_same<typename __node_traits::size_type, |
| 1568 | typename __alloc_traits::size_type>::value), |
| 1569 | "Allocator uses different size_type for different types"); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1570 | public: |
| 1571 | typedef typename __alloc_traits::pointer pointer; |
| 1572 | typedef typename __alloc_traits::const_pointer const_pointer; |
Eric Fiselier | 774c7c5 | 2016-02-10 20:46:23 +0000 | [diff] [blame] | 1573 | typedef typename __table::size_type size_type; |
| 1574 | typedef typename __table::difference_type difference_type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1575 | |
| 1576 | typedef __hash_map_iterator<typename __table::iterator> iterator; |
| 1577 | typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; |
| 1578 | typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; |
| 1579 | typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; |
| 1580 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1581 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1582 | unordered_multimap() |
| 1583 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1584 | { |
| 1585 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1586 | __get_db()->__insert_c(this); |
| 1587 | #endif |
| 1588 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1589 | explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(), |
| 1590 | const key_equal& __eql = key_equal()); |
| 1591 | unordered_multimap(size_type __n, const hasher& __hf, |
| 1592 | const key_equal& __eql, |
| 1593 | const allocator_type& __a); |
| 1594 | template <class _InputIterator> |
| 1595 | unordered_multimap(_InputIterator __first, _InputIterator __last); |
| 1596 | template <class _InputIterator> |
| 1597 | unordered_multimap(_InputIterator __first, _InputIterator __last, |
| 1598 | size_type __n, const hasher& __hf = hasher(), |
| 1599 | const key_equal& __eql = key_equal()); |
| 1600 | template <class _InputIterator> |
| 1601 | unordered_multimap(_InputIterator __first, _InputIterator __last, |
| 1602 | size_type __n, const hasher& __hf, |
| 1603 | const key_equal& __eql, |
| 1604 | const allocator_type& __a); |
| 1605 | explicit unordered_multimap(const allocator_type& __a); |
| 1606 | unordered_multimap(const unordered_multimap& __u); |
| 1607 | unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1608 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1609 | unordered_multimap(unordered_multimap&& __u) |
| 1610 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1611 | unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1612 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1613 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1614 | unordered_multimap(initializer_list<value_type> __il); |
| 1615 | unordered_multimap(initializer_list<value_type> __il, size_type __n, |
| 1616 | const hasher& __hf = hasher(), |
| 1617 | const key_equal& __eql = key_equal()); |
| 1618 | unordered_multimap(initializer_list<value_type> __il, size_type __n, |
| 1619 | const hasher& __hf, const key_equal& __eql, |
| 1620 | const allocator_type& __a); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1621 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Marshall Clow | 6dff618 | 2013-09-12 03:00:31 +0000 | [diff] [blame] | 1622 | #if _LIBCPP_STD_VER > 11 |
| 1623 | _LIBCPP_INLINE_VISIBILITY |
| 1624 | unordered_multimap(size_type __n, const allocator_type& __a) |
| 1625 | : unordered_multimap(__n, hasher(), key_equal(), __a) {} |
| 1626 | _LIBCPP_INLINE_VISIBILITY |
| 1627 | unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1628 | : unordered_multimap(__n, __hf, key_equal(), __a) {} |
| 1629 | template <class _InputIterator> |
| 1630 | _LIBCPP_INLINE_VISIBILITY |
| 1631 | unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) |
| 1632 | : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {} |
| 1633 | template <class _InputIterator> |
| 1634 | _LIBCPP_INLINE_VISIBILITY |
| 1635 | unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, |
| 1636 | const allocator_type& __a) |
| 1637 | : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} |
| 1638 | _LIBCPP_INLINE_VISIBILITY |
| 1639 | unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 1640 | : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} |
| 1641 | _LIBCPP_INLINE_VISIBILITY |
| 1642 | unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 1643 | const allocator_type& __a) |
| 1644 | : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} |
| 1645 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1646 | // ~unordered_multimap() = default; |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1647 | _LIBCPP_INLINE_VISIBILITY |
| 1648 | unordered_multimap& operator=(const unordered_multimap& __u) |
| 1649 | { |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1650 | #if __cplusplus >= 201103L |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1651 | __table_ = __u.__table_; |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1652 | #else |
Marshall Clow | ebfc50e | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 1653 | if (this != &__u) { |
| 1654 | __table_.clear(); |
| 1655 | __table_.hash_function() = __u.__table_.hash_function(); |
| 1656 | __table_.key_eq() = __u.__table_.key_eq(); |
| 1657 | __table_.max_load_factor() = __u.__table_.max_load_factor(); |
| 1658 | __table_.__copy_assign_alloc(__u.__table_); |
| 1659 | insert(__u.begin(), __u.end()); |
| 1660 | } |
Howard Hinnant | 7a6b7ce | 2013-06-22 15:21:29 +0000 | [diff] [blame] | 1661 | #endif |
Howard Hinnant | 61aa601 | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1662 | return *this; |
| 1663 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1664 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1665 | unordered_multimap& operator=(unordered_multimap&& __u) |
| 1666 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1667 | #endif |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1668 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1669 | unordered_multimap& operator=(initializer_list<value_type> __il); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1670 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1671 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1673 | allocator_type get_allocator() const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1674 | {return allocator_type(__table_.__node_alloc());} |
| 1675 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1676 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1677 | bool empty() const _NOEXCEPT {return __table_.size() == 0;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1678 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1679 | size_type size() const _NOEXCEPT {return __table_.size();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1680 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1681 | size_type max_size() const _NOEXCEPT {return __table_.max_size();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1682 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1683 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1684 | iterator begin() _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1685 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1686 | iterator end() _NOEXCEPT {return __table_.end();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1687 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1688 | const_iterator begin() const _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1689 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1690 | const_iterator end() const _NOEXCEPT {return __table_.end();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1691 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1692 | const_iterator cbegin() const _NOEXCEPT {return __table_.begin();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1693 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1694 | const_iterator cend() const _NOEXCEPT {return __table_.end();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1695 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1696 | #ifndef _LIBCPP_CXX03_LANG |
| 1697 | template <class... _Args> |
| 1698 | iterator emplace(_Args&&... __args) { |
| 1699 | return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...); |
| 1700 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1701 | |
Howard Hinnant | 635ce1d | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1702 | template <class... _Args> |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1703 | iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 1704 | return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...); |
| 1705 | } |
| 1706 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1707 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1708 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1709 | iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1710 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1711 | template <class _Pp, |
| 1712 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1713 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1714 | iterator insert(_Pp&& __x) |
| 1715 | {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1716 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1717 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1718 | iterator insert(const_iterator __p, const value_type& __x) |
| 1719 | {return __table_.__insert_multi(__p.__i_, __x);} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1720 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1721 | template <class _Pp, |
| 1722 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1723 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1724 | iterator insert(const_iterator __p, _Pp&& __x) |
| 1725 | {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));} |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1726 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1727 | template <class _InputIterator> |
| 1728 | void insert(_InputIterator __first, _InputIterator __last); |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1729 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1730 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1731 | void insert(initializer_list<value_type> __il) |
| 1732 | {insert(__il.begin(), __il.end());} |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1733 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1734 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1735 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1736 | iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1737 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 488025c | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 1738 | iterator erase(iterator __p) {return __table_.erase(__p.__i_);} |
| 1739 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1740 | size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1741 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1742 | iterator erase(const_iterator __first, const_iterator __last) |
| 1743 | {return __table_.erase(__first.__i_, __last.__i_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1744 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1745 | void clear() _NOEXCEPT {__table_.clear();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1746 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1747 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1748 | void swap(unordered_multimap& __u) |
| 1749 | _NOEXCEPT_(__is_nothrow_swappable<__table>::value) |
| 1750 | {__table_.swap(__u.__table_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1751 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1752 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1753 | hasher hash_function() const |
| 1754 | {return __table_.hash_function().hash_function();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1755 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1756 | key_equal key_eq() const |
| 1757 | {return __table_.key_eq().key_eq();} |
| 1758 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1759 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1760 | iterator find(const key_type& __k) {return __table_.find(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1761 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1762 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1763 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1764 | 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] | 1765 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1766 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 1767 | {return __table_.__equal_range_multi(__k);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1768 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1769 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 1770 | {return __table_.__equal_range_multi(__k);} |
| 1771 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1772 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1773 | size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1774 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1775 | size_type max_bucket_count() const _NOEXCEPT |
| 1776 | {return __table_.max_bucket_count();} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1777 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1778 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1779 | size_type bucket_size(size_type __n) const |
| 1780 | {return __table_.bucket_size(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1781 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1782 | size_type bucket(const key_type& __k) const {return __table_.bucket(__k);} |
| 1783 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1784 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1785 | local_iterator begin(size_type __n) {return __table_.begin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1786 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1787 | local_iterator end(size_type __n) {return __table_.end(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1788 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1789 | const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1790 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1791 | const_local_iterator end(size_type __n) const {return __table_.cend(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1792 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1793 | const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1794 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1795 | const_local_iterator cend(size_type __n) const {return __table_.cend(__n);} |
| 1796 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1797 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1798 | float load_factor() const _NOEXCEPT {return __table_.load_factor();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1799 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1800 | float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1801 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1802 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1803 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1804 | void rehash(size_type __n) {__table_.rehash(__n);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1805 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1806 | void reserve(size_type __n) {__table_.reserve(__n);} |
| 1807 | |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1808 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1809 | |
| 1810 | bool __dereferenceable(const const_iterator* __i) const |
| 1811 | {return __table_.__dereferenceable(&__i->__i_);} |
| 1812 | bool __decrementable(const const_iterator* __i) const |
| 1813 | {return __table_.__decrementable(&__i->__i_);} |
| 1814 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const |
| 1815 | {return __table_.__addable(&__i->__i_, __n);} |
| 1816 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 1817 | {return __table_.__addable(&__i->__i_, __n);} |
| 1818 | |
| 1819 | #endif // _LIBCPP_DEBUG_LEVEL >= 2 |
| 1820 | |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1821 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1822 | }; |
| 1823 | |
| 1824 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1825 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1826 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 1827 | : __table_(__hf, __eql) |
| 1828 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1829 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1830 | __get_db()->__insert_c(this); |
| 1831 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1832 | __table_.rehash(__n); |
| 1833 | } |
| 1834 | |
| 1835 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1836 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1837 | size_type __n, const hasher& __hf, const key_equal& __eql, |
| 1838 | const allocator_type& __a) |
| 1839 | : __table_(__hf, __eql, __a) |
| 1840 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1841 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1842 | __get_db()->__insert_c(this); |
| 1843 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1844 | __table_.rehash(__n); |
| 1845 | } |
| 1846 | |
| 1847 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1848 | template <class _InputIterator> |
| 1849 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1850 | _InputIterator __first, _InputIterator __last) |
| 1851 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1852 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1853 | __get_db()->__insert_c(this); |
| 1854 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1855 | insert(__first, __last); |
| 1856 | } |
| 1857 | |
| 1858 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1859 | template <class _InputIterator> |
| 1860 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1861 | _InputIterator __first, _InputIterator __last, size_type __n, |
| 1862 | const hasher& __hf, const key_equal& __eql) |
| 1863 | : __table_(__hf, __eql) |
| 1864 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1865 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1866 | __get_db()->__insert_c(this); |
| 1867 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1868 | __table_.rehash(__n); |
| 1869 | insert(__first, __last); |
| 1870 | } |
| 1871 | |
| 1872 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1873 | template <class _InputIterator> |
| 1874 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1875 | _InputIterator __first, _InputIterator __last, size_type __n, |
| 1876 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 1877 | : __table_(__hf, __eql, __a) |
| 1878 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1879 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1880 | __get_db()->__insert_c(this); |
| 1881 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1882 | __table_.rehash(__n); |
| 1883 | insert(__first, __last); |
| 1884 | } |
| 1885 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1886 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1887 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1888 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1889 | const allocator_type& __a) |
| 1890 | : __table_(__a) |
| 1891 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1892 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1893 | __get_db()->__insert_c(this); |
| 1894 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1895 | } |
| 1896 | |
| 1897 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1898 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1899 | const unordered_multimap& __u) |
| 1900 | : __table_(__u.__table_) |
| 1901 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1902 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1903 | __get_db()->__insert_c(this); |
| 1904 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1905 | __table_.rehash(__u.bucket_count()); |
| 1906 | insert(__u.begin(), __u.end()); |
| 1907 | } |
| 1908 | |
| 1909 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1910 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1911 | const unordered_multimap& __u, const allocator_type& __a) |
| 1912 | : __table_(__u.__table_, __a) |
| 1913 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1914 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1915 | __get_db()->__insert_c(this); |
| 1916 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1917 | __table_.rehash(__u.bucket_count()); |
| 1918 | insert(__u.begin(), __u.end()); |
| 1919 | } |
| 1920 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1921 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1922 | |
| 1923 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 1924 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1925 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1926 | unordered_multimap&& __u) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 1927 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1928 | : __table_(_VSTD::move(__u.__table_)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1929 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1930 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1931 | __get_db()->__insert_c(this); |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 1932 | __get_db()->swap(this, &__u); |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1933 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1937 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1938 | unordered_multimap&& __u, const allocator_type& __a) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1939 | : __table_(_VSTD::move(__u.__table_), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1940 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1941 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1942 | __get_db()->__insert_c(this); |
| 1943 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1944 | if (__a != __u.get_allocator()) |
| 1945 | { |
| 1946 | iterator __i = __u.begin(); |
| 1947 | while (__u.size() != 0) |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1948 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1949 | __table_.__insert_multi( |
Eric Fiselier | 2960ae2 | 2016-02-11 11:59:44 +0000 | [diff] [blame^] | 1950 | _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_.__nc) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1951 | ); |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1952 | } |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1953 | } |
Howard Hinnant | f890d9b | 2013-07-30 21:04:42 +0000 | [diff] [blame] | 1954 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1955 | else |
| 1956 | __get_db()->swap(this, &__u); |
| 1957 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1958 | } |
| 1959 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1960 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1961 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1962 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 1963 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1964 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1965 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1966 | initializer_list<value_type> __il) |
| 1967 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1968 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1969 | __get_db()->__insert_c(this); |
| 1970 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1971 | insert(__il.begin(), __il.end()); |
| 1972 | } |
| 1973 | |
| 1974 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1975 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1976 | initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 1977 | const key_equal& __eql) |
| 1978 | : __table_(__hf, __eql) |
| 1979 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1980 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1981 | __get_db()->__insert_c(this); |
| 1982 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1983 | __table_.rehash(__n); |
| 1984 | insert(__il.begin(), __il.end()); |
| 1985 | } |
| 1986 | |
| 1987 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1988 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 1989 | initializer_list<value_type> __il, size_type __n, const hasher& __hf, |
| 1990 | const key_equal& __eql, const allocator_type& __a) |
| 1991 | : __table_(__hf, __eql, __a) |
| 1992 | { |
Howard Hinnant | 3921364 | 2013-07-23 22:01:58 +0000 | [diff] [blame] | 1993 | #if _LIBCPP_DEBUG_LEVEL >= 2 |
| 1994 | __get_db()->__insert_c(this); |
| 1995 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1996 | __table_.rehash(__n); |
| 1997 | insert(__il.begin(), __il.end()); |
| 1998 | } |
| 1999 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 2000 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 2001 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2002 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2003 | |
| 2004 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2005 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2006 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 2007 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(unordered_multimap&& __u) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 2008 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2009 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2010 | __table_ = _VSTD::move(__u.__table_); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2011 | return *this; |
| 2012 | } |
| 2013 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 2014 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2015 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 2016 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 2017 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2018 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2019 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2020 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& |
| 2021 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=( |
| 2022 | initializer_list<value_type> __il) |
| 2023 | { |
| 2024 | __table_.__assign_multi(__il.begin(), __il.end()); |
| 2025 | return *this; |
| 2026 | } |
| 2027 | |
Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 2028 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS |
| 2029 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2030 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2031 | |
| 2032 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2033 | template <class _InputIterator> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2034 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2035 | void |
| 2036 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, |
| 2037 | _InputIterator __last) |
| 2038 | { |
| 2039 | for (; __first != __last; ++__first) |
| 2040 | __table_.__insert_multi(*__first); |
| 2041 | } |
| 2042 | |
| 2043 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2044 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2045 | void |
| 2046 | swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 2047 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
Howard Hinnant | 5f2f14c | 2011-06-04 18:54:24 +0000 | [diff] [blame] | 2048 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2049 | { |
| 2050 | __x.swap(__y); |
| 2051 | } |
| 2052 | |
| 2053 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2054 | bool |
| 2055 | operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 2056 | const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 2057 | { |
| 2058 | if (__x.size() != __y.size()) |
| 2059 | return false; |
| 2060 | typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator |
| 2061 | const_iterator; |
| 2062 | typedef pair<const_iterator, const_iterator> _EqRng; |
| 2063 | for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) |
| 2064 | { |
| 2065 | _EqRng __xeq = __x.equal_range(__i->first); |
| 2066 | _EqRng __yeq = __y.equal_range(__i->first); |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2067 | if (_VSTD::distance(__xeq.first, __xeq.second) != |
| 2068 | _VSTD::distance(__yeq.first, __yeq.second) || |
| 2069 | !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2070 | return false; |
| 2071 | __i = __xeq.second; |
| 2072 | } |
| 2073 | return true; |
| 2074 | } |
| 2075 | |
| 2076 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 2077 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2078 | bool |
| 2079 | operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 2080 | const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) |
| 2081 | { |
| 2082 | return !(__x == __y); |
| 2083 | } |
| 2084 | |
| 2085 | _LIBCPP_END_NAMESPACE_STD |
| 2086 | |
| 2087 | #endif // _LIBCPP_UNORDERED_MAP |