hash_map revision 288943
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===-------------------------- hash_map ----------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_HASH_MAP 12227825Stheraven#define _LIBCPP_HASH_MAP 13227825Stheraven 14227825Stheraven/* 15227825Stheraven 16227825Stheraven hash_map synopsis 17227825Stheraven 18227825Stheravennamespace __gnu_cxx 19227825Stheraven{ 20227825Stheraven 21227825Stheraventemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 22227825Stheraven class Alloc = allocator<pair<const Key, T>>> 23227825Stheravenclass hash_map 24227825Stheraven{ 25227825Stheravenpublic: 26227825Stheraven // types 27227825Stheraven typedef Key key_type; 28227825Stheraven typedef T mapped_type; 29227825Stheraven typedef Hash hasher; 30227825Stheraven typedef Pred key_equal; 31227825Stheraven typedef Alloc allocator_type; 32227825Stheraven typedef pair<const key_type, mapped_type> value_type; 33227825Stheraven typedef value_type& reference; 34227825Stheraven typedef const value_type& const_reference; 35227825Stheraven typedef typename allocator_traits<allocator_type>::pointer pointer; 36227825Stheraven typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 37227825Stheraven typedef typename allocator_traits<allocator_type>::size_type size_type; 38227825Stheraven typedef typename allocator_traits<allocator_type>::difference_type difference_type; 39227825Stheraven 40227825Stheraven typedef /unspecified/ iterator; 41227825Stheraven typedef /unspecified/ const_iterator; 42227825Stheraven 43227825Stheraven explicit hash_map(size_type n = 193, const hasher& hf = hasher(), 44227825Stheraven const key_equal& eql = key_equal(), 45227825Stheraven const allocator_type& a = allocator_type()); 46227825Stheraven template <class InputIterator> 47227825Stheraven hash_map(InputIterator f, InputIterator l, 48227825Stheraven size_type n = 193, const hasher& hf = hasher(), 49227825Stheraven const key_equal& eql = key_equal(), 50227825Stheraven const allocator_type& a = allocator_type()); 51227825Stheraven hash_map(const hash_map&); 52227825Stheraven ~hash_map(); 53227825Stheraven hash_map& operator=(const hash_map&); 54227825Stheraven 55227825Stheraven allocator_type get_allocator() const; 56227825Stheraven 57227825Stheraven bool empty() const; 58227825Stheraven size_type size() const; 59227825Stheraven size_type max_size() const; 60227825Stheraven 61227825Stheraven iterator begin(); 62227825Stheraven iterator end(); 63227825Stheraven const_iterator begin() const; 64227825Stheraven const_iterator end() const; 65227825Stheraven 66227825Stheraven pair<iterator, bool> insert(const value_type& obj); 67227825Stheraven template <class InputIterator> 68227825Stheraven void insert(InputIterator first, InputIterator last); 69227825Stheraven 70227825Stheraven void erase(const_iterator position); 71227825Stheraven size_type erase(const key_type& k); 72227825Stheraven void erase(const_iterator first, const_iterator last); 73227825Stheraven void clear(); 74227825Stheraven 75227825Stheraven void swap(hash_map&); 76227825Stheraven 77227825Stheraven hasher hash_funct() const; 78227825Stheraven key_equal key_eq() const; 79227825Stheraven 80227825Stheraven iterator find(const key_type& k); 81227825Stheraven const_iterator find(const key_type& k) const; 82227825Stheraven size_type count(const key_type& k) const; 83227825Stheraven pair<iterator, iterator> equal_range(const key_type& k); 84227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 85227825Stheraven 86227825Stheraven mapped_type& operator[](const key_type& k); 87227825Stheraven 88227825Stheraven size_type bucket_count() const; 89227825Stheraven size_type max_bucket_count() const; 90227825Stheraven 91227825Stheraven size_type elems_in_bucket(size_type n) const; 92227825Stheraven 93227825Stheraven void resize(size_type n); 94227825Stheraven}; 95227825Stheraven 96227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 97227825Stheraven void swap(hash_map<Key, T, Hash, Pred, Alloc>& x, 98227825Stheraven hash_map<Key, T, Hash, Pred, Alloc>& y); 99227825Stheraven 100227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 101227825Stheraven bool 102227825Stheraven operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x, 103227825Stheraven const hash_map<Key, T, Hash, Pred, Alloc>& y); 104227825Stheraven 105227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 106227825Stheraven bool 107227825Stheraven operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x, 108227825Stheraven const hash_map<Key, T, Hash, Pred, Alloc>& y); 109227825Stheraven 110227825Stheraventemplate <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 111227825Stheraven class Alloc = allocator<pair<const Key, T>>> 112227825Stheravenclass hash_multimap 113227825Stheraven{ 114227825Stheravenpublic: 115227825Stheraven // types 116227825Stheraven typedef Key key_type; 117227825Stheraven typedef T mapped_type; 118227825Stheraven typedef Hash hasher; 119227825Stheraven typedef Pred key_equal; 120227825Stheraven typedef Alloc allocator_type; 121227825Stheraven typedef pair<const key_type, mapped_type> value_type; 122227825Stheraven typedef value_type& reference; 123227825Stheraven typedef const value_type& const_reference; 124227825Stheraven typedef typename allocator_traits<allocator_type>::pointer pointer; 125227825Stheraven typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; 126227825Stheraven typedef typename allocator_traits<allocator_type>::size_type size_type; 127227825Stheraven typedef typename allocator_traits<allocator_type>::difference_type difference_type; 128227825Stheraven 129227825Stheraven typedef /unspecified/ iterator; 130227825Stheraven typedef /unspecified/ const_iterator; 131227825Stheraven 132227825Stheraven explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(), 133227825Stheraven const key_equal& eql = key_equal(), 134227825Stheraven const allocator_type& a = allocator_type()); 135227825Stheraven template <class InputIterator> 136227825Stheraven hash_multimap(InputIterator f, InputIterator l, 137227825Stheraven size_type n = 193, const hasher& hf = hasher(), 138227825Stheraven const key_equal& eql = key_equal(), 139227825Stheraven const allocator_type& a = allocator_type()); 140227825Stheraven explicit hash_multimap(const allocator_type&); 141227825Stheraven hash_multimap(const hash_multimap&); 142227825Stheraven ~hash_multimap(); 143227825Stheraven hash_multimap& operator=(const hash_multimap&); 144227825Stheraven 145227825Stheraven allocator_type get_allocator() const; 146227825Stheraven 147227825Stheraven bool empty() const; 148227825Stheraven size_type size() const; 149227825Stheraven size_type max_size() const; 150227825Stheraven 151227825Stheraven iterator begin(); 152227825Stheraven iterator end(); 153227825Stheraven const_iterator begin() const; 154227825Stheraven const_iterator end() const; 155227825Stheraven 156227825Stheraven iterator insert(const value_type& obj); 157227825Stheraven template <class InputIterator> 158227825Stheraven void insert(InputIterator first, InputIterator last); 159227825Stheraven 160227825Stheraven void erase(const_iterator position); 161227825Stheraven size_type erase(const key_type& k); 162227825Stheraven void erase(const_iterator first, const_iterator last); 163227825Stheraven void clear(); 164227825Stheraven 165227825Stheraven void swap(hash_multimap&); 166227825Stheraven 167227825Stheraven hasher hash_funct() const; 168227825Stheraven key_equal key_eq() const; 169227825Stheraven 170227825Stheraven iterator find(const key_type& k); 171227825Stheraven const_iterator find(const key_type& k) const; 172227825Stheraven size_type count(const key_type& k) const; 173227825Stheraven pair<iterator, iterator> equal_range(const key_type& k); 174227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& k) const; 175227825Stheraven 176227825Stheraven size_type bucket_count() const; 177227825Stheraven size_type max_bucket_count() const; 178227825Stheraven 179227825Stheraven size_type elems_in_bucket(size_type n) const; 180227825Stheraven 181227825Stheraven void resize(size_type n); 182227825Stheraven}; 183227825Stheraven 184227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 185227825Stheraven void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x, 186227825Stheraven hash_multimap<Key, T, Hash, Pred, Alloc>& y); 187227825Stheraven 188227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 189227825Stheraven bool 190227825Stheraven operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x, 191227825Stheraven const hash_multimap<Key, T, Hash, Pred, Alloc>& y); 192227825Stheraven 193227825Stheraventemplate <class Key, class T, class Hash, class Pred, class Alloc> 194227825Stheraven bool 195227825Stheraven operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x, 196227825Stheraven const hash_multimap<Key, T, Hash, Pred, Alloc>& y); 197227825Stheraven 198227825Stheraven} // __gnu_cxx 199227825Stheraven 200227825Stheraven*/ 201227825Stheraven 202227825Stheraven#include <__config> 203227825Stheraven#include <__hash_table> 204227825Stheraven#include <functional> 205227825Stheraven#include <stdexcept> 206288943Sdim#include <type_traits> 207227825Stheraven#include <ext/__hash> 208227825Stheraven 209227825Stheraven#if __DEPRECATED 210261272Sdim#if defined(_MSC_VER) && ! defined(__clang__) 211261272Sdim _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") 212261272Sdim#else 213261272Sdim# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> 214227825Stheraven#endif 215261272Sdim#endif 216227825Stheraven 217288943Sdim#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 218227825Stheraven#pragma GCC system_header 219288943Sdim#endif 220227825Stheraven 221227825Stheravennamespace __gnu_cxx { 222227825Stheraven 223227825Stheravenusing namespace std; 224227825Stheraven 225288943Sdimtemplate <class _Tp, class _Hash, 226288943Sdim bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value 227232924Stheraven > 228227825Stheravenclass __hash_map_hasher 229227825Stheraven : private _Hash 230227825Stheraven{ 231227825Stheravenpublic: 232227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {} 233227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {} 234227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;} 235227825Stheraven _LIBCPP_INLINE_VISIBILITY 236227825Stheraven size_t operator()(const _Tp& __x) const 237227825Stheraven {return static_cast<const _Hash&>(*this)(__x.first);} 238227825Stheraven _LIBCPP_INLINE_VISIBILITY 239227825Stheraven size_t operator()(const typename _Tp::first_type& __x) const 240227825Stheraven {return static_cast<const _Hash&>(*this)(__x);} 241227825Stheraven}; 242227825Stheraven 243227825Stheraventemplate <class _Tp, class _Hash> 244227825Stheravenclass __hash_map_hasher<_Tp, _Hash, false> 245227825Stheraven{ 246227825Stheraven _Hash __hash_; 247227825Stheravenpublic: 248227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {} 249227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {} 250227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;} 251227825Stheraven _LIBCPP_INLINE_VISIBILITY 252227825Stheraven size_t operator()(const _Tp& __x) const 253227825Stheraven {return __hash_(__x.first);} 254227825Stheraven _LIBCPP_INLINE_VISIBILITY 255227825Stheraven size_t operator()(const typename _Tp::first_type& __x) const 256227825Stheraven {return __hash_(__x);} 257227825Stheraven}; 258227825Stheraven 259288943Sdimtemplate <class _Tp, class _Pred, 260288943Sdim bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value 261232924Stheraven > 262227825Stheravenclass __hash_map_equal 263227825Stheraven : private _Pred 264227825Stheraven{ 265227825Stheravenpublic: 266227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {} 267227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {} 268227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;} 269227825Stheraven _LIBCPP_INLINE_VISIBILITY 270227825Stheraven bool operator()(const _Tp& __x, const _Tp& __y) const 271227825Stheraven {return static_cast<const _Pred&>(*this)(__x.first, __y.first);} 272227825Stheraven _LIBCPP_INLINE_VISIBILITY 273227825Stheraven bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 274227825Stheraven {return static_cast<const _Pred&>(*this)(__x, __y.first);} 275227825Stheraven _LIBCPP_INLINE_VISIBILITY 276227825Stheraven bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 277227825Stheraven {return static_cast<const _Pred&>(*this)(__x.first, __y);} 278227825Stheraven _LIBCPP_INLINE_VISIBILITY 279227825Stheraven bool operator()(const typename _Tp::first_type& __x, 280227825Stheraven const typename _Tp::first_type& __y) const 281227825Stheraven {return static_cast<const _Pred&>(*this)(__x, __y);} 282227825Stheraven}; 283227825Stheraven 284227825Stheraventemplate <class _Tp, class _Pred> 285227825Stheravenclass __hash_map_equal<_Tp, _Pred, false> 286227825Stheraven{ 287227825Stheraven _Pred __pred_; 288227825Stheravenpublic: 289227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {} 290227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {} 291227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;} 292227825Stheraven _LIBCPP_INLINE_VISIBILITY 293227825Stheraven bool operator()(const _Tp& __x, const _Tp& __y) const 294227825Stheraven {return __pred_(__x.first, __y.first);} 295227825Stheraven _LIBCPP_INLINE_VISIBILITY 296227825Stheraven bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 297227825Stheraven {return __pred_(__x, __y.first);} 298227825Stheraven _LIBCPP_INLINE_VISIBILITY 299227825Stheraven bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 300227825Stheraven {return __pred_(__x.first, __y);} 301227825Stheraven _LIBCPP_INLINE_VISIBILITY 302227825Stheraven bool operator()(const typename _Tp::first_type& __x, 303227825Stheraven const typename _Tp::first_type& __y) const 304227825Stheraven {return __pred_(__x, __y);} 305227825Stheraven}; 306227825Stheraven 307227825Stheraventemplate <class _Alloc> 308227825Stheravenclass __hash_map_node_destructor 309227825Stheraven{ 310227825Stheraven typedef _Alloc allocator_type; 311227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 312227825Stheraven typedef typename __alloc_traits::value_type::value_type value_type; 313227825Stheravenpublic: 314227825Stheraven typedef typename __alloc_traits::pointer pointer; 315227825Stheravenprivate: 316227825Stheraven typedef typename value_type::first_type first_type; 317227825Stheraven typedef typename value_type::second_type second_type; 318227825Stheraven 319227825Stheraven allocator_type& __na_; 320227825Stheraven 321227825Stheraven __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); 322227825Stheraven 323227825Stheravenpublic: 324227825Stheraven bool __first_constructed; 325227825Stheraven bool __second_constructed; 326227825Stheraven 327227825Stheraven _LIBCPP_INLINE_VISIBILITY 328227825Stheraven explicit __hash_map_node_destructor(allocator_type& __na) 329227825Stheraven : __na_(__na), 330227825Stheraven __first_constructed(false), 331227825Stheraven __second_constructed(false) 332227825Stheraven {} 333227825Stheraven 334227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 335227825Stheraven _LIBCPP_INLINE_VISIBILITY 336227825Stheraven __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) 337227825Stheraven : __na_(__x.__na_), 338227825Stheraven __first_constructed(__x.__value_constructed), 339227825Stheraven __second_constructed(__x.__value_constructed) 340227825Stheraven { 341227825Stheraven __x.__value_constructed = false; 342227825Stheraven } 343227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 344227825Stheraven _LIBCPP_INLINE_VISIBILITY 345227825Stheraven __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) 346227825Stheraven : __na_(__x.__na_), 347227825Stheraven __first_constructed(__x.__value_constructed), 348227825Stheraven __second_constructed(__x.__value_constructed) 349227825Stheraven { 350227825Stheraven const_cast<bool&>(__x.__value_constructed) = false; 351227825Stheraven } 352227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 353227825Stheraven 354227825Stheraven _LIBCPP_INLINE_VISIBILITY 355227825Stheraven void operator()(pointer __p) 356227825Stheraven { 357227825Stheraven if (__second_constructed) 358227825Stheraven __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second)); 359227825Stheraven if (__first_constructed) 360227825Stheraven __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first)); 361227825Stheraven if (__p) 362227825Stheraven __alloc_traits::deallocate(__na_, __p, 1); 363227825Stheraven } 364227825Stheraven}; 365227825Stheraven 366227825Stheraventemplate <class _HashIterator> 367261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator 368227825Stheraven{ 369227825Stheraven _HashIterator __i_; 370227825Stheraven 371227825Stheraven typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits; 372227825Stheraven typedef const typename _HashIterator::value_type::first_type key_type; 373227825Stheraven typedef typename _HashIterator::value_type::second_type mapped_type; 374227825Stheravenpublic: 375227825Stheraven typedef forward_iterator_tag iterator_category; 376227825Stheraven typedef pair<key_type, mapped_type> value_type; 377227825Stheraven typedef typename _HashIterator::difference_type difference_type; 378227825Stheraven typedef value_type& reference; 379227825Stheraven typedef typename __pointer_traits::template 380227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 381227825Stheraven rebind<value_type> 382227825Stheraven#else 383227825Stheraven rebind<value_type>::other 384227825Stheraven#endif 385227825Stheraven pointer; 386227825Stheraven 387227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {} 388227825Stheraven 389227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {} 390227825Stheraven 391227825Stheraven _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();} 392227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();} 393227825Stheraven 394227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;} 395227825Stheraven _LIBCPP_INLINE_VISIBILITY 396227825Stheraven __hash_map_iterator operator++(int) 397227825Stheraven { 398227825Stheraven __hash_map_iterator __t(*this); 399227825Stheraven ++(*this); 400227825Stheraven return __t; 401227825Stheraven } 402227825Stheraven 403227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 404227825Stheraven bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 405227825Stheraven {return __x.__i_ == __y.__i_;} 406227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 407227825Stheraven bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 408227825Stheraven {return __x.__i_ != __y.__i_;} 409227825Stheraven 410261272Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; 411261272Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; 412261272Sdim template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; 413261272Sdim template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; 414261272Sdim template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; 415227825Stheraven}; 416227825Stheraven 417227825Stheraventemplate <class _HashIterator> 418261272Sdimclass _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator 419227825Stheraven{ 420227825Stheraven _HashIterator __i_; 421227825Stheraven 422227825Stheraven typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits; 423227825Stheraven typedef const typename _HashIterator::value_type::first_type key_type; 424227825Stheraven typedef typename _HashIterator::value_type::second_type mapped_type; 425227825Stheravenpublic: 426227825Stheraven typedef forward_iterator_tag iterator_category; 427227825Stheraven typedef pair<key_type, mapped_type> value_type; 428227825Stheraven typedef typename _HashIterator::difference_type difference_type; 429227825Stheraven typedef const value_type& reference; 430227825Stheraven typedef typename __pointer_traits::template 431227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 432276792Sdim rebind<const value_type> 433227825Stheraven#else 434276792Sdim rebind<const value_type>::other 435227825Stheraven#endif 436227825Stheraven pointer; 437227825Stheraven 438227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {} 439227825Stheraven 440227825Stheraven _LIBCPP_INLINE_VISIBILITY 441227825Stheraven __hash_map_const_iterator(_HashIterator __i) : __i_(__i) {} 442227825Stheraven _LIBCPP_INLINE_VISIBILITY 443227825Stheraven __hash_map_const_iterator( 444227825Stheraven __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) 445227825Stheraven : __i_(__i.__i_) {} 446227825Stheraven 447227825Stheraven _LIBCPP_INLINE_VISIBILITY 448227825Stheraven reference operator*() const {return *operator->();} 449227825Stheraven _LIBCPP_INLINE_VISIBILITY 450227825Stheraven pointer operator->() const {return (pointer)__i_.operator->();} 451227825Stheraven 452227825Stheraven _LIBCPP_INLINE_VISIBILITY 453227825Stheraven __hash_map_const_iterator& operator++() {++__i_; return *this;} 454227825Stheraven _LIBCPP_INLINE_VISIBILITY 455227825Stheraven __hash_map_const_iterator operator++(int) 456227825Stheraven { 457227825Stheraven __hash_map_const_iterator __t(*this); 458227825Stheraven ++(*this); 459227825Stheraven return __t; 460227825Stheraven } 461227825Stheraven 462227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 463227825Stheraven bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 464227825Stheraven {return __x.__i_ == __y.__i_;} 465227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 466227825Stheraven bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 467227825Stheraven {return __x.__i_ != __y.__i_;} 468227825Stheraven 469261272Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; 470261272Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; 471261272Sdim template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; 472261272Sdim template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; 473227825Stheraven}; 474227825Stheraven 475227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 476227825Stheraven class _Alloc = allocator<pair<const _Key, _Tp> > > 477261272Sdimclass _LIBCPP_TYPE_VIS_ONLY hash_map 478227825Stheraven{ 479227825Stheravenpublic: 480227825Stheraven // types 481227825Stheraven typedef _Key key_type; 482227825Stheraven typedef _Tp mapped_type; 483227825Stheraven typedef _Tp data_type; 484227825Stheraven typedef _Hash hasher; 485227825Stheraven typedef _Pred key_equal; 486227825Stheraven typedef _Alloc allocator_type; 487227825Stheraven typedef pair<const key_type, mapped_type> value_type; 488227825Stheraven typedef value_type& reference; 489227825Stheraven typedef const value_type& const_reference; 490227825Stheraven 491227825Stheravenprivate: 492227825Stheraven typedef pair<key_type, mapped_type> __value_type; 493227825Stheraven typedef __hash_map_hasher<__value_type, hasher> __hasher; 494227825Stheraven typedef __hash_map_equal<__value_type, key_equal> __key_equal; 495288943Sdim typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type; 496227825Stheraven 497227825Stheraven typedef __hash_table<__value_type, __hasher, 498227825Stheraven __key_equal, __allocator_type> __table; 499227825Stheraven 500227825Stheraven __table __table_; 501227825Stheraven 502227825Stheraven typedef typename __table::__node_pointer __node_pointer; 503227825Stheraven typedef typename __table::__node_const_pointer __node_const_pointer; 504227825Stheraven typedef typename __table::__node_traits __node_traits; 505227825Stheraven typedef typename __table::__node_allocator __node_allocator; 506227825Stheraven typedef typename __table::__node __node; 507232924Stheraven typedef __hash_map_node_destructor<__node_allocator> _Dp; 508232924Stheraven typedef unique_ptr<__node, _Dp> __node_holder; 509227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 510227825Stheravenpublic: 511227825Stheraven typedef typename __alloc_traits::pointer pointer; 512227825Stheraven typedef typename __alloc_traits::const_pointer const_pointer; 513227825Stheraven typedef typename __alloc_traits::size_type size_type; 514227825Stheraven typedef typename __alloc_traits::difference_type difference_type; 515227825Stheraven 516227825Stheraven typedef __hash_map_iterator<typename __table::iterator> iterator; 517227825Stheraven typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 518227825Stheraven 519227825Stheraven _LIBCPP_INLINE_VISIBILITY hash_map() {__table_.rehash(193);} 520227825Stheraven explicit hash_map(size_type __n, const hasher& __hf = hasher(), 521227825Stheraven const key_equal& __eql = key_equal()); 522227825Stheraven hash_map(size_type __n, const hasher& __hf, 523227825Stheraven const key_equal& __eql, 524227825Stheraven const allocator_type& __a); 525227825Stheraven template <class _InputIterator> 526227825Stheraven hash_map(_InputIterator __first, _InputIterator __last); 527227825Stheraven template <class _InputIterator> 528227825Stheraven hash_map(_InputIterator __first, _InputIterator __last, 529227825Stheraven size_type __n, const hasher& __hf = hasher(), 530227825Stheraven const key_equal& __eql = key_equal()); 531227825Stheraven template <class _InputIterator> 532227825Stheraven hash_map(_InputIterator __first, _InputIterator __last, 533227825Stheraven size_type __n, const hasher& __hf, 534227825Stheraven const key_equal& __eql, 535227825Stheraven const allocator_type& __a); 536227825Stheraven hash_map(const hash_map& __u); 537227825Stheraven 538227825Stheraven _LIBCPP_INLINE_VISIBILITY 539227825Stheraven allocator_type get_allocator() const 540227825Stheraven {return allocator_type(__table_.__node_alloc());} 541227825Stheraven 542227825Stheraven _LIBCPP_INLINE_VISIBILITY 543227825Stheraven bool empty() const {return __table_.size() == 0;} 544227825Stheraven _LIBCPP_INLINE_VISIBILITY 545227825Stheraven size_type size() const {return __table_.size();} 546227825Stheraven _LIBCPP_INLINE_VISIBILITY 547227825Stheraven size_type max_size() const {return __table_.max_size();} 548227825Stheraven 549227825Stheraven _LIBCPP_INLINE_VISIBILITY 550227825Stheraven iterator begin() {return __table_.begin();} 551227825Stheraven _LIBCPP_INLINE_VISIBILITY 552227825Stheraven iterator end() {return __table_.end();} 553227825Stheraven _LIBCPP_INLINE_VISIBILITY 554227825Stheraven const_iterator begin() const {return __table_.begin();} 555227825Stheraven _LIBCPP_INLINE_VISIBILITY 556227825Stheraven const_iterator end() const {return __table_.end();} 557227825Stheraven 558227825Stheraven _LIBCPP_INLINE_VISIBILITY 559227825Stheraven pair<iterator, bool> insert(const value_type& __x) 560227825Stheraven {return __table_.__insert_unique(__x);} 561227825Stheraven _LIBCPP_INLINE_VISIBILITY 562227825Stheraven iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;} 563227825Stheraven template <class _InputIterator> 564227825Stheraven void insert(_InputIterator __first, _InputIterator __last); 565227825Stheraven 566227825Stheraven _LIBCPP_INLINE_VISIBILITY 567227825Stheraven void erase(const_iterator __p) {__table_.erase(__p.__i_);} 568227825Stheraven _LIBCPP_INLINE_VISIBILITY 569227825Stheraven size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 570227825Stheraven _LIBCPP_INLINE_VISIBILITY 571227825Stheraven void erase(const_iterator __first, const_iterator __last) 572227825Stheraven {__table_.erase(__first.__i_, __last.__i_);} 573227825Stheraven _LIBCPP_INLINE_VISIBILITY 574227825Stheraven void clear() {__table_.clear();} 575227825Stheraven 576227825Stheraven _LIBCPP_INLINE_VISIBILITY 577227825Stheraven void swap(hash_map& __u) {__table_.swap(__u.__table_);} 578227825Stheraven 579227825Stheraven _LIBCPP_INLINE_VISIBILITY 580227825Stheraven hasher hash_funct() const 581227825Stheraven {return __table_.hash_function().hash_function();} 582227825Stheraven _LIBCPP_INLINE_VISIBILITY 583227825Stheraven key_equal key_eq() const 584227825Stheraven {return __table_.key_eq().key_eq();} 585227825Stheraven 586227825Stheraven _LIBCPP_INLINE_VISIBILITY 587227825Stheraven iterator find(const key_type& __k) {return __table_.find(__k);} 588227825Stheraven _LIBCPP_INLINE_VISIBILITY 589227825Stheraven const_iterator find(const key_type& __k) const {return __table_.find(__k);} 590227825Stheraven _LIBCPP_INLINE_VISIBILITY 591227825Stheraven size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 592227825Stheraven _LIBCPP_INLINE_VISIBILITY 593227825Stheraven pair<iterator, iterator> equal_range(const key_type& __k) 594227825Stheraven {return __table_.__equal_range_unique(__k);} 595227825Stheraven _LIBCPP_INLINE_VISIBILITY 596227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 597227825Stheraven {return __table_.__equal_range_unique(__k);} 598227825Stheraven 599227825Stheraven mapped_type& operator[](const key_type& __k); 600227825Stheraven 601227825Stheraven _LIBCPP_INLINE_VISIBILITY 602227825Stheraven size_type bucket_count() const {return __table_.bucket_count();} 603227825Stheraven _LIBCPP_INLINE_VISIBILITY 604227825Stheraven size_type max_bucket_count() const {return __table_.max_bucket_count();} 605227825Stheraven 606227825Stheraven _LIBCPP_INLINE_VISIBILITY 607227825Stheraven size_type elems_in_bucket(size_type __n) const 608227825Stheraven {return __table_.bucket_size(__n);} 609227825Stheraven 610227825Stheraven _LIBCPP_INLINE_VISIBILITY 611227825Stheraven void resize(size_type __n) {__table_.rehash(__n);} 612227825Stheraven 613227825Stheravenprivate: 614227825Stheraven __node_holder __construct_node(const key_type& __k); 615227825Stheraven}; 616227825Stheraven 617227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 618227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 619227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql) 620227825Stheraven : __table_(__hf, __eql) 621227825Stheraven{ 622227825Stheraven __table_.rehash(__n); 623227825Stheraven} 624227825Stheraven 625227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 626227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 627227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql, 628227825Stheraven const allocator_type& __a) 629227825Stheraven : __table_(__hf, __eql, __a) 630227825Stheraven{ 631227825Stheraven __table_.rehash(__n); 632227825Stheraven} 633227825Stheraven 634227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 635227825Stheraventemplate <class _InputIterator> 636227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 637227825Stheraven _InputIterator __first, _InputIterator __last) 638227825Stheraven{ 639227825Stheraven __table_.rehash(193); 640227825Stheraven insert(__first, __last); 641227825Stheraven} 642227825Stheraven 643227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 644227825Stheraventemplate <class _InputIterator> 645227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 646227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 647227825Stheraven const hasher& __hf, const key_equal& __eql) 648227825Stheraven : __table_(__hf, __eql) 649227825Stheraven{ 650227825Stheraven __table_.rehash(__n); 651227825Stheraven insert(__first, __last); 652227825Stheraven} 653227825Stheraven 654227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 655227825Stheraventemplate <class _InputIterator> 656227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 657227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 658227825Stheraven const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 659227825Stheraven : __table_(__hf, __eql, __a) 660227825Stheraven{ 661227825Stheraven __table_.rehash(__n); 662227825Stheraven insert(__first, __last); 663227825Stheraven} 664227825Stheraven 665227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 666227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 667227825Stheraven const hash_map& __u) 668227825Stheraven : __table_(__u.__table_) 669227825Stheraven{ 670227825Stheraven __table_.rehash(__u.bucket_count()); 671227825Stheraven insert(__u.begin(), __u.end()); 672227825Stheraven} 673227825Stheraven 674227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 675227825Stheraventypename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder 676227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) 677227825Stheraven{ 678227825Stheraven __node_allocator& __na = __table_.__node_alloc(); 679232924Stheraven __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 680227825Stheraven __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k); 681227825Stheraven __h.get_deleter().__first_constructed = true; 682227825Stheraven __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); 683227825Stheraven __h.get_deleter().__second_constructed = true; 684261272Sdim return _VSTD::move(__h); // explicitly moved for C++03 685227825Stheraven} 686227825Stheraven 687227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 688227825Stheraventemplate <class _InputIterator> 689227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 690227825Stheravenvoid 691227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 692227825Stheraven _InputIterator __last) 693227825Stheraven{ 694227825Stheraven for (; __first != __last; ++__first) 695227825Stheraven __table_.__insert_unique(*__first); 696227825Stheraven} 697227825Stheraven 698227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 699227825Stheraven_Tp& 700227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) 701227825Stheraven{ 702227825Stheraven iterator __i = find(__k); 703227825Stheraven if (__i != end()) 704227825Stheraven return __i->second; 705227825Stheraven __node_holder __h = __construct_node(__k); 706227825Stheraven pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); 707227825Stheraven __h.release(); 708227825Stheraven return __r.first->second; 709227825Stheraven} 710227825Stheraven 711227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 712227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 713227825Stheravenvoid 714227825Stheravenswap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 715227825Stheraven hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 716227825Stheraven{ 717227825Stheraven __x.swap(__y); 718227825Stheraven} 719227825Stheraven 720227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 721227825Stheravenbool 722227825Stheravenoperator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 723227825Stheraven const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 724227825Stheraven{ 725227825Stheraven if (__x.size() != __y.size()) 726227825Stheraven return false; 727227825Stheraven typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 728227825Stheraven const_iterator; 729227825Stheraven for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 730227825Stheraven __i != __ex; ++__i) 731227825Stheraven { 732227825Stheraven const_iterator __j = __y.find(__i->first); 733227825Stheraven if (__j == __ey || !(*__i == *__j)) 734227825Stheraven return false; 735227825Stheraven } 736227825Stheraven return true; 737227825Stheraven} 738227825Stheraven 739227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 740227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 741227825Stheravenbool 742227825Stheravenoperator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 743227825Stheraven const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 744227825Stheraven{ 745227825Stheraven return !(__x == __y); 746227825Stheraven} 747227825Stheraven 748227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 749227825Stheraven class _Alloc = allocator<pair<const _Key, _Tp> > > 750261272Sdimclass _LIBCPP_TYPE_VIS_ONLY hash_multimap 751227825Stheraven{ 752227825Stheravenpublic: 753227825Stheraven // types 754227825Stheraven typedef _Key key_type; 755227825Stheraven typedef _Tp mapped_type; 756227825Stheraven typedef _Tp data_type; 757227825Stheraven typedef _Hash hasher; 758227825Stheraven typedef _Pred key_equal; 759227825Stheraven typedef _Alloc allocator_type; 760227825Stheraven typedef pair<const key_type, mapped_type> value_type; 761227825Stheraven typedef value_type& reference; 762227825Stheraven typedef const value_type& const_reference; 763227825Stheraven 764227825Stheravenprivate: 765227825Stheraven typedef pair<key_type, mapped_type> __value_type; 766227825Stheraven typedef __hash_map_hasher<__value_type, hasher> __hasher; 767227825Stheraven typedef __hash_map_equal<__value_type, key_equal> __key_equal; 768288943Sdim typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type; 769227825Stheraven 770227825Stheraven typedef __hash_table<__value_type, __hasher, 771227825Stheraven __key_equal, __allocator_type> __table; 772227825Stheraven 773227825Stheraven __table __table_; 774227825Stheraven 775227825Stheraven typedef typename __table::__node_traits __node_traits; 776227825Stheraven typedef typename __table::__node_allocator __node_allocator; 777227825Stheraven typedef typename __table::__node __node; 778232924Stheraven typedef __hash_map_node_destructor<__node_allocator> _Dp; 779232924Stheraven typedef unique_ptr<__node, _Dp> __node_holder; 780227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 781227825Stheravenpublic: 782227825Stheraven typedef typename __alloc_traits::pointer pointer; 783227825Stheraven typedef typename __alloc_traits::const_pointer const_pointer; 784227825Stheraven typedef typename __alloc_traits::size_type size_type; 785227825Stheraven typedef typename __alloc_traits::difference_type difference_type; 786227825Stheraven 787227825Stheraven typedef __hash_map_iterator<typename __table::iterator> iterator; 788227825Stheraven typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 789227825Stheraven 790227825Stheraven _LIBCPP_INLINE_VISIBILITY 791227825Stheraven hash_multimap() {__table_.rehash(193);} 792227825Stheraven explicit hash_multimap(size_type __n, const hasher& __hf = hasher(), 793227825Stheraven const key_equal& __eql = key_equal()); 794227825Stheraven hash_multimap(size_type __n, const hasher& __hf, 795227825Stheraven const key_equal& __eql, 796227825Stheraven const allocator_type& __a); 797227825Stheraven template <class _InputIterator> 798227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last); 799227825Stheraven template <class _InputIterator> 800227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last, 801227825Stheraven size_type __n, const hasher& __hf = hasher(), 802227825Stheraven const key_equal& __eql = key_equal()); 803227825Stheraven template <class _InputIterator> 804227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last, 805227825Stheraven size_type __n, const hasher& __hf, 806227825Stheraven const key_equal& __eql, 807227825Stheraven const allocator_type& __a); 808227825Stheraven hash_multimap(const hash_multimap& __u); 809227825Stheraven 810227825Stheraven _LIBCPP_INLINE_VISIBILITY 811227825Stheraven allocator_type get_allocator() const 812227825Stheraven {return allocator_type(__table_.__node_alloc());} 813227825Stheraven 814227825Stheraven _LIBCPP_INLINE_VISIBILITY 815227825Stheraven bool empty() const {return __table_.size() == 0;} 816227825Stheraven _LIBCPP_INLINE_VISIBILITY 817227825Stheraven size_type size() const {return __table_.size();} 818227825Stheraven _LIBCPP_INLINE_VISIBILITY 819227825Stheraven size_type max_size() const {return __table_.max_size();} 820227825Stheraven 821227825Stheraven _LIBCPP_INLINE_VISIBILITY 822227825Stheraven iterator begin() {return __table_.begin();} 823227825Stheraven _LIBCPP_INLINE_VISIBILITY 824227825Stheraven iterator end() {return __table_.end();} 825227825Stheraven _LIBCPP_INLINE_VISIBILITY 826227825Stheraven const_iterator begin() const {return __table_.begin();} 827227825Stheraven _LIBCPP_INLINE_VISIBILITY 828227825Stheraven const_iterator end() const {return __table_.end();} 829227825Stheraven 830227825Stheraven _LIBCPP_INLINE_VISIBILITY 831227825Stheraven iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 832227825Stheraven _LIBCPP_INLINE_VISIBILITY 833227825Stheraven iterator insert(const_iterator, const value_type& __x) {return insert(__x);} 834227825Stheraven template <class _InputIterator> 835227825Stheraven void insert(_InputIterator __first, _InputIterator __last); 836227825Stheraven 837227825Stheraven _LIBCPP_INLINE_VISIBILITY 838227825Stheraven void erase(const_iterator __p) {__table_.erase(__p.__i_);} 839227825Stheraven _LIBCPP_INLINE_VISIBILITY 840227825Stheraven size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 841227825Stheraven _LIBCPP_INLINE_VISIBILITY 842227825Stheraven void erase(const_iterator __first, const_iterator __last) 843227825Stheraven {__table_.erase(__first.__i_, __last.__i_);} 844227825Stheraven _LIBCPP_INLINE_VISIBILITY 845227825Stheraven void clear() {__table_.clear();} 846227825Stheraven 847227825Stheraven _LIBCPP_INLINE_VISIBILITY 848227825Stheraven void swap(hash_multimap& __u) {__table_.swap(__u.__table_);} 849227825Stheraven 850227825Stheraven _LIBCPP_INLINE_VISIBILITY 851227825Stheraven hasher hash_funct() const 852227825Stheraven {return __table_.hash_function().hash_function();} 853227825Stheraven _LIBCPP_INLINE_VISIBILITY 854227825Stheraven key_equal key_eq() const 855227825Stheraven {return __table_.key_eq().key_eq();} 856227825Stheraven 857227825Stheraven _LIBCPP_INLINE_VISIBILITY 858227825Stheraven iterator find(const key_type& __k) {return __table_.find(__k);} 859227825Stheraven _LIBCPP_INLINE_VISIBILITY 860227825Stheraven const_iterator find(const key_type& __k) const {return __table_.find(__k);} 861227825Stheraven _LIBCPP_INLINE_VISIBILITY 862227825Stheraven size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 863227825Stheraven _LIBCPP_INLINE_VISIBILITY 864227825Stheraven pair<iterator, iterator> equal_range(const key_type& __k) 865227825Stheraven {return __table_.__equal_range_multi(__k);} 866227825Stheraven _LIBCPP_INLINE_VISIBILITY 867227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 868227825Stheraven {return __table_.__equal_range_multi(__k);} 869227825Stheraven 870227825Stheraven _LIBCPP_INLINE_VISIBILITY 871227825Stheraven size_type bucket_count() const {return __table_.bucket_count();} 872227825Stheraven _LIBCPP_INLINE_VISIBILITY 873227825Stheraven size_type max_bucket_count() const {return __table_.max_bucket_count();} 874227825Stheraven 875227825Stheraven _LIBCPP_INLINE_VISIBILITY 876227825Stheraven size_type elems_in_bucket(size_type __n) const 877227825Stheraven {return __table_.bucket_size(__n);} 878227825Stheraven 879227825Stheraven _LIBCPP_INLINE_VISIBILITY 880227825Stheraven void resize(size_type __n) {__table_.rehash(__n);} 881227825Stheraven}; 882227825Stheraven 883227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 884227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 885227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql) 886227825Stheraven : __table_(__hf, __eql) 887227825Stheraven{ 888227825Stheraven __table_.rehash(__n); 889227825Stheraven} 890227825Stheraven 891227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 892227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 893227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql, 894227825Stheraven const allocator_type& __a) 895227825Stheraven : __table_(__hf, __eql, __a) 896227825Stheraven{ 897227825Stheraven __table_.rehash(__n); 898227825Stheraven} 899227825Stheraven 900227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 901227825Stheraventemplate <class _InputIterator> 902227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 903227825Stheraven _InputIterator __first, _InputIterator __last) 904227825Stheraven{ 905227825Stheraven __table_.rehash(193); 906227825Stheraven insert(__first, __last); 907227825Stheraven} 908227825Stheraven 909227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 910227825Stheraventemplate <class _InputIterator> 911227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 912227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 913227825Stheraven const hasher& __hf, const key_equal& __eql) 914227825Stheraven : __table_(__hf, __eql) 915227825Stheraven{ 916227825Stheraven __table_.rehash(__n); 917227825Stheraven insert(__first, __last); 918227825Stheraven} 919227825Stheraven 920227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 921227825Stheraventemplate <class _InputIterator> 922227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 923227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 924227825Stheraven const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 925227825Stheraven : __table_(__hf, __eql, __a) 926227825Stheraven{ 927227825Stheraven __table_.rehash(__n); 928227825Stheraven insert(__first, __last); 929227825Stheraven} 930227825Stheraven 931227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 932227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 933227825Stheraven const hash_multimap& __u) 934227825Stheraven : __table_(__u.__table_) 935227825Stheraven{ 936227825Stheraven __table_.rehash(__u.bucket_count()); 937227825Stheraven insert(__u.begin(), __u.end()); 938227825Stheraven} 939227825Stheraven 940227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 941227825Stheraventemplate <class _InputIterator> 942227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 943227825Stheravenvoid 944227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 945227825Stheraven _InputIterator __last) 946227825Stheraven{ 947227825Stheraven for (; __first != __last; ++__first) 948227825Stheraven __table_.__insert_multi(*__first); 949227825Stheraven} 950227825Stheraven 951227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 952227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 953227825Stheravenvoid 954227825Stheravenswap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 955227825Stheraven hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 956227825Stheraven{ 957227825Stheraven __x.swap(__y); 958227825Stheraven} 959227825Stheraven 960227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 961227825Stheravenbool 962227825Stheravenoperator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 963227825Stheraven const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 964227825Stheraven{ 965227825Stheraven if (__x.size() != __y.size()) 966227825Stheraven return false; 967227825Stheraven typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 968227825Stheraven const_iterator; 969227825Stheraven typedef pair<const_iterator, const_iterator> _EqRng; 970227825Stheraven for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 971227825Stheraven { 972227825Stheraven _EqRng __xeq = __x.equal_range(__i->first); 973227825Stheraven _EqRng __yeq = __y.equal_range(__i->first); 974227825Stheraven if (_VSTD::distance(__xeq.first, __xeq.second) != 975227825Stheraven _VSTD::distance(__yeq.first, __yeq.second) || 976227825Stheraven !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 977227825Stheraven return false; 978227825Stheraven __i = __xeq.second; 979227825Stheraven } 980227825Stheraven return true; 981227825Stheraven} 982227825Stheraven 983227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 984227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 985227825Stheravenbool 986227825Stheravenoperator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 987227825Stheraven const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 988227825Stheraven{ 989227825Stheraven return !(__x == __y); 990227825Stheraven} 991227825Stheraven 992227825Stheraven} // __gnu_cxx 993227825Stheraven 994227825Stheraven#endif // _LIBCPP_HASH_MAP 995