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