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