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