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> 206227825Stheraven#include <ext/__hash> 207227825Stheraven 208227825Stheraven#if __DEPRECATED 209227825Stheraven#warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> 210227825Stheraven#endif 211227825Stheraven 212227825Stheraven#pragma GCC system_header 213227825Stheraven 214227825Stheravennamespace __gnu_cxx { 215227825Stheraven 216227825Stheravenusing namespace std; 217227825Stheraven 218232950Stheraventemplate <class _Tp, class _Hash, bool = is_empty<_Hash>::value 219232950Stheraven#if __has_feature(is_final) 220232950Stheraven && !__is_final(_Hash) 221232950Stheraven#endif 222232950Stheraven > 223227825Stheravenclass __hash_map_hasher 224227825Stheraven : private _Hash 225227825Stheraven{ 226227825Stheravenpublic: 227227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {} 228227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {} 229227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;} 230227825Stheraven _LIBCPP_INLINE_VISIBILITY 231227825Stheraven size_t operator()(const _Tp& __x) const 232227825Stheraven {return static_cast<const _Hash&>(*this)(__x.first);} 233227825Stheraven _LIBCPP_INLINE_VISIBILITY 234227825Stheraven size_t operator()(const typename _Tp::first_type& __x) const 235227825Stheraven {return static_cast<const _Hash&>(*this)(__x);} 236227825Stheraven}; 237227825Stheraven 238227825Stheraventemplate <class _Tp, class _Hash> 239227825Stheravenclass __hash_map_hasher<_Tp, _Hash, false> 240227825Stheraven{ 241227825Stheraven _Hash __hash_; 242227825Stheravenpublic: 243227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {} 244227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {} 245227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;} 246227825Stheraven _LIBCPP_INLINE_VISIBILITY 247227825Stheraven size_t operator()(const _Tp& __x) const 248227825Stheraven {return __hash_(__x.first);} 249227825Stheraven _LIBCPP_INLINE_VISIBILITY 250227825Stheraven size_t operator()(const typename _Tp::first_type& __x) const 251227825Stheraven {return __hash_(__x);} 252227825Stheraven}; 253227825Stheraven 254232950Stheraventemplate <class _Tp, class _Pred, bool = is_empty<_Pred>::value 255232950Stheraven#if __has_feature(is_final) 256232950Stheraven && !__is_final(_Pred) 257232950Stheraven#endif 258232950Stheraven > 259227825Stheravenclass __hash_map_equal 260227825Stheraven : private _Pred 261227825Stheraven{ 262227825Stheravenpublic: 263227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {} 264227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {} 265227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;} 266227825Stheraven _LIBCPP_INLINE_VISIBILITY 267227825Stheraven bool operator()(const _Tp& __x, const _Tp& __y) const 268227825Stheraven {return static_cast<const _Pred&>(*this)(__x.first, __y.first);} 269227825Stheraven _LIBCPP_INLINE_VISIBILITY 270227825Stheraven bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 271227825Stheraven {return static_cast<const _Pred&>(*this)(__x, __y.first);} 272227825Stheraven _LIBCPP_INLINE_VISIBILITY 273227825Stheraven bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 274227825Stheraven {return static_cast<const _Pred&>(*this)(__x.first, __y);} 275227825Stheraven _LIBCPP_INLINE_VISIBILITY 276227825Stheraven bool operator()(const typename _Tp::first_type& __x, 277227825Stheraven const typename _Tp::first_type& __y) const 278227825Stheraven {return static_cast<const _Pred&>(*this)(__x, __y);} 279227825Stheraven}; 280227825Stheraven 281227825Stheraventemplate <class _Tp, class _Pred> 282227825Stheravenclass __hash_map_equal<_Tp, _Pred, false> 283227825Stheraven{ 284227825Stheraven _Pred __pred_; 285227825Stheravenpublic: 286227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {} 287227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {} 288227825Stheraven _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;} 289227825Stheraven _LIBCPP_INLINE_VISIBILITY 290227825Stheraven bool operator()(const _Tp& __x, const _Tp& __y) const 291227825Stheraven {return __pred_(__x.first, __y.first);} 292227825Stheraven _LIBCPP_INLINE_VISIBILITY 293227825Stheraven bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const 294227825Stheraven {return __pred_(__x, __y.first);} 295227825Stheraven _LIBCPP_INLINE_VISIBILITY 296227825Stheraven bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const 297227825Stheraven {return __pred_(__x.first, __y);} 298227825Stheraven _LIBCPP_INLINE_VISIBILITY 299227825Stheraven bool operator()(const typename _Tp::first_type& __x, 300227825Stheraven const typename _Tp::first_type& __y) const 301227825Stheraven {return __pred_(__x, __y);} 302227825Stheraven}; 303227825Stheraven 304227825Stheraventemplate <class _Alloc> 305227825Stheravenclass __hash_map_node_destructor 306227825Stheraven{ 307227825Stheraven typedef _Alloc allocator_type; 308227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 309227825Stheraven typedef typename __alloc_traits::value_type::value_type value_type; 310227825Stheravenpublic: 311227825Stheraven typedef typename __alloc_traits::pointer pointer; 312227825Stheravenprivate: 313227825Stheraven typedef typename value_type::first_type first_type; 314227825Stheraven typedef typename value_type::second_type second_type; 315227825Stheraven 316227825Stheraven allocator_type& __na_; 317227825Stheraven 318227825Stheraven __hash_map_node_destructor& operator=(const __hash_map_node_destructor&); 319227825Stheraven 320227825Stheravenpublic: 321227825Stheraven bool __first_constructed; 322227825Stheraven bool __second_constructed; 323227825Stheraven 324227825Stheraven _LIBCPP_INLINE_VISIBILITY 325227825Stheraven explicit __hash_map_node_destructor(allocator_type& __na) 326227825Stheraven : __na_(__na), 327227825Stheraven __first_constructed(false), 328227825Stheraven __second_constructed(false) 329227825Stheraven {} 330227825Stheraven 331227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 332227825Stheraven _LIBCPP_INLINE_VISIBILITY 333227825Stheraven __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) 334227825Stheraven : __na_(__x.__na_), 335227825Stheraven __first_constructed(__x.__value_constructed), 336227825Stheraven __second_constructed(__x.__value_constructed) 337227825Stheraven { 338227825Stheraven __x.__value_constructed = false; 339227825Stheraven } 340227825Stheraven#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 341227825Stheraven _LIBCPP_INLINE_VISIBILITY 342227825Stheraven __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) 343227825Stheraven : __na_(__x.__na_), 344227825Stheraven __first_constructed(__x.__value_constructed), 345227825Stheraven __second_constructed(__x.__value_constructed) 346227825Stheraven { 347227825Stheraven const_cast<bool&>(__x.__value_constructed) = false; 348227825Stheraven } 349227825Stheraven#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 350227825Stheraven 351227825Stheraven _LIBCPP_INLINE_VISIBILITY 352227825Stheraven void operator()(pointer __p) 353227825Stheraven { 354227825Stheraven if (__second_constructed) 355227825Stheraven __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second)); 356227825Stheraven if (__first_constructed) 357227825Stheraven __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first)); 358227825Stheraven if (__p) 359227825Stheraven __alloc_traits::deallocate(__na_, __p, 1); 360227825Stheraven } 361227825Stheraven}; 362227825Stheraven 363227825Stheraventemplate <class _HashIterator> 364249998Sdimclass _LIBCPP_TYPE_VIS __hash_map_iterator 365227825Stheraven{ 366227825Stheraven _HashIterator __i_; 367227825Stheraven 368227825Stheraven typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits; 369227825Stheraven typedef const typename _HashIterator::value_type::first_type key_type; 370227825Stheraven typedef typename _HashIterator::value_type::second_type mapped_type; 371227825Stheravenpublic: 372227825Stheraven typedef forward_iterator_tag iterator_category; 373227825Stheraven typedef pair<key_type, mapped_type> value_type; 374227825Stheraven typedef typename _HashIterator::difference_type difference_type; 375227825Stheraven typedef value_type& reference; 376227825Stheraven typedef typename __pointer_traits::template 377227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 378227825Stheraven rebind<value_type> 379227825Stheraven#else 380227825Stheraven rebind<value_type>::other 381227825Stheraven#endif 382227825Stheraven pointer; 383227825Stheraven 384227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {} 385227825Stheraven 386227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {} 387227825Stheraven 388227825Stheraven _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();} 389227825Stheraven _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();} 390227825Stheraven 391227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;} 392227825Stheraven _LIBCPP_INLINE_VISIBILITY 393227825Stheraven __hash_map_iterator operator++(int) 394227825Stheraven { 395227825Stheraven __hash_map_iterator __t(*this); 396227825Stheraven ++(*this); 397227825Stheraven return __t; 398227825Stheraven } 399227825Stheraven 400227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 401227825Stheraven bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) 402227825Stheraven {return __x.__i_ == __y.__i_;} 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 407249998Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_map; 408249998Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_multimap; 409249998Sdim template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; 410249998Sdim template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; 411249998Sdim template <class> friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; 412227825Stheraven}; 413227825Stheraven 414227825Stheraventemplate <class _HashIterator> 415249998Sdimclass _LIBCPP_TYPE_VIS __hash_map_const_iterator 416227825Stheraven{ 417227825Stheraven _HashIterator __i_; 418227825Stheraven 419227825Stheraven typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits; 420227825Stheraven typedef const typename _HashIterator::value_type::first_type key_type; 421227825Stheraven typedef typename _HashIterator::value_type::second_type mapped_type; 422227825Stheravenpublic: 423227825Stheraven typedef forward_iterator_tag iterator_category; 424227825Stheraven typedef pair<key_type, mapped_type> value_type; 425227825Stheraven typedef typename _HashIterator::difference_type difference_type; 426227825Stheraven typedef const value_type& reference; 427227825Stheraven typedef typename __pointer_traits::template 428227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 429227825Stheraven rebind<value_type> 430227825Stheraven#else 431227825Stheraven rebind<value_type>::other 432227825Stheraven#endif 433227825Stheraven pointer; 434227825Stheraven 435227825Stheraven _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {} 436227825Stheraven 437227825Stheraven _LIBCPP_INLINE_VISIBILITY 438227825Stheraven __hash_map_const_iterator(_HashIterator __i) : __i_(__i) {} 439227825Stheraven _LIBCPP_INLINE_VISIBILITY 440227825Stheraven __hash_map_const_iterator( 441227825Stheraven __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) 442227825Stheraven : __i_(__i.__i_) {} 443227825Stheraven 444227825Stheraven _LIBCPP_INLINE_VISIBILITY 445227825Stheraven reference operator*() const {return *operator->();} 446227825Stheraven _LIBCPP_INLINE_VISIBILITY 447227825Stheraven pointer operator->() const {return (pointer)__i_.operator->();} 448227825Stheraven 449227825Stheraven _LIBCPP_INLINE_VISIBILITY 450227825Stheraven __hash_map_const_iterator& operator++() {++__i_; return *this;} 451227825Stheraven _LIBCPP_INLINE_VISIBILITY 452227825Stheraven __hash_map_const_iterator operator++(int) 453227825Stheraven { 454227825Stheraven __hash_map_const_iterator __t(*this); 455227825Stheraven ++(*this); 456227825Stheraven return __t; 457227825Stheraven } 458227825Stheraven 459227825Stheraven friend _LIBCPP_INLINE_VISIBILITY 460227825Stheraven bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) 461227825Stheraven {return __x.__i_ == __y.__i_;} 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 466249998Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_map; 467249998Sdim template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_multimap; 468249998Sdim template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; 469249998Sdim template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; 470227825Stheraven}; 471227825Stheraven 472227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 473227825Stheraven class _Alloc = allocator<pair<const _Key, _Tp> > > 474249998Sdimclass _LIBCPP_TYPE_VIS hash_map 475227825Stheraven{ 476227825Stheravenpublic: 477227825Stheraven // types 478227825Stheraven typedef _Key key_type; 479227825Stheraven typedef _Tp mapped_type; 480227825Stheraven typedef _Tp data_type; 481227825Stheraven typedef _Hash hasher; 482227825Stheraven typedef _Pred key_equal; 483227825Stheraven typedef _Alloc allocator_type; 484227825Stheraven typedef pair<const key_type, mapped_type> value_type; 485227825Stheraven typedef value_type& reference; 486227825Stheraven typedef const value_type& const_reference; 487227825Stheraven 488227825Stheravenprivate: 489227825Stheraven typedef pair<key_type, mapped_type> __value_type; 490227825Stheraven typedef __hash_map_hasher<__value_type, hasher> __hasher; 491227825Stheraven typedef __hash_map_equal<__value_type, key_equal> __key_equal; 492227825Stheraven typedef typename allocator_traits<allocator_type>::template 493227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 494227825Stheraven rebind_alloc<__value_type> 495227825Stheraven#else 496227825Stheraven rebind_alloc<__value_type>::other 497227825Stheraven#endif 498227825Stheraven __allocator_type; 499227825Stheraven 500227825Stheraven typedef __hash_table<__value_type, __hasher, 501227825Stheraven __key_equal, __allocator_type> __table; 502227825Stheraven 503227825Stheraven __table __table_; 504227825Stheraven 505227825Stheraven typedef typename __table::__node_pointer __node_pointer; 506227825Stheraven typedef typename __table::__node_const_pointer __node_const_pointer; 507227825Stheraven typedef typename __table::__node_traits __node_traits; 508227825Stheraven typedef typename __table::__node_allocator __node_allocator; 509227825Stheraven typedef typename __table::__node __node; 510232950Stheraven typedef __hash_map_node_destructor<__node_allocator> _Dp; 511232950Stheraven typedef unique_ptr<__node, _Dp> __node_holder; 512227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 513227825Stheravenpublic: 514227825Stheraven typedef typename __alloc_traits::pointer pointer; 515227825Stheraven typedef typename __alloc_traits::const_pointer const_pointer; 516227825Stheraven typedef typename __alloc_traits::size_type size_type; 517227825Stheraven typedef typename __alloc_traits::difference_type difference_type; 518227825Stheraven 519227825Stheraven typedef __hash_map_iterator<typename __table::iterator> iterator; 520227825Stheraven typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 521227825Stheraven 522227825Stheraven _LIBCPP_INLINE_VISIBILITY hash_map() {__table_.rehash(193);} 523227825Stheraven explicit hash_map(size_type __n, const hasher& __hf = hasher(), 524227825Stheraven const key_equal& __eql = key_equal()); 525227825Stheraven hash_map(size_type __n, const hasher& __hf, 526227825Stheraven const key_equal& __eql, 527227825Stheraven const allocator_type& __a); 528227825Stheraven template <class _InputIterator> 529227825Stheraven hash_map(_InputIterator __first, _InputIterator __last); 530227825Stheraven template <class _InputIterator> 531227825Stheraven hash_map(_InputIterator __first, _InputIterator __last, 532227825Stheraven size_type __n, const hasher& __hf = hasher(), 533227825Stheraven const key_equal& __eql = key_equal()); 534227825Stheraven template <class _InputIterator> 535227825Stheraven hash_map(_InputIterator __first, _InputIterator __last, 536227825Stheraven size_type __n, const hasher& __hf, 537227825Stheraven const key_equal& __eql, 538227825Stheraven const allocator_type& __a); 539227825Stheraven hash_map(const hash_map& __u); 540227825Stheraven 541227825Stheraven _LIBCPP_INLINE_VISIBILITY 542227825Stheraven allocator_type get_allocator() const 543227825Stheraven {return allocator_type(__table_.__node_alloc());} 544227825Stheraven 545227825Stheraven _LIBCPP_INLINE_VISIBILITY 546227825Stheraven bool empty() const {return __table_.size() == 0;} 547227825Stheraven _LIBCPP_INLINE_VISIBILITY 548227825Stheraven size_type size() const {return __table_.size();} 549227825Stheraven _LIBCPP_INLINE_VISIBILITY 550227825Stheraven size_type max_size() const {return __table_.max_size();} 551227825Stheraven 552227825Stheraven _LIBCPP_INLINE_VISIBILITY 553227825Stheraven iterator begin() {return __table_.begin();} 554227825Stheraven _LIBCPP_INLINE_VISIBILITY 555227825Stheraven iterator end() {return __table_.end();} 556227825Stheraven _LIBCPP_INLINE_VISIBILITY 557227825Stheraven const_iterator begin() const {return __table_.begin();} 558227825Stheraven _LIBCPP_INLINE_VISIBILITY 559227825Stheraven const_iterator end() const {return __table_.end();} 560227825Stheraven 561227825Stheraven _LIBCPP_INLINE_VISIBILITY 562227825Stheraven pair<iterator, bool> insert(const value_type& __x) 563227825Stheraven {return __table_.__insert_unique(__x);} 564227825Stheraven _LIBCPP_INLINE_VISIBILITY 565227825Stheraven iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;} 566227825Stheraven template <class _InputIterator> 567227825Stheraven void insert(_InputIterator __first, _InputIterator __last); 568227825Stheraven 569227825Stheraven _LIBCPP_INLINE_VISIBILITY 570227825Stheraven void erase(const_iterator __p) {__table_.erase(__p.__i_);} 571227825Stheraven _LIBCPP_INLINE_VISIBILITY 572227825Stheraven size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);} 573227825Stheraven _LIBCPP_INLINE_VISIBILITY 574227825Stheraven void erase(const_iterator __first, const_iterator __last) 575227825Stheraven {__table_.erase(__first.__i_, __last.__i_);} 576227825Stheraven _LIBCPP_INLINE_VISIBILITY 577227825Stheraven void clear() {__table_.clear();} 578227825Stheraven 579227825Stheraven _LIBCPP_INLINE_VISIBILITY 580227825Stheraven void swap(hash_map& __u) {__table_.swap(__u.__table_);} 581227825Stheraven 582227825Stheraven _LIBCPP_INLINE_VISIBILITY 583227825Stheraven hasher hash_funct() const 584227825Stheraven {return __table_.hash_function().hash_function();} 585227825Stheraven _LIBCPP_INLINE_VISIBILITY 586227825Stheraven key_equal key_eq() const 587227825Stheraven {return __table_.key_eq().key_eq();} 588227825Stheraven 589227825Stheraven _LIBCPP_INLINE_VISIBILITY 590227825Stheraven iterator find(const key_type& __k) {return __table_.find(__k);} 591227825Stheraven _LIBCPP_INLINE_VISIBILITY 592227825Stheraven const_iterator find(const key_type& __k) const {return __table_.find(__k);} 593227825Stheraven _LIBCPP_INLINE_VISIBILITY 594227825Stheraven size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} 595227825Stheraven _LIBCPP_INLINE_VISIBILITY 596227825Stheraven pair<iterator, iterator> equal_range(const key_type& __k) 597227825Stheraven {return __table_.__equal_range_unique(__k);} 598227825Stheraven _LIBCPP_INLINE_VISIBILITY 599227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 600227825Stheraven {return __table_.__equal_range_unique(__k);} 601227825Stheraven 602227825Stheraven mapped_type& operator[](const key_type& __k); 603227825Stheraven 604227825Stheraven _LIBCPP_INLINE_VISIBILITY 605227825Stheraven size_type bucket_count() const {return __table_.bucket_count();} 606227825Stheraven _LIBCPP_INLINE_VISIBILITY 607227825Stheraven size_type max_bucket_count() const {return __table_.max_bucket_count();} 608227825Stheraven 609227825Stheraven _LIBCPP_INLINE_VISIBILITY 610227825Stheraven size_type elems_in_bucket(size_type __n) const 611227825Stheraven {return __table_.bucket_size(__n);} 612227825Stheraven 613227825Stheraven _LIBCPP_INLINE_VISIBILITY 614227825Stheraven void resize(size_type __n) {__table_.rehash(__n);} 615227825Stheraven 616227825Stheravenprivate: 617227825Stheraven __node_holder __construct_node(const key_type& __k); 618227825Stheraven}; 619227825Stheraven 620227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 621227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 622227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql) 623227825Stheraven : __table_(__hf, __eql) 624227825Stheraven{ 625227825Stheraven __table_.rehash(__n); 626227825Stheraven} 627227825Stheraven 628227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 629227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 630227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql, 631227825Stheraven const allocator_type& __a) 632227825Stheraven : __table_(__hf, __eql, __a) 633227825Stheraven{ 634227825Stheraven __table_.rehash(__n); 635227825Stheraven} 636227825Stheraven 637227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 638227825Stheraventemplate <class _InputIterator> 639227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 640227825Stheraven _InputIterator __first, _InputIterator __last) 641227825Stheraven{ 642227825Stheraven __table_.rehash(193); 643227825Stheraven insert(__first, __last); 644227825Stheraven} 645227825Stheraven 646227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 647227825Stheraventemplate <class _InputIterator> 648227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 649227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 650227825Stheraven const hasher& __hf, const key_equal& __eql) 651227825Stheraven : __table_(__hf, __eql) 652227825Stheraven{ 653227825Stheraven __table_.rehash(__n); 654227825Stheraven insert(__first, __last); 655227825Stheraven} 656227825Stheraven 657227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 658227825Stheraventemplate <class _InputIterator> 659227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 660227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 661227825Stheraven const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 662227825Stheraven : __table_(__hf, __eql, __a) 663227825Stheraven{ 664227825Stheraven __table_.rehash(__n); 665227825Stheraven insert(__first, __last); 666227825Stheraven} 667227825Stheraven 668227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 669227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( 670227825Stheraven const hash_map& __u) 671227825Stheraven : __table_(__u.__table_) 672227825Stheraven{ 673227825Stheraven __table_.rehash(__u.bucket_count()); 674227825Stheraven insert(__u.begin(), __u.end()); 675227825Stheraven} 676227825Stheraven 677227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 678227825Stheraventypename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder 679227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) 680227825Stheraven{ 681227825Stheraven __node_allocator& __na = __table_.__node_alloc(); 682232950Stheraven __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); 683227825Stheraven __node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k); 684227825Stheraven __h.get_deleter().__first_constructed = true; 685227825Stheraven __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); 686227825Stheraven __h.get_deleter().__second_constructed = true; 687227825Stheraven return _VSTD::move(__h); 688227825Stheraven} 689227825Stheraven 690227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 691227825Stheraventemplate <class _InputIterator> 692227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 693227825Stheravenvoid 694227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 695227825Stheraven _InputIterator __last) 696227825Stheraven{ 697227825Stheraven for (; __first != __last; ++__first) 698227825Stheraven __table_.__insert_unique(*__first); 699227825Stheraven} 700227825Stheraven 701227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 702227825Stheraven_Tp& 703227825Stheravenhash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) 704227825Stheraven{ 705227825Stheraven iterator __i = find(__k); 706227825Stheraven if (__i != end()) 707227825Stheraven return __i->second; 708227825Stheraven __node_holder __h = __construct_node(__k); 709227825Stheraven pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get()); 710227825Stheraven __h.release(); 711227825Stheraven return __r.first->second; 712227825Stheraven} 713227825Stheraven 714227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 715227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 716227825Stheravenvoid 717227825Stheravenswap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 718227825Stheraven hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 719227825Stheraven{ 720227825Stheraven __x.swap(__y); 721227825Stheraven} 722227825Stheraven 723227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 724227825Stheravenbool 725227825Stheravenoperator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 726227825Stheraven const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 727227825Stheraven{ 728227825Stheraven if (__x.size() != __y.size()) 729227825Stheraven return false; 730227825Stheraven typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 731227825Stheraven const_iterator; 732227825Stheraven for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end(); 733227825Stheraven __i != __ex; ++__i) 734227825Stheraven { 735227825Stheraven const_iterator __j = __y.find(__i->first); 736227825Stheraven if (__j == __ey || !(*__i == *__j)) 737227825Stheraven return false; 738227825Stheraven } 739227825Stheraven return true; 740227825Stheraven} 741227825Stheraven 742227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 743227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 744227825Stheravenbool 745227825Stheravenoperator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 746227825Stheraven const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 747227825Stheraven{ 748227825Stheraven return !(__x == __y); 749227825Stheraven} 750227825Stheraven 751227825Stheraventemplate <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, 752227825Stheraven class _Alloc = allocator<pair<const _Key, _Tp> > > 753249998Sdimclass _LIBCPP_TYPE_VIS hash_multimap 754227825Stheraven{ 755227825Stheravenpublic: 756227825Stheraven // types 757227825Stheraven typedef _Key key_type; 758227825Stheraven typedef _Tp mapped_type; 759227825Stheraven typedef _Tp data_type; 760227825Stheraven typedef _Hash hasher; 761227825Stheraven typedef _Pred key_equal; 762227825Stheraven typedef _Alloc allocator_type; 763227825Stheraven typedef pair<const key_type, mapped_type> value_type; 764227825Stheraven typedef value_type& reference; 765227825Stheraven typedef const value_type& const_reference; 766227825Stheraven 767227825Stheravenprivate: 768227825Stheraven typedef pair<key_type, mapped_type> __value_type; 769227825Stheraven typedef __hash_map_hasher<__value_type, hasher> __hasher; 770227825Stheraven typedef __hash_map_equal<__value_type, key_equal> __key_equal; 771227825Stheraven typedef typename allocator_traits<allocator_type>::template 772227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 773227825Stheraven rebind_alloc<__value_type> 774227825Stheraven#else 775227825Stheraven rebind_alloc<__value_type>::other 776227825Stheraven#endif 777227825Stheraven __allocator_type; 778227825Stheraven 779227825Stheraven typedef __hash_table<__value_type, __hasher, 780227825Stheraven __key_equal, __allocator_type> __table; 781227825Stheraven 782227825Stheraven __table __table_; 783227825Stheraven 784227825Stheraven typedef typename __table::__node_traits __node_traits; 785227825Stheraven typedef typename __table::__node_allocator __node_allocator; 786227825Stheraven typedef typename __table::__node __node; 787232950Stheraven typedef __hash_map_node_destructor<__node_allocator> _Dp; 788232950Stheraven typedef unique_ptr<__node, _Dp> __node_holder; 789227825Stheraven typedef allocator_traits<allocator_type> __alloc_traits; 790227825Stheravenpublic: 791227825Stheraven typedef typename __alloc_traits::pointer pointer; 792227825Stheraven typedef typename __alloc_traits::const_pointer const_pointer; 793227825Stheraven typedef typename __alloc_traits::size_type size_type; 794227825Stheraven typedef typename __alloc_traits::difference_type difference_type; 795227825Stheraven 796227825Stheraven typedef __hash_map_iterator<typename __table::iterator> iterator; 797227825Stheraven typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator; 798227825Stheraven 799227825Stheraven _LIBCPP_INLINE_VISIBILITY 800227825Stheraven hash_multimap() {__table_.rehash(193);} 801227825Stheraven explicit hash_multimap(size_type __n, const hasher& __hf = hasher(), 802227825Stheraven const key_equal& __eql = key_equal()); 803227825Stheraven hash_multimap(size_type __n, const hasher& __hf, 804227825Stheraven const key_equal& __eql, 805227825Stheraven const allocator_type& __a); 806227825Stheraven template <class _InputIterator> 807227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last); 808227825Stheraven template <class _InputIterator> 809227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last, 810227825Stheraven size_type __n, const hasher& __hf = hasher(), 811227825Stheraven const key_equal& __eql = key_equal()); 812227825Stheraven template <class _InputIterator> 813227825Stheraven hash_multimap(_InputIterator __first, _InputIterator __last, 814227825Stheraven size_type __n, const hasher& __hf, 815227825Stheraven const key_equal& __eql, 816227825Stheraven const allocator_type& __a); 817227825Stheraven hash_multimap(const hash_multimap& __u); 818227825Stheraven 819227825Stheraven _LIBCPP_INLINE_VISIBILITY 820227825Stheraven allocator_type get_allocator() const 821227825Stheraven {return allocator_type(__table_.__node_alloc());} 822227825Stheraven 823227825Stheraven _LIBCPP_INLINE_VISIBILITY 824227825Stheraven bool empty() const {return __table_.size() == 0;} 825227825Stheraven _LIBCPP_INLINE_VISIBILITY 826227825Stheraven size_type size() const {return __table_.size();} 827227825Stheraven _LIBCPP_INLINE_VISIBILITY 828227825Stheraven size_type max_size() const {return __table_.max_size();} 829227825Stheraven 830227825Stheraven _LIBCPP_INLINE_VISIBILITY 831227825Stheraven iterator begin() {return __table_.begin();} 832227825Stheraven _LIBCPP_INLINE_VISIBILITY 833227825Stheraven iterator end() {return __table_.end();} 834227825Stheraven _LIBCPP_INLINE_VISIBILITY 835227825Stheraven const_iterator begin() const {return __table_.begin();} 836227825Stheraven _LIBCPP_INLINE_VISIBILITY 837227825Stheraven const_iterator end() const {return __table_.end();} 838227825Stheraven 839227825Stheraven _LIBCPP_INLINE_VISIBILITY 840227825Stheraven iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} 841227825Stheraven _LIBCPP_INLINE_VISIBILITY 842227825Stheraven iterator insert(const_iterator, const value_type& __x) {return insert(__x);} 843227825Stheraven template <class _InputIterator> 844227825Stheraven void insert(_InputIterator __first, _InputIterator __last); 845227825Stheraven 846227825Stheraven _LIBCPP_INLINE_VISIBILITY 847227825Stheraven void erase(const_iterator __p) {__table_.erase(__p.__i_);} 848227825Stheraven _LIBCPP_INLINE_VISIBILITY 849227825Stheraven size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);} 850227825Stheraven _LIBCPP_INLINE_VISIBILITY 851227825Stheraven void erase(const_iterator __first, const_iterator __last) 852227825Stheraven {__table_.erase(__first.__i_, __last.__i_);} 853227825Stheraven _LIBCPP_INLINE_VISIBILITY 854227825Stheraven void clear() {__table_.clear();} 855227825Stheraven 856227825Stheraven _LIBCPP_INLINE_VISIBILITY 857227825Stheraven void swap(hash_multimap& __u) {__table_.swap(__u.__table_);} 858227825Stheraven 859227825Stheraven _LIBCPP_INLINE_VISIBILITY 860227825Stheraven hasher hash_funct() const 861227825Stheraven {return __table_.hash_function().hash_function();} 862227825Stheraven _LIBCPP_INLINE_VISIBILITY 863227825Stheraven key_equal key_eq() const 864227825Stheraven {return __table_.key_eq().key_eq();} 865227825Stheraven 866227825Stheraven _LIBCPP_INLINE_VISIBILITY 867227825Stheraven iterator find(const key_type& __k) {return __table_.find(__k);} 868227825Stheraven _LIBCPP_INLINE_VISIBILITY 869227825Stheraven const_iterator find(const key_type& __k) const {return __table_.find(__k);} 870227825Stheraven _LIBCPP_INLINE_VISIBILITY 871227825Stheraven size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} 872227825Stheraven _LIBCPP_INLINE_VISIBILITY 873227825Stheraven pair<iterator, iterator> equal_range(const key_type& __k) 874227825Stheraven {return __table_.__equal_range_multi(__k);} 875227825Stheraven _LIBCPP_INLINE_VISIBILITY 876227825Stheraven pair<const_iterator, const_iterator> equal_range(const key_type& __k) const 877227825Stheraven {return __table_.__equal_range_multi(__k);} 878227825Stheraven 879227825Stheraven _LIBCPP_INLINE_VISIBILITY 880227825Stheraven size_type bucket_count() const {return __table_.bucket_count();} 881227825Stheraven _LIBCPP_INLINE_VISIBILITY 882227825Stheraven size_type max_bucket_count() const {return __table_.max_bucket_count();} 883227825Stheraven 884227825Stheraven _LIBCPP_INLINE_VISIBILITY 885227825Stheraven size_type elems_in_bucket(size_type __n) const 886227825Stheraven {return __table_.bucket_size(__n);} 887227825Stheraven 888227825Stheraven _LIBCPP_INLINE_VISIBILITY 889227825Stheraven void resize(size_type __n) {__table_.rehash(__n);} 890227825Stheraven}; 891227825Stheraven 892227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 893227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 894227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql) 895227825Stheraven : __table_(__hf, __eql) 896227825Stheraven{ 897227825Stheraven __table_.rehash(__n); 898227825Stheraven} 899227825Stheraven 900227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 901227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 902227825Stheraven size_type __n, const hasher& __hf, const key_equal& __eql, 903227825Stheraven const allocator_type& __a) 904227825Stheraven : __table_(__hf, __eql, __a) 905227825Stheraven{ 906227825Stheraven __table_.rehash(__n); 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) 913227825Stheraven{ 914227825Stheraven __table_.rehash(193); 915227825Stheraven insert(__first, __last); 916227825Stheraven} 917227825Stheraven 918227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 919227825Stheraventemplate <class _InputIterator> 920227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 921227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 922227825Stheraven const hasher& __hf, const key_equal& __eql) 923227825Stheraven : __table_(__hf, __eql) 924227825Stheraven{ 925227825Stheraven __table_.rehash(__n); 926227825Stheraven insert(__first, __last); 927227825Stheraven} 928227825Stheraven 929227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 930227825Stheraventemplate <class _InputIterator> 931227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 932227825Stheraven _InputIterator __first, _InputIterator __last, size_type __n, 933227825Stheraven const hasher& __hf, const key_equal& __eql, const allocator_type& __a) 934227825Stheraven : __table_(__hf, __eql, __a) 935227825Stheraven{ 936227825Stheraven __table_.rehash(__n); 937227825Stheraven insert(__first, __last); 938227825Stheraven} 939227825Stheraven 940227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 941227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( 942227825Stheraven const hash_multimap& __u) 943227825Stheraven : __table_(__u.__table_) 944227825Stheraven{ 945227825Stheraven __table_.rehash(__u.bucket_count()); 946227825Stheraven insert(__u.begin(), __u.end()); 947227825Stheraven} 948227825Stheraven 949227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 950227825Stheraventemplate <class _InputIterator> 951227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 952227825Stheravenvoid 953227825Stheravenhash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, 954227825Stheraven _InputIterator __last) 955227825Stheraven{ 956227825Stheraven for (; __first != __last; ++__first) 957227825Stheraven __table_.__insert_multi(*__first); 958227825Stheraven} 959227825Stheraven 960227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 961227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 962227825Stheravenvoid 963227825Stheravenswap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 964227825Stheraven hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 965227825Stheraven{ 966227825Stheraven __x.swap(__y); 967227825Stheraven} 968227825Stheraven 969227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 970227825Stheravenbool 971227825Stheravenoperator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 972227825Stheraven const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 973227825Stheraven{ 974227825Stheraven if (__x.size() != __y.size()) 975227825Stheraven return false; 976227825Stheraven typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator 977227825Stheraven const_iterator; 978227825Stheraven typedef pair<const_iterator, const_iterator> _EqRng; 979227825Stheraven for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;) 980227825Stheraven { 981227825Stheraven _EqRng __xeq = __x.equal_range(__i->first); 982227825Stheraven _EqRng __yeq = __y.equal_range(__i->first); 983227825Stheraven if (_VSTD::distance(__xeq.first, __xeq.second) != 984227825Stheraven _VSTD::distance(__yeq.first, __yeq.second) || 985227825Stheraven !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first)) 986227825Stheraven return false; 987227825Stheraven __i = __xeq.second; 988227825Stheraven } 989227825Stheraven return true; 990227825Stheraven} 991227825Stheraven 992227825Stheraventemplate <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> 993227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 994227825Stheravenbool 995227825Stheravenoperator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, 996227825Stheraven const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) 997227825Stheraven{ 998227825Stheraven return !(__x == __y); 999227825Stheraven} 1000227825Stheraven 1001227825Stheraven} // __gnu_cxx 1002227825Stheraven 1003227825Stheraven#endif // _LIBCPP_HASH_MAP 1004