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