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