unordered_map 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // <unordered_map> -*- C++ -*-
  2. // Copyright (C) 2007-2023 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file include/unordered_map
  21. * This is a Standard C++ Library header.
  22. */
  23. #ifndef _GLIBCXX_UNORDERED_MAP
  24. #define _GLIBCXX_UNORDERED_MAP 1
  25. #pragma GCC system_header
  26. #include <bits/requires_hosted.h> // container
  27. #if __cplusplus < 201103L
  28. # include <bits/c++0x_warning.h>
  29. #else
  30. #include <initializer_list>
  31. #include <bits/unordered_map.h>
  32. #include <bits/range_access.h>
  33. #include <bits/erase_if.h>
  34. #ifdef _GLIBCXX_DEBUG
  35. # include <debug/unordered_map>
  36. #endif
  37. #if __cplusplus >= 201703L
  38. #include <bits/memory_resource.h>
  39. namespace std _GLIBCXX_VISIBILITY(default)
  40. {
  41. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  42. namespace pmr
  43. {
  44. template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
  45. typename _Pred = std::equal_to<_Key>>
  46. using unordered_map
  47. = std::unordered_map<_Key, _Tp, _Hash, _Pred,
  48. polymorphic_allocator<pair<const _Key, _Tp>>>;
  49. template<typename _Key, typename _Tp, typename _Hash = std::hash<_Key>,
  50. typename _Pred = std::equal_to<_Key>>
  51. using unordered_multimap
  52. = std::unordered_multimap<_Key, _Tp, _Hash, _Pred,
  53. polymorphic_allocator<pair<const _Key, _Tp>>>;
  54. } // namespace pmr
  55. _GLIBCXX_END_NAMESPACE_VERSION
  56. } // namespace std
  57. #endif // C++17
  58. #if __cplusplus > 201703L
  59. namespace std _GLIBCXX_VISIBILITY(default)
  60. {
  61. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  62. template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
  63. typename _Alloc, typename _Predicate>
  64. inline typename unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>::size_type
  65. erase_if(unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
  66. _Predicate __pred)
  67. {
  68. _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _CPred, _Alloc>&
  69. __ucont = __cont;
  70. return __detail::__erase_nodes_if(__cont, __ucont, __pred);
  71. }
  72. template<typename _Key, typename _Tp, typename _Hash, typename _CPred,
  73. typename _Alloc, typename _Predicate>
  74. inline typename unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>::
  75. size_type
  76. erase_if(unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>& __cont,
  77. _Predicate __pred)
  78. {
  79. _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _CPred, _Alloc>&
  80. __ucont = __cont;
  81. return __detail::__erase_nodes_if(__cont, __ucont, __pred);
  82. }
  83. _GLIBCXX_END_NAMESPACE_VERSION
  84. } // namespace std
  85. #endif // C++20
  86. #endif // C++11
  87. #endif // _GLIBCXX_UNORDERED_MAP