146035553Spatrick// -*- C++ -*- 2*4bdff4beSrobert//===----------------------------------------------------------------------===// 346035553Spatrick// 446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 546035553Spatrick// See https://llvm.org/LICENSE.txt for license information. 646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 746035553Spatrick// 846035553Spatrick//===----------------------------------------------------------------------===// 946035553Spatrick 1046035553Spatrick#ifndef _LIBCPP_HASH_MAP 1146035553Spatrick#define _LIBCPP_HASH_MAP 1246035553Spatrick 1346035553Spatrick/* 1446035553Spatrick 1546035553Spatrick hash_map synopsis 1646035553Spatrick 1746035553Spatricknamespace __gnu_cxx 1846035553Spatrick{ 1946035553Spatrick 2046035553Spatricktemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 2146035553Spatrick class Alloc = allocator<pair<const Key, T>>> 2246035553Spatrickclass hash_map 2346035553Spatrick{ 2446035553Spatrickpublic: 2546035553Spatrick // types 2646035553Spatrick typedef Key key_type; 2746035553Spatrick typedef T mapped_type; 2846035553Spatrick typedef Hash hasher; 2946035553Spatrick typedef Pred key_equal; 3046035553Spatrick typedef Alloc allocator_type; 3146035553Spatrick typedef pair<const key_type, mapped_type> value_type; 3246035553Spatrick typedef value_type& reference; 3346035553Spatrick typedef const value_type& const_reference; 3446035553Spatrick typedef typename allocator_traits<allocator_type>::pointer pointer; 3546035553Spatrick typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 3646035553Spatrick typedef typename allocator_traits<allocator_type>::size_type size_type; 3746035553Spatrick typedef typename allocator_traits<allocator_type>::difference_type difference_type; 3846035553Spatrick 3946035553Spatrick typedef /unspecified/ iterator; 4046035553Spatrick typedef /unspecified/ const_iterator; 4146035553Spatrick 4246035553Spatrick hash_map(); 4346035553Spatrick explicit hash_map(size_type n, const hasher& hf = hasher(), 4446035553Spatrick const key_equal& eql = key_equal(), 4546035553Spatrick const allocator_type& a = allocator_type()); 4646035553Spatrick template <class InputIterator> 4746035553Spatrick hash_map(InputIterator f, InputIterator l); 4846035553Spatrick template <class InputIterator> 4946035553Spatrick hash_map(InputIterator f, InputIterator l, 5046035553Spatrick size_type n, const hasher& hf = hasher(), 5146035553Spatrick const key_equal& eql = key_equal(), 5246035553Spatrick const allocator_type& a = allocator_type()); 5346035553Spatrick hash_map(const hash_map&); 5446035553Spatrick ~hash_map(); 5546035553Spatrick hash_map& operator=(const hash_map&); 5646035553Spatrick 5746035553Spatrick allocator_type get_allocator() const; 5846035553Spatrick 5946035553Spatrick bool empty() const; 6046035553Spatrick size_type size() const; 6146035553Spatrick size_type max_size() const; 6246035553Spatrick 6346035553Spatrick iterator begin(); 6446035553Spatrick iterator end(); 6546035553Spatrick const_iterator begin() const; 6646035553Spatrick const_iterator end() const; 6746035553Spatrick 6846035553Spatrick pair<iterator, bool> insert(const value_type& obj); 6946035553Spatrick template <class InputIterator> 7046035553Spatrick void insert(InputIterator first, InputIterator last); 7146035553Spatrick 7246035553Spatrick void erase(const_iterator position); 7346035553Spatrick size_type erase(const key_type& k); 7446035553Spatrick void erase(const_iterator first, const_iterator last); 7546035553Spatrick void clear(); 7646035553Spatrick 7746035553Spatrick void swap(hash_map&); 7846035553Spatrick 7946035553Spatrick hasher hash_funct() const; 8046035553Spatrick key_equal key_eq() const; 8146035553Spatrick 8246035553Spatrick iterator find(const key_type& k); 8346035553Spatrick const_iterator find(const key_type& k) const; 8446035553Spatrick size_type count(const key_type& k) const; 8546035553Spatrick pair<iterator, iterator> equal_range(const key_type& k); 8646035553Spatrick pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 8746035553Spatrick 8846035553Spatrick mapped_type& operator[](const key_type& k); 8946035553Spatrick 9046035553Spatrick size_type bucket_count() const; 9146035553Spatrick size_type max_bucket_count() const; 9246035553Spatrick 9346035553Spatrick size_type elems_in_bucket(size_type n) const; 9446035553Spatrick 9546035553Spatrick void resize(size_type n); 9646035553Spatrick}; 9746035553Spatrick 9846035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 9946035553Spatrick void swap(hash_map<Key, T, Hash, Pred, Alloc>& x, 10046035553Spatrick hash_map<Key, T, Hash, Pred, Alloc>& y); 10146035553Spatrick 10246035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 10346035553Spatrick bool 10446035553Spatrick operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x, 10546035553Spatrick const hash_map<Key, T, Hash, Pred, Alloc>& y); 10646035553Spatrick 10746035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 10846035553Spatrick bool 10946035553Spatrick operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x, 11046035553Spatrick const hash_map<Key, T, Hash, Pred, Alloc>& y); 11146035553Spatrick 11246035553Spatricktemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 11346035553Spatrick class Alloc = allocator<pair<const Key, T>>> 11446035553Spatrickclass hash_multimap 11546035553Spatrick{ 11646035553Spatrickpublic: 11746035553Spatrick // types 11846035553Spatrick typedef Key key_type; 11946035553Spatrick typedef T mapped_type; 12046035553Spatrick typedef Hash hasher; 12146035553Spatrick typedef Pred key_equal; 12246035553Spatrick typedef Alloc allocator_type; 12346035553Spatrick typedef pair<const key_type, mapped_type> value_type; 12446035553Spatrick typedef value_type& reference; 12546035553Spatrick typedef const value_type& const_reference; 12646035553Spatrick typedef typename allocator_traits<allocator_type>::pointer pointer; 12746035553Spatrick typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 12846035553Spatrick typedef typename allocator_traits<allocator_type>::size_type size_type; 12946035553Spatrick typedef typename allocator_traits<allocator_type>::difference_type difference_type; 13046035553Spatrick 13146035553Spatrick typedef /unspecified/ iterator; 13246035553Spatrick typedef /unspecified/ const_iterator; 13346035553Spatrick 13446035553Spatrick explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(), 13546035553Spatrick const key_equal& eql = key_equal(), 13646035553Spatrick const allocator_type& a = allocator_type()); 13746035553Spatrick template <class InputIterator> 13846035553Spatrick hash_multimap(InputIterator f, InputIterator l, 13946035553Spatrick size_type n = 193, const hasher& hf = hasher(), 14046035553Spatrick const key_equal& eql = key_equal(), 14146035553Spatrick const allocator_type& a = allocator_type()); 14246035553Spatrick explicit hash_multimap(const allocator_type&); 14346035553Spatrick hash_multimap(const hash_multimap&); 14446035553Spatrick ~hash_multimap(); 14546035553Spatrick hash_multimap& operator=(const hash_multimap&); 14646035553Spatrick 14746035553Spatrick allocator_type get_allocator() const; 14846035553Spatrick 14946035553Spatrick bool empty() const; 15046035553Spatrick size_type size() const; 15146035553Spatrick size_type max_size() const; 15246035553Spatrick 15346035553Spatrick iterator begin(); 15446035553Spatrick iterator end(); 15546035553Spatrick const_iterator begin() const; 15646035553Spatrick const_iterator end() const; 15746035553Spatrick 15846035553Spatrick iterator insert(const value_type& obj); 15946035553Spatrick template <class InputIterator> 16046035553Spatrick void insert(InputIterator first, InputIterator last); 16146035553Spatrick 16246035553Spatrick void erase(const_iterator position); 16346035553Spatrick size_type erase(const key_type& k); 16446035553Spatrick void erase(const_iterator first, const_iterator last); 16546035553Spatrick void clear(); 16646035553Spatrick 16746035553Spatrick void swap(hash_multimap&); 16846035553Spatrick 16946035553Spatrick hasher hash_funct() const; 17046035553Spatrick key_equal key_eq() const; 17146035553Spatrick 17246035553Spatrick iterator find(const key_type& k); 17346035553Spatrick const_iterator find(const key_type& k) const; 17446035553Spatrick size_type count(const key_type& k) const; 17546035553Spatrick pair<iterator, iterator> equal_range(const key_type& k); 17646035553Spatrick pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 17746035553Spatrick 17846035553Spatrick size_type bucket_count() const; 17946035553Spatrick size_type max_bucket_count() const; 18046035553Spatrick 18146035553Spatrick size_type elems_in_bucket(size_type n) const; 18246035553Spatrick 18346035553Spatrick void resize(size_type n); 18446035553Spatrick}; 18546035553Spatrick 18646035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 18746035553Spatrick void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x, 18846035553Spatrick hash_multimap<Key, T, Hash, Pred, Alloc>& y); 18946035553Spatrick 19046035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 19146035553Spatrick bool 19246035553Spatrick operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x, 19346035553Spatrick const hash_multimap<Key, T, Hash, Pred, Alloc>& y); 19446035553Spatrick 19546035553Spatricktemplate <class Key, class T, class Hash, class Pred, class Alloc> 19646035553Spatrick bool 19746035553Spatrick operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x, 19846035553Spatrick const hash_multimap<Key, T, Hash, Pred, Alloc>& y); 19946035553Spatrick 20046035553Spatrick} // __gnu_cxx 20146035553Spatrick 20246035553Spatrick*/ 20346035553Spatrick 204*4bdff4beSrobert#include <__assert> // all public C++ headers provide the assertion handler 20546035553Spatrick#include <__config> 20646035553Spatrick#include <__hash_table> 207*4bdff4beSrobert#include <algorithm> 208*4bdff4beSrobert#include <ext/__hash> 20946035553Spatrick#include <functional> 21046035553Spatrick#include <stdexcept> 21146035553Spatrick#include <type_traits> 21246035553Spatrick 21376d0caaeSpatrick#if defined(__DEPRECATED) && __DEPRECATED 21446035553Spatrick#if defined(_LIBCPP_WARNING) 21546035553Spatrick _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") 21646035553Spatrick#else 21746035553Spatrick# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> 21846035553Spatrick#endif 21946035553Spatrick#endif 22046035553Spatrick 22146035553Spatrick#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 22246035553Spatrick# pragma GCC system_header 22346035553Spatrick#endif 22446035553Spatrick 22546035553Spatricknamespace __gnu_cxx { 22646035553Spatrick 22746035553Spatricktemplate <class _Tp, class _Hash, 22846035553Spatrick bool = std::is_empty<_Hash>::value && !std::__libcpp_is_final<_Hash>::value 22946035553Spatrick > 23046035553Spatrickclass __hash_map_hasher 23146035553Spatrick : private _Hash 23246035553Spatrick{ 23346035553Spatrickpublic: 23446035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {} 23546035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {} 23646035553Spatrick _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;} 23746035553Spatrick _LIBCPP_INLINE_VISIBILITY 23846035553Spatrick size_t operator()(const _Tp& __x) const 23946035553Spatrick {return static_cast<const _Hash&>(*this)(__x.first);} 24046035553Spatrick _LIBCPP_INLINE_VISIBILITY 24146035553Spatrick size_t operator()(const typename _Tp::first_type& __x) const 24246035553Spatrick {return static_cast<const _Hash&>(*this)(__x);} 24346035553Spatrick}; 24446035553Spatrick 24546035553Spatricktemplate <class _Tp, class _Hash> 24646035553Spatrickclass __hash_map_hasher<_Tp, _Hash, false> 24746035553Spatrick{ 24846035553Spatrick _Hash __hash_; 24946035553Spatrickpublic: 25046035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {} 25146035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {} 25246035553Spatrick _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;} 25346035553Spatrick _LIBCPP_INLINE_VISIBILITY 25446035553Spatrick size_t operator()(const _Tp& __x) const 25546035553Spatrick {return __hash_(__x.first);} 25646035553Spatrick _LIBCPP_INLINE_VISIBILITY 25746035553Spatrick size_t operator()(const typename _Tp::first_type& __x) const 25846035553Spatrick {return __hash_(__x);} 25946035553Spatrick}; 26046035553Spatrick 26146035553Spatricktemplate <class _Tp, class _Pred, 26246035553Spatrick bool = std::is_empty<_Pred>::value && !std::__libcpp_is_final<_Pred>::value 26346035553Spatrick > 26446035553Spatrickclass __hash_map_equal 26546035553Spatrick : private _Pred 26646035553Spatrick{ 26746035553Spatrickpublic: 26846035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {} 26946035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {} 27046035553Spatrick _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;} 27146035553Spatrick _LIBCPP_INLINE_VISIBILITY 27246035553Spatrick bool operator()(const _Tp& __x, const _Tp& __y) const 27346035553Spatrick {return static_cast<const _Pred&>(*this)(__x.first, __y.first);} 27446035553Spatrick _LIBCPP_INLINE_VISIBILITY 27546035553Spatrick bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 27646035553Spatrick {return static_cast<const _Pred&>(*this)(__x, __y.first);} 27746035553Spatrick _LIBCPP_INLINE_VISIBILITY 27846035553Spatrick bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 27946035553Spatrick {return static_cast<const _Pred&>(*this)(__x.first, __y);} 28046035553Spatrick _LIBCPP_INLINE_VISIBILITY 28146035553Spatrick bool operator()(const typename _Tp::first_type& __x, 28246035553Spatrick const typename _Tp::first_type& __y) const 28346035553Spatrick {return static_cast<const _Pred&>(*this)(__x, __y);} 28446035553Spatrick}; 28546035553Spatrick 28646035553Spatricktemplate <class _Tp, class _Pred> 28746035553Spatrickclass __hash_map_equal<_Tp, _Pred, false> 28846035553Spatrick{ 28946035553Spatrick _Pred __pred_; 29046035553Spatrickpublic: 29146035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {} 29246035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {} 29346035553Spatrick _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;} 29446035553Spatrick _LIBCPP_INLINE_VISIBILITY 29546035553Spatrick bool operator()(const _Tp& __x, const _Tp& __y) const 29646035553Spatrick {return __pred_(__x.first, __y.first);} 29746035553Spatrick _LIBCPP_INLINE_VISIBILITY 29846035553Spatrick bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 29946035553Spatrick {return __pred_(__x, __y.first);} 30046035553Spatrick _LIBCPP_INLINE_VISIBILITY 30146035553Spatrick bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 30246035553Spatrick {return __pred_(__x.first, __y);} 30346035553Spatrick _LIBCPP_INLINE_VISIBILITY 30446035553Spatrick bool operator()(const typename _Tp::first_type& __x, 30546035553Spatrick const typename _Tp::first_type& __y) const 30646035553Spatrick {return __pred_(__x, __y);} 30746035553Spatrick}; 30846035553Spatrick 30946035553Spatricktemplate <class _Alloc> 31046035553Spatrickclass __hash_map_node_destructor 31146035553Spatrick{ 31246035553Spatrick typedef _Alloc allocator_type; 31346035553Spatrick typedef std::allocator_traits<allocator_type> __alloc_traits; 31446035553Spatrick typedef typename __alloc_traits::value_type::__node_value_type value_type; 31546035553Spatrickpublic: 31646035553Spatrick typedef typename __alloc_traits::pointer pointer; 31746035553Spatrickprivate: 31846035553Spatrick typedef typename value_type::first_type first_type; 31946035553Spatrick typedef typename value_type::second_type second_type; 32046035553Spatrick 32146035553Spatrick allocator_type& __na_; 32246035553Spatrick 32346035553Spatrickpublic: 32446035553Spatrick bool __first_constructed; 32546035553Spatrick bool __second_constructed; 32646035553Spatrick 32746035553Spatrick __hash_map_node_destructor(__hash_map_node_destructor const&) = default; 32846035553Spatrick __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete; 32946035553Spatrick 33046035553Spatrick _LIBCPP_INLINE_VISIBILITY 33146035553Spatrick explicit __hash_map_node_destructor(allocator_type& __na) 33246035553Spatrick : __na_(__na), 33346035553Spatrick __first_constructed(false), 33446035553Spatrick __second_constructed(false) 33546035553Spatrick {} 33646035553Spatrick 33746035553Spatrick#ifndef _LIBCPP_CXX03_LANG 33846035553Spatrick _LIBCPP_INLINE_VISIBILITY 33946035553Spatrick __hash_map_node_destructor(std::__hash_node_destructor<allocator_type>&& __x) 34046035553Spatrick : __na_(__x.__na_), 34146035553Spatrick __first_constructed(__x.__value_constructed), 34246035553Spatrick __second_constructed(__x.__value_constructed) 34346035553Spatrick { 34446035553Spatrick __x.__value_constructed = false; 34546035553Spatrick } 34646035553Spatrick#else // _LIBCPP_CXX03_LANG 34746035553Spatrick _LIBCPP_INLINE_VISIBILITY 34846035553Spatrick __hash_map_node_destructor(const std::__hash_node_destructor<allocator_type>& __x) 34946035553Spatrick : __na_(__x.__na_), 35046035553Spatrick __first_constructed(__x.__value_constructed), 35146035553Spatrick __second_constructed(__x.__value_constructed) 35246035553Spatrick { 35346035553Spatrick const_cast<bool&>(__x.__value_constructed) = false; 35446035553Spatrick } 35546035553Spatrick#endif // _LIBCPP_CXX03_LANG 35646035553Spatrick 35746035553Spatrick _LIBCPP_INLINE_VISIBILITY 35846035553Spatrick void operator()(pointer __p) 35946035553Spatrick { 36046035553Spatrick if (__second_constructed) 36146035553Spatrick __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second)); 36246035553Spatrick if (__first_constructed) 36346035553Spatrick __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first)); 36446035553Spatrick if (__p) 36546035553Spatrick __alloc_traits::deallocate(__na_, __p, 1); 36646035553Spatrick } 36746035553Spatrick}; 36846035553Spatrick 36946035553Spatricktemplate <class _HashIterator> 37046035553Spatrickclass _LIBCPP_TEMPLATE_VIS __hash_map_iterator 37146035553Spatrick{ 37246035553Spatrick _HashIterator __i_; 37346035553Spatrick 37446035553Spatrick typedef const typename _HashIterator::value_type::first_type key_type; 37546035553Spatrick typedef typename _HashIterator::value_type::second_type mapped_type; 37646035553Spatrickpublic: 37746035553Spatrick typedef std::forward_iterator_tag iterator_category; 37846035553Spatrick typedef std::pair<key_type, mapped_type> value_type; 37946035553Spatrick typedef typename _HashIterator::difference_type difference_type; 38046035553Spatrick typedef value_type& reference; 381*4bdff4beSrobert typedef std::__rebind_pointer_t<typename _HashIterator::pointer, value_type> 38246035553Spatrick pointer; 38346035553Spatrick 38446035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {} 38546035553Spatrick 38646035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {} 38746035553Spatrick 38846035553Spatrick _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();} 38946035553Spatrick _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();} 39046035553Spatrick 39146035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;} 39246035553Spatrick _LIBCPP_INLINE_VISIBILITY 39346035553Spatrick __hash_map_iterator operator++(int) 39446035553Spatrick { 39546035553Spatrick __hash_map_iterator __t(*this); 39646035553Spatrick ++(*this); 39746035553Spatrick return __t; 39846035553Spatrick } 39946035553Spatrick 40046035553Spatrick friend _LIBCPP_INLINE_VISIBILITY 40146035553Spatrick bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 40246035553Spatrick {return __x.__i_ == __y.__i_;} 40346035553Spatrick friend _LIBCPP_INLINE_VISIBILITY 40446035553Spatrick bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 40546035553Spatrick {return __x.__i_ != __y.__i_;} 40646035553Spatrick 40746035553Spatrick template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map; 40846035553Spatrick template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap; 40946035553Spatrick template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 41046035553Spatrick template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 41146035553Spatrick template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; 41246035553Spatrick}; 41346035553Spatrick 41446035553Spatricktemplate <class _HashIterator> 41546035553Spatrickclass _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator 41646035553Spatrick{ 41746035553Spatrick _HashIterator __i_; 41846035553Spatrick 41946035553Spatrick typedef const typename _HashIterator::value_type::first_type key_type; 42046035553Spatrick typedef typename _HashIterator::value_type::second_type mapped_type; 42146035553Spatrickpublic: 42246035553Spatrick typedef std::forward_iterator_tag iterator_category; 42346035553Spatrick typedef std::pair<key_type, mapped_type> value_type; 42446035553Spatrick typedef typename _HashIterator::difference_type difference_type; 42546035553Spatrick typedef const value_type& reference; 426*4bdff4beSrobert typedef std::__rebind_pointer_t<typename _HashIterator::pointer, const value_type> 42746035553Spatrick pointer; 42846035553Spatrick 42946035553Spatrick _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {} 43046035553Spatrick 43146035553Spatrick _LIBCPP_INLINE_VISIBILITY 43246035553Spatrick __hash_map_const_iterator(_HashIterator __i) : __i_(__i) {} 43346035553Spatrick _LIBCPP_INLINE_VISIBILITY 43446035553Spatrick __hash_map_const_iterator( 43546035553Spatrick __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) 43646035553Spatrick : __i_(__i.__i_) {} 43746035553Spatrick 43846035553Spatrick _LIBCPP_INLINE_VISIBILITY 43946035553Spatrick reference operator*() const {return *operator->();} 44046035553Spatrick _LIBCPP_INLINE_VISIBILITY 44146035553Spatrick pointer operator->() const {return (pointer)__i_.operator->();} 44246035553Spatrick 44346035553Spatrick _LIBCPP_INLINE_VISIBILITY 44446035553Spatrick __hash_map_const_iterator& operator++() {++__i_; return *this;} 44546035553Spatrick _LIBCPP_INLINE_VISIBILITY 44646035553Spatrick __hash_map_const_iterator operator++(int) 44746035553Spatrick { 44846035553Spatrick __hash_map_const_iterator __t(*this); 44946035553Spatrick ++(*this); 45046035553Spatrick return __t; 45146035553Spatrick } 45246035553Spatrick 45346035553Spatrick friend _LIBCPP_INLINE_VISIBILITY 45446035553Spatrick bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 45546035553Spatrick {return __x.__i_ == __y.__i_;} 45646035553Spatrick friend _LIBCPP_INLINE_VISIBILITY 45746035553Spatrick bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 45846035553Spatrick {return __x.__i_ != __y.__i_;} 45946035553Spatrick 46046035553Spatrick template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map; 46146035553Spatrick template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap; 46246035553Spatrick template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; 46346035553Spatrick template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; 46446035553Spatrick}; 46546035553Spatrick 46646035553Spatricktemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = std::equal_to<_Key>, 46746035553Spatrick class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > 46846035553Spatrickclass _LIBCPP_TEMPLATE_VIS hash_map 46946035553Spatrick{ 47046035553Spatrickpublic: 47146035553Spatrick // types 47246035553Spatrick typedef _Key key_type; 47346035553Spatrick typedef _Tp mapped_type; 47446035553Spatrick typedef _Tp data_type; 47546035553Spatrick typedef _Hash hasher; 47646035553Spatrick typedef _Pred key_equal; 47746035553Spatrick typedef _Alloc allocator_type; 47846035553Spatrick typedef std::pair<const key_type, mapped_type> value_type; 47946035553Spatrick typedef value_type& reference; 48046035553Spatrick typedef const value_type& const_reference; 48146035553Spatrick 48246035553Spatrickprivate: 48346035553Spatrick typedef std::pair<key_type, mapped_type> __value_type; 48446035553Spatrick typedef __hash_map_hasher<__value_type, hasher> __hasher; 48546035553Spatrick typedef __hash_map_equal<__value_type, key_equal> __key_equal; 486*4bdff4beSrobert typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type; 48746035553Spatrick 48846035553Spatrick typedef std::__hash_table<__value_type, __hasher, 48946035553Spatrick __key_equal, __allocator_type> __table; 49046035553Spatrick 49146035553Spatrick __table __table_; 49246035553Spatrick 49346035553Spatrick typedef typename __table::__node_pointer __node_pointer; 49446035553Spatrick typedef typename __table::__node_const_pointer __node_const_pointer; 49546035553Spatrick typedef typename __table::__node_traits __node_traits; 49646035553Spatrick typedef typename __table::__node_allocator __node_allocator; 49746035553Spatrick typedef typename __table::__node __node; 49846035553Spatrick typedef __hash_map_node_destructor<__node_allocator> _Dp; 49946035553Spatrick typedef std::unique_ptr<__node, _Dp> __node_holder; 50046035553Spatrick typedef std::allocator_traits<allocator_type> __alloc_traits; 50146035553Spatrickpublic: 50246035553Spatrick typedef typename __alloc_traits::pointer pointer; 50346035553Spatrick typedef typename __alloc_traits::const_pointer const_pointer; 50446035553Spatrick typedef typename __alloc_traits::size_type size_type; 50546035553Spatrick typedef typename __alloc_traits::difference_type difference_type; 50646035553Spatrick 50746035553Spatrick typedef __hash_map_iterator<typename __table::iterator> iterator; 50846035553Spatrick typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 50946035553Spatrick 51046035553Spatrick _LIBCPP_INLINE_VISIBILITY hash_map() { } 51146035553Spatrick explicit hash_map(size_type __n, const hasher& __hf = hasher(), 51246035553Spatrick const key_equal& __eql = key_equal()); 51346035553Spatrick hash_map(size_type __n, const hasher& __hf, 51446035553Spatrick const key_equal& __eql, 51546035553Spatrick const allocator_type& __a); 51646035553Spatrick template <class _InputIterator> 51746035553Spatrick hash_map(_InputIterator __first, _InputIterator __last); 51846035553Spatrick template <class _InputIterator> 51946035553Spatrick hash_map(_InputIterator __first, _InputIterator __last, 52046035553Spatrick size_type __n, const hasher& __hf = hasher(), 52146035553Spatrick const key_equal& __eql = key_equal()); 52246035553Spatrick template <class _InputIterator> 52346035553Spatrick hash_map(_InputIterator __first, _InputIterator __last, 52446035553Spatrick size_type __n, const hasher& __hf, 52546035553Spatrick const key_equal& __eql, 52646035553Spatrick const allocator_type& __a); 52746035553Spatrick hash_map(const hash_map& __u); 52846035553Spatrick 52946035553Spatrick _LIBCPP_INLINE_VISIBILITY 53046035553Spatrick allocator_type get_allocator() const 53146035553Spatrick {return allocator_type(__table_.__node_alloc());} 53246035553Spatrick 53346035553Spatrick _LIBCPP_INLINE_VISIBILITY 53446035553Spatrick bool empty() const {return __table_.size() == 0;} 53546035553Spatrick _LIBCPP_INLINE_VISIBILITY 53646035553Spatrick size_type size() const {return __table_.size();} 53746035553Spatrick _LIBCPP_INLINE_VISIBILITY 53846035553Spatrick size_type max_size() const {return __table_.max_size();} 53946035553Spatrick 54046035553Spatrick _LIBCPP_INLINE_VISIBILITY 54146035553Spatrick iterator begin() {return __table_.begin();} 54246035553Spatrick _LIBCPP_INLINE_VISIBILITY 54346035553Spatrick iterator end() {return __table_.end();} 54446035553Spatrick _LIBCPP_INLINE_VISIBILITY 54546035553Spatrick const_iterator begin() const {return __table_.begin();} 54646035553Spatrick _LIBCPP_INLINE_VISIBILITY 54746035553Spatrick const_iterator end() const {return __table_.end();} 54846035553Spatrick 54946035553Spatrick _LIBCPP_INLINE_VISIBILITY 55046035553Spatrick std::pair<iterator, bool> insert(const value_type& __x) 55146035553Spatrick {return __table_.__insert_unique(__x);} 55246035553Spatrick _LIBCPP_INLINE_VISIBILITY 55346035553Spatrick iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;} 55446035553Spatrick template <class _InputIterator> 55546035553Spatrick _LIBCPP_INLINE_VISIBILITY 55646035553Spatrick void insert(_InputIterator __first, _InputIterator __last); 55746035553Spatrick 55846035553Spatrick _LIBCPP_INLINE_VISIBILITY 55946035553Spatrick void erase(const_iterator __p) {__table_.erase(__p.__i_);} 56046035553Spatrick _LIBCPP_INLINE_VISIBILITY 56146035553Spatrick size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 56246035553Spatrick _LIBCPP_INLINE_VISIBILITY 56346035553Spatrick void erase(const_iterator __first, const_iterator __last) 56446035553Spatrick {__table_.erase(__first.__i_, __last.__i_);} 56546035553Spatrick _LIBCPP_INLINE_VISIBILITY 56646035553Spatrick void clear() {__table_.clear();} 56746035553Spatrick 56846035553Spatrick _LIBCPP_INLINE_VISIBILITY 56946035553Spatrick void swap(hash_map& __u) {__table_.swap(__u.__table_);} 57046035553Spatrick 57146035553Spatrick _LIBCPP_INLINE_VISIBILITY 57246035553Spatrick hasher hash_funct() const 57346035553Spatrick {return __table_.hash_function().hash_function();} 57446035553Spatrick _LIBCPP_INLINE_VISIBILITY 57546035553Spatrick key_equal key_eq() const 57646035553Spatrick {return __table_.key_eq().key_eq();} 57746035553Spatrick 57846035553Spatrick _LIBCPP_INLINE_VISIBILITY 57946035553Spatrick iterator find(const key_type& __k) {return __table_.find(__k);} 58046035553Spatrick _LIBCPP_INLINE_VISIBILITY 58146035553Spatrick const_iterator find(const key_type& __k) const {return __table_.find(__k);} 58246035553Spatrick _LIBCPP_INLINE_VISIBILITY 58346035553Spatrick size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 58446035553Spatrick _LIBCPP_INLINE_VISIBILITY 58546035553Spatrick std::pair<iterator, iterator> equal_range(const key_type& __k) 58646035553Spatrick {return __table_.__equal_range_unique(__k);} 58746035553Spatrick _LIBCPP_INLINE_VISIBILITY 58846035553Spatrick std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 58946035553Spatrick {return __table_.__equal_range_unique(__k);} 59046035553Spatrick 59146035553Spatrick mapped_type& operator[](const key_type& __k); 59246035553Spatrick 59346035553Spatrick _LIBCPP_INLINE_VISIBILITY 59446035553Spatrick size_type bucket_count() const {return __table_.bucket_count();} 59546035553Spatrick _LIBCPP_INLINE_VISIBILITY 59646035553Spatrick size_type max_bucket_count() const {return __table_.max_bucket_count();} 59746035553Spatrick 59846035553Spatrick _LIBCPP_INLINE_VISIBILITY 59946035553Spatrick size_type elems_in_bucket(size_type __n) const 60046035553Spatrick {return __table_.bucket_size(__n);} 60146035553Spatrick 60246035553Spatrick _LIBCPP_INLINE_VISIBILITY 603*4bdff4beSrobert void resize(size_type __n) {__table_.__rehash_unique(__n);} 60446035553Spatrick 60546035553Spatrickprivate: 60646035553Spatrick __node_holder __construct_node(const key_type& __k); 60746035553Spatrick}; 60846035553Spatrick 60946035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 61046035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 61146035553Spatrick size_type __n, const hasher& __hf, const key_equal& __eql) 61246035553Spatrick : __table_(__hf, __eql) 61346035553Spatrick{ 614*4bdff4beSrobert __table_.__rehash_unique(__n); 61546035553Spatrick} 61646035553Spatrick 61746035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 61846035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 61946035553Spatrick size_type __n, const hasher& __hf, const key_equal& __eql, 62046035553Spatrick const allocator_type& __a) 62146035553Spatrick : __table_(__hf, __eql, __a) 62246035553Spatrick{ 623*4bdff4beSrobert __table_.__rehash_unique(__n); 62446035553Spatrick} 62546035553Spatrick 62646035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 62746035553Spatricktemplate <class _InputIterator> 62846035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 62946035553Spatrick _InputIterator __first, _InputIterator __last) 63046035553Spatrick{ 63146035553Spatrick insert(__first, __last); 63246035553Spatrick} 63346035553Spatrick 63446035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 63546035553Spatricktemplate <class _InputIterator> 63646035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 63746035553Spatrick _InputIterator __first, _InputIterator __last, size_type __n, 63846035553Spatrick const hasher& __hf, const key_equal& __eql) 63946035553Spatrick : __table_(__hf, __eql) 64046035553Spatrick{ 641*4bdff4beSrobert __table_.__rehash_unique(__n); 64246035553Spatrick insert(__first, __last); 64346035553Spatrick} 64446035553Spatrick 64546035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 64646035553Spatricktemplate <class _InputIterator> 64746035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 64846035553Spatrick _InputIterator __first, _InputIterator __last, size_type __n, 64946035553Spatrick const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 65046035553Spatrick : __table_(__hf, __eql, __a) 65146035553Spatrick{ 652*4bdff4beSrobert __table_.__rehash_unique(__n); 65346035553Spatrick insert(__first, __last); 65446035553Spatrick} 65546035553Spatrick 65646035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 65746035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 65846035553Spatrick const hash_map& __u) 65946035553Spatrick : __table_(__u.__table_) 66046035553Spatrick{ 661*4bdff4beSrobert __table_.__rehash_unique(__u.bucket_count()); 66246035553Spatrick insert(__u.begin(), __u.end()); 66346035553Spatrick} 66446035553Spatrick 66546035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 66646035553Spatricktypename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder 66746035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) 66846035553Spatrick{ 66946035553Spatrick __node_allocator& __na = __table_.__node_alloc(); 67046035553Spatrick __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 67146035553Spatrick __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k); 67246035553Spatrick __h.get_deleter().__first_constructed = true; 67346035553Spatrick __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); 67446035553Spatrick __h.get_deleter().__second_constructed = true; 67576d0caaeSpatrick return __h; 67646035553Spatrick} 67746035553Spatrick 67846035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 67946035553Spatricktemplate <class _InputIterator> 68046035553Spatrickinline 68146035553Spatrickvoid 68246035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 68346035553Spatrick _InputIterator __last) 68446035553Spatrick{ 68546035553Spatrick for (; __first != __last; ++__first) 68646035553Spatrick __table_.__insert_unique(*__first); 68746035553Spatrick} 68846035553Spatrick 68946035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 69046035553Spatrick_Tp& 69146035553Spatrickhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) 69246035553Spatrick{ 69346035553Spatrick iterator __i = find(__k); 69446035553Spatrick if (__i != end()) 69546035553Spatrick return __i->second; 69646035553Spatrick __node_holder __h = __construct_node(__k); 69746035553Spatrick std::pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); 69846035553Spatrick __h.release(); 69946035553Spatrick return __r.first->second; 70046035553Spatrick} 70146035553Spatrick 70246035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 70346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY 70446035553Spatrickvoid 70546035553Spatrickswap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 70646035553Spatrick hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 70746035553Spatrick{ 70846035553Spatrick __x.swap(__y); 70946035553Spatrick} 71046035553Spatrick 71146035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 712*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI bool 71346035553Spatrickoperator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 71446035553Spatrick const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 71546035553Spatrick{ 71646035553Spatrick if (__x.size() != __y.size()) 71746035553Spatrick return false; 71846035553Spatrick typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 71946035553Spatrick const_iterator; 72046035553Spatrick for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 72146035553Spatrick __i != __ex; ++__i) 72246035553Spatrick { 72346035553Spatrick const_iterator __j = __y.find(__i->first); 72446035553Spatrick if (__j == __ey || !(*__i == *__j)) 72546035553Spatrick return false; 72646035553Spatrick } 72746035553Spatrick return true; 72846035553Spatrick} 72946035553Spatrick 73046035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 73146035553Spatrickinline _LIBCPP_INLINE_VISIBILITY 73246035553Spatrickbool 73346035553Spatrickoperator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 73446035553Spatrick const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 73546035553Spatrick{ 73646035553Spatrick return !(__x == __y); 73746035553Spatrick} 73846035553Spatrick 73946035553Spatricktemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = std::equal_to<_Key>, 74046035553Spatrick class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > 74146035553Spatrickclass _LIBCPP_TEMPLATE_VIS hash_multimap 74246035553Spatrick{ 74346035553Spatrickpublic: 74446035553Spatrick // types 74546035553Spatrick typedef _Key key_type; 74646035553Spatrick typedef _Tp mapped_type; 74746035553Spatrick typedef _Tp data_type; 74846035553Spatrick typedef _Hash hasher; 74946035553Spatrick typedef _Pred key_equal; 75046035553Spatrick typedef _Alloc allocator_type; 75146035553Spatrick typedef std::pair<const key_type, mapped_type> value_type; 75246035553Spatrick typedef value_type& reference; 75346035553Spatrick typedef const value_type& const_reference; 75446035553Spatrick 75546035553Spatrickprivate: 75646035553Spatrick typedef std::pair<key_type, mapped_type> __value_type; 75746035553Spatrick typedef __hash_map_hasher<__value_type, hasher> __hasher; 75846035553Spatrick typedef __hash_map_equal<__value_type, key_equal> __key_equal; 759*4bdff4beSrobert typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type; 76046035553Spatrick 76146035553Spatrick typedef std::__hash_table<__value_type, __hasher, 76246035553Spatrick __key_equal, __allocator_type> __table; 76346035553Spatrick 76446035553Spatrick __table __table_; 76546035553Spatrick 76646035553Spatrick typedef typename __table::__node_traits __node_traits; 76746035553Spatrick typedef typename __table::__node_allocator __node_allocator; 76846035553Spatrick typedef typename __table::__node __node; 76946035553Spatrick typedef __hash_map_node_destructor<__node_allocator> _Dp; 77046035553Spatrick typedef std::unique_ptr<__node, _Dp> __node_holder; 77146035553Spatrick typedef std::allocator_traits<allocator_type> __alloc_traits; 77246035553Spatrickpublic: 77346035553Spatrick typedef typename __alloc_traits::pointer pointer; 77446035553Spatrick typedef typename __alloc_traits::const_pointer const_pointer; 77546035553Spatrick typedef typename __alloc_traits::size_type size_type; 77646035553Spatrick typedef typename __alloc_traits::difference_type difference_type; 77746035553Spatrick 77846035553Spatrick typedef __hash_map_iterator<typename __table::iterator> iterator; 77946035553Spatrick typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 78046035553Spatrick 78146035553Spatrick _LIBCPP_INLINE_VISIBILITY 78246035553Spatrick hash_multimap() { } 78346035553Spatrick explicit hash_multimap(size_type __n, const hasher& __hf = hasher(), 78446035553Spatrick const key_equal& __eql = key_equal()); 78546035553Spatrick hash_multimap(size_type __n, const hasher& __hf, 78646035553Spatrick const key_equal& __eql, 78746035553Spatrick const allocator_type& __a); 78846035553Spatrick template <class _InputIterator> 78946035553Spatrick hash_multimap(_InputIterator __first, _InputIterator __last); 79046035553Spatrick template <class _InputIterator> 79146035553Spatrick hash_multimap(_InputIterator __first, _InputIterator __last, 79246035553Spatrick size_type __n, const hasher& __hf = hasher(), 79346035553Spatrick const key_equal& __eql = key_equal()); 79446035553Spatrick template <class _InputIterator> 79546035553Spatrick hash_multimap(_InputIterator __first, _InputIterator __last, 79646035553Spatrick size_type __n, const hasher& __hf, 79746035553Spatrick const key_equal& __eql, 79846035553Spatrick const allocator_type& __a); 79946035553Spatrick hash_multimap(const hash_multimap& __u); 80046035553Spatrick 80146035553Spatrick _LIBCPP_INLINE_VISIBILITY 80246035553Spatrick allocator_type get_allocator() const 80346035553Spatrick {return allocator_type(__table_.__node_alloc());} 80446035553Spatrick 80546035553Spatrick _LIBCPP_INLINE_VISIBILITY 80646035553Spatrick bool empty() const {return __table_.size() == 0;} 80746035553Spatrick _LIBCPP_INLINE_VISIBILITY 80846035553Spatrick size_type size() const {return __table_.size();} 80946035553Spatrick _LIBCPP_INLINE_VISIBILITY 81046035553Spatrick size_type max_size() const {return __table_.max_size();} 81146035553Spatrick 81246035553Spatrick _LIBCPP_INLINE_VISIBILITY 81346035553Spatrick iterator begin() {return __table_.begin();} 81446035553Spatrick _LIBCPP_INLINE_VISIBILITY 81546035553Spatrick iterator end() {return __table_.end();} 81646035553Spatrick _LIBCPP_INLINE_VISIBILITY 81746035553Spatrick const_iterator begin() const {return __table_.begin();} 81846035553Spatrick _LIBCPP_INLINE_VISIBILITY 81946035553Spatrick const_iterator end() const {return __table_.end();} 82046035553Spatrick 82146035553Spatrick _LIBCPP_INLINE_VISIBILITY 82246035553Spatrick iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 82346035553Spatrick _LIBCPP_INLINE_VISIBILITY 82446035553Spatrick iterator insert(const_iterator, const value_type& __x) {return insert(__x);} 82546035553Spatrick template <class _InputIterator> 82646035553Spatrick _LIBCPP_INLINE_VISIBILITY 82746035553Spatrick void insert(_InputIterator __first, _InputIterator __last); 82846035553Spatrick 82946035553Spatrick _LIBCPP_INLINE_VISIBILITY 83046035553Spatrick void erase(const_iterator __p) {__table_.erase(__p.__i_);} 83146035553Spatrick _LIBCPP_INLINE_VISIBILITY 83246035553Spatrick size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 83346035553Spatrick _LIBCPP_INLINE_VISIBILITY 83446035553Spatrick void erase(const_iterator __first, const_iterator __last) 83546035553Spatrick {__table_.erase(__first.__i_, __last.__i_);} 83646035553Spatrick _LIBCPP_INLINE_VISIBILITY 83746035553Spatrick void clear() {__table_.clear();} 83846035553Spatrick 83946035553Spatrick _LIBCPP_INLINE_VISIBILITY 84046035553Spatrick void swap(hash_multimap& __u) {__table_.swap(__u.__table_);} 84146035553Spatrick 84246035553Spatrick _LIBCPP_INLINE_VISIBILITY 84346035553Spatrick hasher hash_funct() const 84446035553Spatrick {return __table_.hash_function().hash_function();} 84546035553Spatrick _LIBCPP_INLINE_VISIBILITY 84646035553Spatrick key_equal key_eq() const 84746035553Spatrick {return __table_.key_eq().key_eq();} 84846035553Spatrick 84946035553Spatrick _LIBCPP_INLINE_VISIBILITY 85046035553Spatrick iterator find(const key_type& __k) {return __table_.find(__k);} 85146035553Spatrick _LIBCPP_INLINE_VISIBILITY 85246035553Spatrick const_iterator find(const key_type& __k) const {return __table_.find(__k);} 85346035553Spatrick _LIBCPP_INLINE_VISIBILITY 85446035553Spatrick size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 85546035553Spatrick _LIBCPP_INLINE_VISIBILITY 85646035553Spatrick std::pair<iterator, iterator> equal_range(const key_type& __k) 85746035553Spatrick {return __table_.__equal_range_multi(__k);} 85846035553Spatrick _LIBCPP_INLINE_VISIBILITY 85946035553Spatrick std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 86046035553Spatrick {return __table_.__equal_range_multi(__k);} 86146035553Spatrick 86246035553Spatrick _LIBCPP_INLINE_VISIBILITY 86346035553Spatrick size_type bucket_count() const {return __table_.bucket_count();} 86446035553Spatrick _LIBCPP_INLINE_VISIBILITY 86546035553Spatrick size_type max_bucket_count() const {return __table_.max_bucket_count();} 86646035553Spatrick 86746035553Spatrick _LIBCPP_INLINE_VISIBILITY 86846035553Spatrick size_type elems_in_bucket(size_type __n) const 86946035553Spatrick {return __table_.bucket_size(__n);} 87046035553Spatrick 87146035553Spatrick _LIBCPP_INLINE_VISIBILITY 872*4bdff4beSrobert void resize(size_type __n) {__table_.__rehash_multi(__n);} 87346035553Spatrick}; 87446035553Spatrick 87546035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 87646035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 87746035553Spatrick size_type __n, const hasher& __hf, const key_equal& __eql) 87846035553Spatrick : __table_(__hf, __eql) 87946035553Spatrick{ 880*4bdff4beSrobert __table_.__rehash_multi(__n); 88146035553Spatrick} 88246035553Spatrick 88346035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 88446035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 88546035553Spatrick size_type __n, const hasher& __hf, const key_equal& __eql, 88646035553Spatrick const allocator_type& __a) 88746035553Spatrick : __table_(__hf, __eql, __a) 88846035553Spatrick{ 889*4bdff4beSrobert __table_.__rehash_multi(__n); 89046035553Spatrick} 89146035553Spatrick 89246035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 89346035553Spatricktemplate <class _InputIterator> 89446035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 89546035553Spatrick _InputIterator __first, _InputIterator __last) 89646035553Spatrick{ 89746035553Spatrick insert(__first, __last); 89846035553Spatrick} 89946035553Spatrick 90046035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 90146035553Spatricktemplate <class _InputIterator> 90246035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 90346035553Spatrick _InputIterator __first, _InputIterator __last, size_type __n, 90446035553Spatrick const hasher& __hf, const key_equal& __eql) 90546035553Spatrick : __table_(__hf, __eql) 90646035553Spatrick{ 907*4bdff4beSrobert __table_.__rehash_multi(__n); 90846035553Spatrick insert(__first, __last); 90946035553Spatrick} 91046035553Spatrick 91146035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 91246035553Spatricktemplate <class _InputIterator> 91346035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 91446035553Spatrick _InputIterator __first, _InputIterator __last, size_type __n, 91546035553Spatrick const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 91646035553Spatrick : __table_(__hf, __eql, __a) 91746035553Spatrick{ 918*4bdff4beSrobert __table_.__rehash_multi(__n); 91946035553Spatrick insert(__first, __last); 92046035553Spatrick} 92146035553Spatrick 92246035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 92346035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 92446035553Spatrick const hash_multimap& __u) 92546035553Spatrick : __table_(__u.__table_) 92646035553Spatrick{ 927*4bdff4beSrobert __table_.__rehash_multi(__u.bucket_count()); 92846035553Spatrick insert(__u.begin(), __u.end()); 92946035553Spatrick} 93046035553Spatrick 93146035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 93246035553Spatricktemplate <class _InputIterator> 93346035553Spatrickinline 93446035553Spatrickvoid 93546035553Spatrickhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 93646035553Spatrick _InputIterator __last) 93746035553Spatrick{ 93846035553Spatrick for (; __first != __last; ++__first) 93946035553Spatrick __table_.__insert_multi(*__first); 94046035553Spatrick} 94146035553Spatrick 94246035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 94346035553Spatrickinline _LIBCPP_INLINE_VISIBILITY 94446035553Spatrickvoid 94546035553Spatrickswap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 94646035553Spatrick hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 94746035553Spatrick{ 94846035553Spatrick __x.swap(__y); 94946035553Spatrick} 95046035553Spatrick 95146035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 952*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI bool 95346035553Spatrickoperator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 95446035553Spatrick const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 95546035553Spatrick{ 95646035553Spatrick if (__x.size() != __y.size()) 95746035553Spatrick return false; 95846035553Spatrick typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 95946035553Spatrick const_iterator; 96046035553Spatrick typedef std::pair<const_iterator, const_iterator> _EqRng; 96146035553Spatrick for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 96246035553Spatrick { 96346035553Spatrick _EqRng __xeq = __x.equal_range(__i->first); 96446035553Spatrick _EqRng __yeq = __y.equal_range(__i->first); 96546035553Spatrick if (_VSTD::distance(__xeq.first, __xeq.second) != 96646035553Spatrick _VSTD::distance(__yeq.first, __yeq.second) || 96746035553Spatrick !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 96846035553Spatrick return false; 96946035553Spatrick __i = __xeq.second; 97046035553Spatrick } 97146035553Spatrick return true; 97246035553Spatrick} 97346035553Spatrick 97446035553Spatricktemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 97546035553Spatrickinline _LIBCPP_INLINE_VISIBILITY 97646035553Spatrickbool 97746035553Spatrickoperator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 97846035553Spatrick const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 97946035553Spatrick{ 98046035553Spatrick return !(__x == __y); 98146035553Spatrick} 98246035553Spatrick 983*4bdff4beSrobert} // namespace __gnu_cxx 984*4bdff4beSrobert 985*4bdff4beSrobert#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 986*4bdff4beSrobert# include <concepts> 987*4bdff4beSrobert# include <iterator> 988*4bdff4beSrobert#endif 98946035553Spatrick 99046035553Spatrick#endif // _LIBCPP_HASH_MAP 991