1*38fd1498Szrj// Hashing map implementation -*- C++ -*- 2*38fd1498Szrj 3*38fd1498Szrj// Copyright (C) 2001-2018 Free Software Foundation, Inc. 4*38fd1498Szrj// 5*38fd1498Szrj// This file is part of the GNU ISO C++ Library. This library is free 6*38fd1498Szrj// software; you can redistribute it and/or modify it under the 7*38fd1498Szrj// terms of the GNU General Public License as published by the 8*38fd1498Szrj// Free Software Foundation; either version 3, or (at your option) 9*38fd1498Szrj// any later version. 10*38fd1498Szrj 11*38fd1498Szrj// This library is distributed in the hope that it will be useful, 12*38fd1498Szrj// but WITHOUT ANY WARRANTY; without even the implied warranty of 13*38fd1498Szrj// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*38fd1498Szrj// GNU General Public License for more details. 15*38fd1498Szrj 16*38fd1498Szrj// Under Section 7 of GPL version 3, you are granted additional 17*38fd1498Szrj// permissions described in the GCC Runtime Library Exception, version 18*38fd1498Szrj// 3.1, as published by the Free Software Foundation. 19*38fd1498Szrj 20*38fd1498Szrj// You should have received a copy of the GNU General Public License and 21*38fd1498Szrj// a copy of the GCC Runtime Library Exception along with this program; 22*38fd1498Szrj// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23*38fd1498Szrj// <http://www.gnu.org/licenses/>. 24*38fd1498Szrj 25*38fd1498Szrj/* 26*38fd1498Szrj * Copyright (c) 1996 27*38fd1498Szrj * Silicon Graphics Computer Systems, Inc. 28*38fd1498Szrj * 29*38fd1498Szrj * Permission to use, copy, modify, distribute and sell this software 30*38fd1498Szrj * and its documentation for any purpose is hereby granted without fee, 31*38fd1498Szrj * provided that the above copyright notice appear in all copies and 32*38fd1498Szrj * that both that copyright notice and this permission notice appear 33*38fd1498Szrj * in supporting documentation. Silicon Graphics makes no 34*38fd1498Szrj * representations about the suitability of this software for any 35*38fd1498Szrj * purpose. It is provided "as is" without express or implied warranty. 36*38fd1498Szrj * 37*38fd1498Szrj * 38*38fd1498Szrj * Copyright (c) 1994 39*38fd1498Szrj * Hewlett-Packard Company 40*38fd1498Szrj * 41*38fd1498Szrj * Permission to use, copy, modify, distribute and sell this software 42*38fd1498Szrj * and its documentation for any purpose is hereby granted without fee, 43*38fd1498Szrj * provided that the above copyright notice appear in all copies and 44*38fd1498Szrj * that both that copyright notice and this permission notice appear 45*38fd1498Szrj * in supporting documentation. Hewlett-Packard Company makes no 46*38fd1498Szrj * representations about the suitability of this software for any 47*38fd1498Szrj * purpose. It is provided "as is" without express or implied warranty. 48*38fd1498Szrj * 49*38fd1498Szrj */ 50*38fd1498Szrj 51*38fd1498Szrj/** @file backward/hash_map 52*38fd1498Szrj * This file is a GNU extension to the Standard C++ Library (possibly 53*38fd1498Szrj * containing extensions from the HP/SGI STL subset). 54*38fd1498Szrj */ 55*38fd1498Szrj 56*38fd1498Szrj#ifndef _BACKWARD_HASH_MAP 57*38fd1498Szrj#define _BACKWARD_HASH_MAP 1 58*38fd1498Szrj 59*38fd1498Szrj#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH 60*38fd1498Szrj#include "backward_warning.h" 61*38fd1498Szrj#endif 62*38fd1498Szrj 63*38fd1498Szrj#include <bits/c++config.h> 64*38fd1498Szrj#include <backward/hashtable.h> 65*38fd1498Szrj#include <bits/concept_check.h> 66*38fd1498Szrj 67*38fd1498Szrjnamespace __gnu_cxx _GLIBCXX_VISIBILITY(default) 68*38fd1498Szrj{ 69*38fd1498Szrj_GLIBCXX_BEGIN_NAMESPACE_VERSION 70*38fd1498Szrj 71*38fd1498Szrj using std::equal_to; 72*38fd1498Szrj using std::allocator; 73*38fd1498Szrj using std::pair; 74*38fd1498Szrj using std::_Select1st; 75*38fd1498Szrj 76*38fd1498Szrj /** 77*38fd1498Szrj * This is an SGI extension. 78*38fd1498Szrj * @ingroup SGIextensions 79*38fd1498Szrj * @doctodo 80*38fd1498Szrj */ 81*38fd1498Szrj template<class _Key, class _Tp, class _HashFn = hash<_Key>, 82*38fd1498Szrj class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > 83*38fd1498Szrj class hash_map 84*38fd1498Szrj { 85*38fd1498Szrj private: 86*38fd1498Szrj typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFn, 87*38fd1498Szrj _Select1st<pair<const _Key, _Tp> >, 88*38fd1498Szrj _EqualKey, _Alloc> _Ht; 89*38fd1498Szrj 90*38fd1498Szrj _Ht _M_ht; 91*38fd1498Szrj 92*38fd1498Szrj public: 93*38fd1498Szrj typedef typename _Ht::key_type key_type; 94*38fd1498Szrj typedef _Tp data_type; 95*38fd1498Szrj typedef _Tp mapped_type; 96*38fd1498Szrj typedef typename _Ht::value_type value_type; 97*38fd1498Szrj typedef typename _Ht::hasher hasher; 98*38fd1498Szrj typedef typename _Ht::key_equal key_equal; 99*38fd1498Szrj 100*38fd1498Szrj typedef typename _Ht::size_type size_type; 101*38fd1498Szrj typedef typename _Ht::difference_type difference_type; 102*38fd1498Szrj typedef typename _Ht::pointer pointer; 103*38fd1498Szrj typedef typename _Ht::const_pointer const_pointer; 104*38fd1498Szrj typedef typename _Ht::reference reference; 105*38fd1498Szrj typedef typename _Ht::const_reference const_reference; 106*38fd1498Szrj 107*38fd1498Szrj typedef typename _Ht::iterator iterator; 108*38fd1498Szrj typedef typename _Ht::const_iterator const_iterator; 109*38fd1498Szrj 110*38fd1498Szrj typedef typename _Ht::allocator_type allocator_type; 111*38fd1498Szrj 112*38fd1498Szrj hasher 113*38fd1498Szrj hash_funct() const 114*38fd1498Szrj { return _M_ht.hash_funct(); } 115*38fd1498Szrj 116*38fd1498Szrj key_equal 117*38fd1498Szrj key_eq() const 118*38fd1498Szrj { return _M_ht.key_eq(); } 119*38fd1498Szrj 120*38fd1498Szrj allocator_type 121*38fd1498Szrj get_allocator() const 122*38fd1498Szrj { return _M_ht.get_allocator(); } 123*38fd1498Szrj 124*38fd1498Szrj hash_map() 125*38fd1498Szrj : _M_ht(100, hasher(), key_equal(), allocator_type()) {} 126*38fd1498Szrj 127*38fd1498Szrj explicit 128*38fd1498Szrj hash_map(size_type __n) 129*38fd1498Szrj : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} 130*38fd1498Szrj 131*38fd1498Szrj hash_map(size_type __n, const hasher& __hf) 132*38fd1498Szrj : _M_ht(__n, __hf, key_equal(), allocator_type()) {} 133*38fd1498Szrj 134*38fd1498Szrj hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, 135*38fd1498Szrj const allocator_type& __a = allocator_type()) 136*38fd1498Szrj : _M_ht(__n, __hf, __eql, __a) {} 137*38fd1498Szrj 138*38fd1498Szrj template<class _InputIterator> 139*38fd1498Szrj hash_map(_InputIterator __f, _InputIterator __l) 140*38fd1498Szrj : _M_ht(100, hasher(), key_equal(), allocator_type()) 141*38fd1498Szrj { _M_ht.insert_unique(__f, __l); } 142*38fd1498Szrj 143*38fd1498Szrj template<class _InputIterator> 144*38fd1498Szrj hash_map(_InputIterator __f, _InputIterator __l, size_type __n) 145*38fd1498Szrj : _M_ht(__n, hasher(), key_equal(), allocator_type()) 146*38fd1498Szrj { _M_ht.insert_unique(__f, __l); } 147*38fd1498Szrj 148*38fd1498Szrj template<class _InputIterator> 149*38fd1498Szrj hash_map(_InputIterator __f, _InputIterator __l, size_type __n, 150*38fd1498Szrj const hasher& __hf) 151*38fd1498Szrj : _M_ht(__n, __hf, key_equal(), allocator_type()) 152*38fd1498Szrj { _M_ht.insert_unique(__f, __l); } 153*38fd1498Szrj 154*38fd1498Szrj template<class _InputIterator> 155*38fd1498Szrj hash_map(_InputIterator __f, _InputIterator __l, size_type __n, 156*38fd1498Szrj const hasher& __hf, const key_equal& __eql, 157*38fd1498Szrj const allocator_type& __a = allocator_type()) 158*38fd1498Szrj : _M_ht(__n, __hf, __eql, __a) 159*38fd1498Szrj { _M_ht.insert_unique(__f, __l); } 160*38fd1498Szrj 161*38fd1498Szrj size_type 162*38fd1498Szrj size() const 163*38fd1498Szrj { return _M_ht.size(); } 164*38fd1498Szrj 165*38fd1498Szrj size_type 166*38fd1498Szrj max_size() const 167*38fd1498Szrj { return _M_ht.max_size(); } 168*38fd1498Szrj 169*38fd1498Szrj bool 170*38fd1498Szrj empty() const 171*38fd1498Szrj { return _M_ht.empty(); } 172*38fd1498Szrj 173*38fd1498Szrj void 174*38fd1498Szrj swap(hash_map& __hs) 175*38fd1498Szrj { _M_ht.swap(__hs._M_ht); } 176*38fd1498Szrj 177*38fd1498Szrj template<class _K1, class _T1, class _HF, class _EqK, class _Al> 178*38fd1498Szrj friend bool 179*38fd1498Szrj operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, 180*38fd1498Szrj const hash_map<_K1, _T1, _HF, _EqK, _Al>&); 181*38fd1498Szrj 182*38fd1498Szrj iterator 183*38fd1498Szrj begin() 184*38fd1498Szrj { return _M_ht.begin(); } 185*38fd1498Szrj 186*38fd1498Szrj iterator 187*38fd1498Szrj end() 188*38fd1498Szrj { return _M_ht.end(); } 189*38fd1498Szrj 190*38fd1498Szrj const_iterator 191*38fd1498Szrj begin() const 192*38fd1498Szrj { return _M_ht.begin(); } 193*38fd1498Szrj 194*38fd1498Szrj const_iterator 195*38fd1498Szrj end() const 196*38fd1498Szrj { return _M_ht.end(); } 197*38fd1498Szrj 198*38fd1498Szrj pair<iterator, bool> 199*38fd1498Szrj insert(const value_type& __obj) 200*38fd1498Szrj { return _M_ht.insert_unique(__obj); } 201*38fd1498Szrj 202*38fd1498Szrj template<class _InputIterator> 203*38fd1498Szrj void 204*38fd1498Szrj insert(_InputIterator __f, _InputIterator __l) 205*38fd1498Szrj { _M_ht.insert_unique(__f, __l); } 206*38fd1498Szrj 207*38fd1498Szrj pair<iterator, bool> 208*38fd1498Szrj insert_noresize(const value_type& __obj) 209*38fd1498Szrj { return _M_ht.insert_unique_noresize(__obj); } 210*38fd1498Szrj 211*38fd1498Szrj iterator 212*38fd1498Szrj find(const key_type& __key) 213*38fd1498Szrj { return _M_ht.find(__key); } 214*38fd1498Szrj 215*38fd1498Szrj const_iterator 216*38fd1498Szrj find(const key_type& __key) const 217*38fd1498Szrj { return _M_ht.find(__key); } 218*38fd1498Szrj 219*38fd1498Szrj _Tp& 220*38fd1498Szrj operator[](const key_type& __key) 221*38fd1498Szrj { return _M_ht.find_or_insert(value_type(__key, _Tp())).second; } 222*38fd1498Szrj 223*38fd1498Szrj size_type 224*38fd1498Szrj count(const key_type& __key) const 225*38fd1498Szrj { return _M_ht.count(__key); } 226*38fd1498Szrj 227*38fd1498Szrj pair<iterator, iterator> 228*38fd1498Szrj equal_range(const key_type& __key) 229*38fd1498Szrj { return _M_ht.equal_range(__key); } 230*38fd1498Szrj 231*38fd1498Szrj pair<const_iterator, const_iterator> 232*38fd1498Szrj equal_range(const key_type& __key) const 233*38fd1498Szrj { return _M_ht.equal_range(__key); } 234*38fd1498Szrj 235*38fd1498Szrj size_type 236*38fd1498Szrj erase(const key_type& __key) 237*38fd1498Szrj {return _M_ht.erase(__key); } 238*38fd1498Szrj 239*38fd1498Szrj void 240*38fd1498Szrj erase(iterator __it) 241*38fd1498Szrj { _M_ht.erase(__it); } 242*38fd1498Szrj 243*38fd1498Szrj void 244*38fd1498Szrj erase(iterator __f, iterator __l) 245*38fd1498Szrj { _M_ht.erase(__f, __l); } 246*38fd1498Szrj 247*38fd1498Szrj void 248*38fd1498Szrj clear() 249*38fd1498Szrj { _M_ht.clear(); } 250*38fd1498Szrj 251*38fd1498Szrj void 252*38fd1498Szrj resize(size_type __hint) 253*38fd1498Szrj { _M_ht.resize(__hint); } 254*38fd1498Szrj 255*38fd1498Szrj size_type 256*38fd1498Szrj bucket_count() const 257*38fd1498Szrj { return _M_ht.bucket_count(); } 258*38fd1498Szrj 259*38fd1498Szrj size_type 260*38fd1498Szrj max_bucket_count() const 261*38fd1498Szrj { return _M_ht.max_bucket_count(); } 262*38fd1498Szrj 263*38fd1498Szrj size_type 264*38fd1498Szrj elems_in_bucket(size_type __n) const 265*38fd1498Szrj { return _M_ht.elems_in_bucket(__n); } 266*38fd1498Szrj }; 267*38fd1498Szrj 268*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc> 269*38fd1498Szrj inline bool 270*38fd1498Szrj operator==(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, 271*38fd1498Szrj const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) 272*38fd1498Szrj { return __hm1._M_ht == __hm2._M_ht; } 273*38fd1498Szrj 274*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc> 275*38fd1498Szrj inline bool 276*38fd1498Szrj operator!=(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, 277*38fd1498Szrj const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) 278*38fd1498Szrj { return !(__hm1 == __hm2); } 279*38fd1498Szrj 280*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc> 281*38fd1498Szrj inline void 282*38fd1498Szrj swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, 283*38fd1498Szrj hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) 284*38fd1498Szrj { __hm1.swap(__hm2); } 285*38fd1498Szrj 286*38fd1498Szrj 287*38fd1498Szrj /** 288*38fd1498Szrj * This is an SGI extension. 289*38fd1498Szrj * @ingroup SGIextensions 290*38fd1498Szrj * @doctodo 291*38fd1498Szrj */ 292*38fd1498Szrj template<class _Key, class _Tp, 293*38fd1498Szrj class _HashFn = hash<_Key>, 294*38fd1498Szrj class _EqualKey = equal_to<_Key>, 295*38fd1498Szrj class _Alloc = allocator<_Tp> > 296*38fd1498Szrj class hash_multimap 297*38fd1498Szrj { 298*38fd1498Szrj // concept requirements 299*38fd1498Szrj __glibcxx_class_requires(_Key, _SGIAssignableConcept) 300*38fd1498Szrj __glibcxx_class_requires(_Tp, _SGIAssignableConcept) 301*38fd1498Szrj __glibcxx_class_requires3(_HashFn, size_t, _Key, _UnaryFunctionConcept) 302*38fd1498Szrj __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) 303*38fd1498Szrj 304*38fd1498Szrj private: 305*38fd1498Szrj typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFn, 306*38fd1498Szrj _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> 307*38fd1498Szrj _Ht; 308*38fd1498Szrj 309*38fd1498Szrj _Ht _M_ht; 310*38fd1498Szrj 311*38fd1498Szrj public: 312*38fd1498Szrj typedef typename _Ht::key_type key_type; 313*38fd1498Szrj typedef _Tp data_type; 314*38fd1498Szrj typedef _Tp mapped_type; 315*38fd1498Szrj typedef typename _Ht::value_type value_type; 316*38fd1498Szrj typedef typename _Ht::hasher hasher; 317*38fd1498Szrj typedef typename _Ht::key_equal key_equal; 318*38fd1498Szrj 319*38fd1498Szrj typedef typename _Ht::size_type size_type; 320*38fd1498Szrj typedef typename _Ht::difference_type difference_type; 321*38fd1498Szrj typedef typename _Ht::pointer pointer; 322*38fd1498Szrj typedef typename _Ht::const_pointer const_pointer; 323*38fd1498Szrj typedef typename _Ht::reference reference; 324*38fd1498Szrj typedef typename _Ht::const_reference const_reference; 325*38fd1498Szrj 326*38fd1498Szrj typedef typename _Ht::iterator iterator; 327*38fd1498Szrj typedef typename _Ht::const_iterator const_iterator; 328*38fd1498Szrj 329*38fd1498Szrj typedef typename _Ht::allocator_type allocator_type; 330*38fd1498Szrj 331*38fd1498Szrj hasher 332*38fd1498Szrj hash_funct() const 333*38fd1498Szrj { return _M_ht.hash_funct(); } 334*38fd1498Szrj 335*38fd1498Szrj key_equal 336*38fd1498Szrj key_eq() const 337*38fd1498Szrj { return _M_ht.key_eq(); } 338*38fd1498Szrj 339*38fd1498Szrj allocator_type 340*38fd1498Szrj get_allocator() const 341*38fd1498Szrj { return _M_ht.get_allocator(); } 342*38fd1498Szrj 343*38fd1498Szrj hash_multimap() 344*38fd1498Szrj : _M_ht(100, hasher(), key_equal(), allocator_type()) {} 345*38fd1498Szrj 346*38fd1498Szrj explicit 347*38fd1498Szrj hash_multimap(size_type __n) 348*38fd1498Szrj : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} 349*38fd1498Szrj 350*38fd1498Szrj hash_multimap(size_type __n, const hasher& __hf) 351*38fd1498Szrj : _M_ht(__n, __hf, key_equal(), allocator_type()) {} 352*38fd1498Szrj 353*38fd1498Szrj hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, 354*38fd1498Szrj const allocator_type& __a = allocator_type()) 355*38fd1498Szrj : _M_ht(__n, __hf, __eql, __a) {} 356*38fd1498Szrj 357*38fd1498Szrj template<class _InputIterator> 358*38fd1498Szrj hash_multimap(_InputIterator __f, _InputIterator __l) 359*38fd1498Szrj : _M_ht(100, hasher(), key_equal(), allocator_type()) 360*38fd1498Szrj { _M_ht.insert_equal(__f, __l); } 361*38fd1498Szrj 362*38fd1498Szrj template<class _InputIterator> 363*38fd1498Szrj hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) 364*38fd1498Szrj : _M_ht(__n, hasher(), key_equal(), allocator_type()) 365*38fd1498Szrj { _M_ht.insert_equal(__f, __l); } 366*38fd1498Szrj 367*38fd1498Szrj template<class _InputIterator> 368*38fd1498Szrj hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, 369*38fd1498Szrj const hasher& __hf) 370*38fd1498Szrj : _M_ht(__n, __hf, key_equal(), allocator_type()) 371*38fd1498Szrj { _M_ht.insert_equal(__f, __l); } 372*38fd1498Szrj 373*38fd1498Szrj template<class _InputIterator> 374*38fd1498Szrj hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, 375*38fd1498Szrj const hasher& __hf, const key_equal& __eql, 376*38fd1498Szrj const allocator_type& __a = allocator_type()) 377*38fd1498Szrj : _M_ht(__n, __hf, __eql, __a) 378*38fd1498Szrj { _M_ht.insert_equal(__f, __l); } 379*38fd1498Szrj 380*38fd1498Szrj size_type 381*38fd1498Szrj size() const 382*38fd1498Szrj { return _M_ht.size(); } 383*38fd1498Szrj 384*38fd1498Szrj size_type 385*38fd1498Szrj max_size() const 386*38fd1498Szrj { return _M_ht.max_size(); } 387*38fd1498Szrj 388*38fd1498Szrj bool 389*38fd1498Szrj empty() const 390*38fd1498Szrj { return _M_ht.empty(); } 391*38fd1498Szrj 392*38fd1498Szrj void 393*38fd1498Szrj swap(hash_multimap& __hs) 394*38fd1498Szrj { _M_ht.swap(__hs._M_ht); } 395*38fd1498Szrj 396*38fd1498Szrj template<class _K1, class _T1, class _HF, class _EqK, class _Al> 397*38fd1498Szrj friend bool 398*38fd1498Szrj operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, 399*38fd1498Szrj const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); 400*38fd1498Szrj 401*38fd1498Szrj iterator 402*38fd1498Szrj begin() 403*38fd1498Szrj { return _M_ht.begin(); } 404*38fd1498Szrj 405*38fd1498Szrj iterator 406*38fd1498Szrj end() 407*38fd1498Szrj { return _M_ht.end(); } 408*38fd1498Szrj 409*38fd1498Szrj const_iterator 410*38fd1498Szrj begin() const 411*38fd1498Szrj { return _M_ht.begin(); } 412*38fd1498Szrj 413*38fd1498Szrj const_iterator 414*38fd1498Szrj end() const 415*38fd1498Szrj { return _M_ht.end(); } 416*38fd1498Szrj 417*38fd1498Szrj iterator 418*38fd1498Szrj insert(const value_type& __obj) 419*38fd1498Szrj { return _M_ht.insert_equal(__obj); } 420*38fd1498Szrj 421*38fd1498Szrj template<class _InputIterator> 422*38fd1498Szrj void 423*38fd1498Szrj insert(_InputIterator __f, _InputIterator __l) 424*38fd1498Szrj { _M_ht.insert_equal(__f,__l); } 425*38fd1498Szrj 426*38fd1498Szrj iterator 427*38fd1498Szrj insert_noresize(const value_type& __obj) 428*38fd1498Szrj { return _M_ht.insert_equal_noresize(__obj); } 429*38fd1498Szrj 430*38fd1498Szrj iterator 431*38fd1498Szrj find(const key_type& __key) 432*38fd1498Szrj { return _M_ht.find(__key); } 433*38fd1498Szrj 434*38fd1498Szrj const_iterator 435*38fd1498Szrj find(const key_type& __key) const 436*38fd1498Szrj { return _M_ht.find(__key); } 437*38fd1498Szrj 438*38fd1498Szrj size_type 439*38fd1498Szrj count(const key_type& __key) const 440*38fd1498Szrj { return _M_ht.count(__key); } 441*38fd1498Szrj 442*38fd1498Szrj pair<iterator, iterator> 443*38fd1498Szrj equal_range(const key_type& __key) 444*38fd1498Szrj { return _M_ht.equal_range(__key); } 445*38fd1498Szrj 446*38fd1498Szrj pair<const_iterator, const_iterator> 447*38fd1498Szrj equal_range(const key_type& __key) const 448*38fd1498Szrj { return _M_ht.equal_range(__key); } 449*38fd1498Szrj 450*38fd1498Szrj size_type 451*38fd1498Szrj erase(const key_type& __key) 452*38fd1498Szrj { return _M_ht.erase(__key); } 453*38fd1498Szrj 454*38fd1498Szrj void 455*38fd1498Szrj erase(iterator __it) 456*38fd1498Szrj { _M_ht.erase(__it); } 457*38fd1498Szrj 458*38fd1498Szrj void 459*38fd1498Szrj erase(iterator __f, iterator __l) 460*38fd1498Szrj { _M_ht.erase(__f, __l); } 461*38fd1498Szrj 462*38fd1498Szrj void 463*38fd1498Szrj clear() 464*38fd1498Szrj { _M_ht.clear(); } 465*38fd1498Szrj 466*38fd1498Szrj void 467*38fd1498Szrj resize(size_type __hint) 468*38fd1498Szrj { _M_ht.resize(__hint); } 469*38fd1498Szrj 470*38fd1498Szrj size_type 471*38fd1498Szrj bucket_count() const 472*38fd1498Szrj { return _M_ht.bucket_count(); } 473*38fd1498Szrj 474*38fd1498Szrj size_type 475*38fd1498Szrj max_bucket_count() const 476*38fd1498Szrj { return _M_ht.max_bucket_count(); } 477*38fd1498Szrj 478*38fd1498Szrj size_type 479*38fd1498Szrj elems_in_bucket(size_type __n) const 480*38fd1498Szrj { return _M_ht.elems_in_bucket(__n); } 481*38fd1498Szrj }; 482*38fd1498Szrj 483*38fd1498Szrj template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> 484*38fd1498Szrj inline bool 485*38fd1498Szrj operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, 486*38fd1498Szrj const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) 487*38fd1498Szrj { return __hm1._M_ht == __hm2._M_ht; } 488*38fd1498Szrj 489*38fd1498Szrj template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> 490*38fd1498Szrj inline bool 491*38fd1498Szrj operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, 492*38fd1498Szrj const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) 493*38fd1498Szrj { return !(__hm1 == __hm2); } 494*38fd1498Szrj 495*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc> 496*38fd1498Szrj inline void 497*38fd1498Szrj swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, 498*38fd1498Szrj hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) 499*38fd1498Szrj { __hm1.swap(__hm2); } 500*38fd1498Szrj 501*38fd1498Szrj_GLIBCXX_END_NAMESPACE_VERSION 502*38fd1498Szrj} // namespace 503*38fd1498Szrj 504*38fd1498Szrjnamespace std _GLIBCXX_VISIBILITY(default) 505*38fd1498Szrj{ 506*38fd1498Szrj_GLIBCXX_BEGIN_NAMESPACE_VERSION 507*38fd1498Szrj 508*38fd1498Szrj // Specialization of insert_iterator so that it will work for hash_map 509*38fd1498Szrj // and hash_multimap. 510*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> 511*38fd1498Szrj class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, 512*38fd1498Szrj _EqKey, _Alloc> > 513*38fd1498Szrj { 514*38fd1498Szrj protected: 515*38fd1498Szrj typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> 516*38fd1498Szrj _Container; 517*38fd1498Szrj _Container* container; 518*38fd1498Szrj 519*38fd1498Szrj public: 520*38fd1498Szrj typedef _Container container_type; 521*38fd1498Szrj typedef output_iterator_tag iterator_category; 522*38fd1498Szrj typedef void value_type; 523*38fd1498Szrj typedef void difference_type; 524*38fd1498Szrj typedef void pointer; 525*38fd1498Szrj typedef void reference; 526*38fd1498Szrj 527*38fd1498Szrj insert_iterator(_Container& __x) 528*38fd1498Szrj : container(&__x) {} 529*38fd1498Szrj 530*38fd1498Szrj insert_iterator(_Container& __x, typename _Container::iterator) 531*38fd1498Szrj : container(&__x) {} 532*38fd1498Szrj 533*38fd1498Szrj insert_iterator<_Container>& 534*38fd1498Szrj operator=(const typename _Container::value_type& __value) 535*38fd1498Szrj { 536*38fd1498Szrj container->insert(__value); 537*38fd1498Szrj return *this; 538*38fd1498Szrj } 539*38fd1498Szrj 540*38fd1498Szrj insert_iterator<_Container>& 541*38fd1498Szrj operator*() 542*38fd1498Szrj { return *this; } 543*38fd1498Szrj 544*38fd1498Szrj insert_iterator<_Container>& 545*38fd1498Szrj operator++() { return *this; } 546*38fd1498Szrj 547*38fd1498Szrj insert_iterator<_Container>& 548*38fd1498Szrj operator++(int) 549*38fd1498Szrj { return *this; } 550*38fd1498Szrj }; 551*38fd1498Szrj 552*38fd1498Szrj template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> 553*38fd1498Szrj class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, 554*38fd1498Szrj _EqKey, _Alloc> > 555*38fd1498Szrj { 556*38fd1498Szrj protected: 557*38fd1498Szrj typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> 558*38fd1498Szrj _Container; 559*38fd1498Szrj _Container* container; 560*38fd1498Szrj typename _Container::iterator iter; 561*38fd1498Szrj 562*38fd1498Szrj public: 563*38fd1498Szrj typedef _Container container_type; 564*38fd1498Szrj typedef output_iterator_tag iterator_category; 565*38fd1498Szrj typedef void value_type; 566*38fd1498Szrj typedef void difference_type; 567*38fd1498Szrj typedef void pointer; 568*38fd1498Szrj typedef void reference; 569*38fd1498Szrj 570*38fd1498Szrj insert_iterator(_Container& __x) 571*38fd1498Szrj : container(&__x) {} 572*38fd1498Szrj 573*38fd1498Szrj insert_iterator(_Container& __x, typename _Container::iterator) 574*38fd1498Szrj : container(&__x) {} 575*38fd1498Szrj 576*38fd1498Szrj insert_iterator<_Container>& 577*38fd1498Szrj operator=(const typename _Container::value_type& __value) 578*38fd1498Szrj { 579*38fd1498Szrj container->insert(__value); 580*38fd1498Szrj return *this; 581*38fd1498Szrj } 582*38fd1498Szrj 583*38fd1498Szrj insert_iterator<_Container>& 584*38fd1498Szrj operator*() 585*38fd1498Szrj { return *this; } 586*38fd1498Szrj 587*38fd1498Szrj insert_iterator<_Container>& 588*38fd1498Szrj operator++() 589*38fd1498Szrj { return *this; } 590*38fd1498Szrj 591*38fd1498Szrj insert_iterator<_Container>& 592*38fd1498Szrj operator++(int) 593*38fd1498Szrj { return *this; } 594*38fd1498Szrj }; 595*38fd1498Szrj 596*38fd1498Szrj_GLIBCXX_END_NAMESPACE_VERSION 597*38fd1498Szrj} // namespace 598*38fd1498Szrj 599*38fd1498Szrj#endif 600