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