hash_map revision 97403
197403Sobrien// Hashing map implementation -*- C++ -*-
297403Sobrien
397403Sobrien// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
497403Sobrien//
597403Sobrien// This file is part of the GNU ISO C++ Library.  This library is free
697403Sobrien// software; you can redistribute it and/or modify it under the
797403Sobrien// terms of the GNU General Public License as published by the
897403Sobrien// Free Software Foundation; either version 2, or (at your option)
997403Sobrien// any later version.
1097403Sobrien
1197403Sobrien// This library is distributed in the hope that it will be useful,
1297403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of
1397403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1497403Sobrien// GNU General Public License for more details.
1597403Sobrien
1697403Sobrien// You should have received a copy of the GNU General Public License along
1797403Sobrien// with this library; see the file COPYING.  If not, write to the Free
1897403Sobrien// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1997403Sobrien// USA.
2097403Sobrien
2197403Sobrien// As a special exception, you may use this file as part of a free software
2297403Sobrien// library without restriction.  Specifically, if other files instantiate
2397403Sobrien// templates or use macros or inline functions from this file, or you compile
2497403Sobrien// this file and link it with other files to produce an executable, this
2597403Sobrien// file does not by itself cause the resulting executable to be covered by
2697403Sobrien// the GNU General Public License.  This exception does not however
2797403Sobrien// invalidate any other reasons why the executable file might be covered by
2897403Sobrien// the GNU General Public License.
2997403Sobrien
3097403Sobrien/*
3197403Sobrien * Copyright (c) 1996
3297403Sobrien * Silicon Graphics Computer Systems, Inc.
3397403Sobrien *
3497403Sobrien * Permission to use, copy, modify, distribute and sell this software
3597403Sobrien * and its documentation for any purpose is hereby granted without fee,
3697403Sobrien * provided that the above copyright notice appear in all copies and
3797403Sobrien * that both that copyright notice and this permission notice appear
3897403Sobrien * in supporting documentation.  Silicon Graphics makes no
3997403Sobrien * representations about the suitability of this software for any
4097403Sobrien * purpose.  It is provided "as is" without express or implied warranty.
4197403Sobrien *
4297403Sobrien *
4397403Sobrien * Copyright (c) 1994
4497403Sobrien * Hewlett-Packard Company
4597403Sobrien *
4697403Sobrien * Permission to use, copy, modify, distribute and sell this software
4797403Sobrien * and its documentation for any purpose is hereby granted without fee,
4897403Sobrien * provided that the above copyright notice appear in all copies and
4997403Sobrien * that both that copyright notice and this permission notice appear
5097403Sobrien * in supporting documentation.  Hewlett-Packard Company makes no
5197403Sobrien * representations about the suitability of this software for any
5297403Sobrien * purpose.  It is provided "as is" without express or implied warranty.
5397403Sobrien *
5497403Sobrien */
5597403Sobrien
5697403Sobrien/** @file ext/hash_map
5797403Sobrien *  This file is a GNU extension to the Standard C++ Library (possibly
5897403Sobrien *  containing extensions from the HP/SGI STL subset).  You should only
5997403Sobrien *  include this header if you are using GCC 3 or later.
6097403Sobrien */
6197403Sobrien
6297403Sobrien#ifndef __SGI_STL_INTERNAL_HASH_MAP_H
6397403Sobrien#define __SGI_STL_INTERNAL_HASH_MAP_H
6497403Sobrien
6597403Sobrien#include <ext/stl_hashtable.h>
6697403Sobrien#include <bits/concept_check.h>
6797403Sobrien
6897403Sobriennamespace __gnu_cxx
6997403Sobrien{
7097403Sobrienusing std::equal_to;
7197403Sobrienusing std::allocator;
7297403Sobrienusing std::pair;
7397403Sobrienusing std::_Select1st;
7497403Sobrien
7597403Sobrien// Forward declaration of equality operator; needed for friend declaration.
7697403Sobrien
7797403Sobrientemplate <class _Key, class _Tp,
7897403Sobrien          class _HashFcn  = hash<_Key>,
7997403Sobrien          class _EqualKey = equal_to<_Key>,
8097403Sobrien          class _Alloc =  allocator<_Tp> >
8197403Sobrienclass hash_map;
8297403Sobrien
8397403Sobrientemplate <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
8497403Sobrieninline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
8597403Sobrien                       const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
8697403Sobrien
8797403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey,
8897403Sobrien          class _Alloc>
8997403Sobrienclass hash_map
9097403Sobrien{
9197403Sobrienprivate:
9297403Sobrien  typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
9397403Sobrien                    _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
9497403Sobrien  _Ht _M_ht;
9597403Sobrien
9697403Sobrienpublic:
9797403Sobrien  typedef typename _Ht::key_type key_type;
9897403Sobrien  typedef _Tp data_type;
9997403Sobrien  typedef _Tp mapped_type;
10097403Sobrien  typedef typename _Ht::value_type value_type;
10197403Sobrien  typedef typename _Ht::hasher hasher;
10297403Sobrien  typedef typename _Ht::key_equal key_equal;
10397403Sobrien  
10497403Sobrien  typedef typename _Ht::size_type size_type;
10597403Sobrien  typedef typename _Ht::difference_type difference_type;
10697403Sobrien  typedef typename _Ht::pointer pointer;
10797403Sobrien  typedef typename _Ht::const_pointer const_pointer;
10897403Sobrien  typedef typename _Ht::reference reference;
10997403Sobrien  typedef typename _Ht::const_reference const_reference;
11097403Sobrien
11197403Sobrien  typedef typename _Ht::iterator iterator;
11297403Sobrien  typedef typename _Ht::const_iterator const_iterator;
11397403Sobrien
11497403Sobrien  typedef typename _Ht::allocator_type allocator_type;
11597403Sobrien
11697403Sobrien  hasher hash_funct() const { return _M_ht.hash_funct(); }
11797403Sobrien  key_equal key_eq() const { return _M_ht.key_eq(); }
11897403Sobrien  allocator_type get_allocator() const { return _M_ht.get_allocator(); }
11997403Sobrien
12097403Sobrienpublic:
12197403Sobrien  hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
12297403Sobrien  explicit hash_map(size_type __n)
12397403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
12497403Sobrien  hash_map(size_type __n, const hasher& __hf)
12597403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
12697403Sobrien  hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
12797403Sobrien           const allocator_type& __a = allocator_type())
12897403Sobrien    : _M_ht(__n, __hf, __eql, __a) {}
12997403Sobrien
13097403Sobrien  template <class _InputIterator>
13197403Sobrien  hash_map(_InputIterator __f, _InputIterator __l)
13297403Sobrien    : _M_ht(100, hasher(), key_equal(), allocator_type())
13397403Sobrien    { _M_ht.insert_unique(__f, __l); }
13497403Sobrien  template <class _InputIterator>
13597403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
13697403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type())
13797403Sobrien    { _M_ht.insert_unique(__f, __l); }
13897403Sobrien  template <class _InputIterator>
13997403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
14097403Sobrien           const hasher& __hf)
14197403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type())
14297403Sobrien    { _M_ht.insert_unique(__f, __l); }
14397403Sobrien  template <class _InputIterator>
14497403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
14597403Sobrien           const hasher& __hf, const key_equal& __eql,
14697403Sobrien           const allocator_type& __a = allocator_type())
14797403Sobrien    : _M_ht(__n, __hf, __eql, __a)
14897403Sobrien    { _M_ht.insert_unique(__f, __l); }
14997403Sobrien
15097403Sobrienpublic:
15197403Sobrien  size_type size() const { return _M_ht.size(); }
15297403Sobrien  size_type max_size() const { return _M_ht.max_size(); }
15397403Sobrien  bool empty() const { return _M_ht.empty(); }
15497403Sobrien  void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
15597403Sobrien
15697403Sobrien  template <class _K1, class _T1, class _HF, class _EqK, class _Al>
15797403Sobrien  friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
15897403Sobrien                          const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
15997403Sobrien
16097403Sobrien  iterator begin() { return _M_ht.begin(); }
16197403Sobrien  iterator end() { return _M_ht.end(); }
16297403Sobrien  const_iterator begin() const { return _M_ht.begin(); }
16397403Sobrien  const_iterator end() const { return _M_ht.end(); }
16497403Sobrien
16597403Sobrienpublic:
16697403Sobrien  pair<iterator,bool> insert(const value_type& __obj)
16797403Sobrien    { return _M_ht.insert_unique(__obj); }
16897403Sobrien  template <class _InputIterator>
16997403Sobrien  void insert(_InputIterator __f, _InputIterator __l)
17097403Sobrien    { _M_ht.insert_unique(__f,__l); }
17197403Sobrien  pair<iterator,bool> insert_noresize(const value_type& __obj)
17297403Sobrien    { return _M_ht.insert_unique_noresize(__obj); }    
17397403Sobrien
17497403Sobrien  iterator find(const key_type& __key) { return _M_ht.find(__key); }
17597403Sobrien  const_iterator find(const key_type& __key) const 
17697403Sobrien    { return _M_ht.find(__key); }
17797403Sobrien
17897403Sobrien  _Tp& operator[](const key_type& __key) {
17997403Sobrien    return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
18097403Sobrien  }
18197403Sobrien
18297403Sobrien  size_type count(const key_type& __key) const { return _M_ht.count(__key); }
18397403Sobrien  
18497403Sobrien  pair<iterator, iterator> equal_range(const key_type& __key)
18597403Sobrien    { return _M_ht.equal_range(__key); }
18697403Sobrien  pair<const_iterator, const_iterator>
18797403Sobrien  equal_range(const key_type& __key) const
18897403Sobrien    { return _M_ht.equal_range(__key); }
18997403Sobrien
19097403Sobrien  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
19197403Sobrien  void erase(iterator __it) { _M_ht.erase(__it); }
19297403Sobrien  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
19397403Sobrien  void clear() { _M_ht.clear(); }
19497403Sobrien
19597403Sobrien  void resize(size_type __hint) { _M_ht.resize(__hint); }
19697403Sobrien  size_type bucket_count() const { return _M_ht.bucket_count(); }
19797403Sobrien  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
19897403Sobrien  size_type elems_in_bucket(size_type __n) const
19997403Sobrien    { return _M_ht.elems_in_bucket(__n); }
20097403Sobrien};
20197403Sobrien
20297403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
20397403Sobrieninline bool 
20497403Sobrienoperator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
20597403Sobrien           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
20697403Sobrien{
20797403Sobrien  return __hm1._M_ht == __hm2._M_ht;
20897403Sobrien}
20997403Sobrien
21097403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
21197403Sobrieninline bool 
21297403Sobrienoperator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
21397403Sobrien           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
21497403Sobrien  return !(__hm1 == __hm2);
21597403Sobrien}
21697403Sobrien
21797403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
21897403Sobrieninline void 
21997403Sobrienswap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
22097403Sobrien     hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
22197403Sobrien{
22297403Sobrien  __hm1.swap(__hm2);
22397403Sobrien}
22497403Sobrien
22597403Sobrien// Forward declaration of equality operator; needed for friend declaration.
22697403Sobrien
22797403Sobrientemplate <class _Key, class _Tp,
22897403Sobrien          class _HashFcn  = hash<_Key>,
22997403Sobrien          class _EqualKey = equal_to<_Key>,
23097403Sobrien          class _Alloc =  allocator<_Tp> >
23197403Sobrienclass hash_multimap;
23297403Sobrien
23397403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
23497403Sobrieninline bool 
23597403Sobrienoperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
23697403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2);
23797403Sobrien
23897403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
23997403Sobrienclass hash_multimap
24097403Sobrien{
24197403Sobrien  // concept requirements
24297403Sobrien  __glibcpp_class_requires(_Key, _SGIAssignableConcept)
24397403Sobrien  __glibcpp_class_requires(_Tp, _SGIAssignableConcept)
24497403Sobrien  __glibcpp_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept);
24597403Sobrien  __glibcpp_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept);
24697403Sobrien
24797403Sobrienprivate:
24897403Sobrien  typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
24997403Sobrien                    _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> 
25097403Sobrien          _Ht;
25197403Sobrien  _Ht _M_ht;
25297403Sobrien
25397403Sobrienpublic:
25497403Sobrien  typedef typename _Ht::key_type key_type;
25597403Sobrien  typedef _Tp data_type;
25697403Sobrien  typedef _Tp mapped_type;
25797403Sobrien  typedef typename _Ht::value_type value_type;
25897403Sobrien  typedef typename _Ht::hasher hasher;
25997403Sobrien  typedef typename _Ht::key_equal key_equal;
26097403Sobrien
26197403Sobrien  typedef typename _Ht::size_type size_type;
26297403Sobrien  typedef typename _Ht::difference_type difference_type;
26397403Sobrien  typedef typename _Ht::pointer pointer;
26497403Sobrien  typedef typename _Ht::const_pointer const_pointer;
26597403Sobrien  typedef typename _Ht::reference reference;
26697403Sobrien  typedef typename _Ht::const_reference const_reference;
26797403Sobrien
26897403Sobrien  typedef typename _Ht::iterator iterator;
26997403Sobrien  typedef typename _Ht::const_iterator const_iterator;
27097403Sobrien
27197403Sobrien  typedef typename _Ht::allocator_type allocator_type;
27297403Sobrien
27397403Sobrien  hasher hash_funct() const { return _M_ht.hash_funct(); }
27497403Sobrien  key_equal key_eq() const { return _M_ht.key_eq(); }
27597403Sobrien  allocator_type get_allocator() const { return _M_ht.get_allocator(); }
27697403Sobrien
27797403Sobrienpublic:
27897403Sobrien  hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
27997403Sobrien  explicit hash_multimap(size_type __n)
28097403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
28197403Sobrien  hash_multimap(size_type __n, const hasher& __hf)
28297403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
28397403Sobrien  hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
28497403Sobrien                const allocator_type& __a = allocator_type())
28597403Sobrien    : _M_ht(__n, __hf, __eql, __a) {}
28697403Sobrien
28797403Sobrien  template <class _InputIterator>
28897403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l)
28997403Sobrien    : _M_ht(100, hasher(), key_equal(), allocator_type())
29097403Sobrien    { _M_ht.insert_equal(__f, __l); }
29197403Sobrien  template <class _InputIterator>
29297403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
29397403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type())
29497403Sobrien    { _M_ht.insert_equal(__f, __l); }
29597403Sobrien  template <class _InputIterator>
29697403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
29797403Sobrien                const hasher& __hf)
29897403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type())
29997403Sobrien    { _M_ht.insert_equal(__f, __l); }
30097403Sobrien  template <class _InputIterator>
30197403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
30297403Sobrien                const hasher& __hf, const key_equal& __eql,
30397403Sobrien                const allocator_type& __a = allocator_type())
30497403Sobrien    : _M_ht(__n, __hf, __eql, __a)
30597403Sobrien    { _M_ht.insert_equal(__f, __l); }
30697403Sobrien
30797403Sobrienpublic:
30897403Sobrien  size_type size() const { return _M_ht.size(); }
30997403Sobrien  size_type max_size() const { return _M_ht.max_size(); }
31097403Sobrien  bool empty() const { return _M_ht.empty(); }
31197403Sobrien  void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
31297403Sobrien
31397403Sobrien  template <class _K1, class _T1, class _HF, class _EqK, class _Al>
31497403Sobrien  friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
31597403Sobrien                          const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
31697403Sobrien
31797403Sobrien  iterator begin() { return _M_ht.begin(); }
31897403Sobrien  iterator end() { return _M_ht.end(); }
31997403Sobrien  const_iterator begin() const { return _M_ht.begin(); }
32097403Sobrien  const_iterator end() const { return _M_ht.end(); }
32197403Sobrien
32297403Sobrienpublic:
32397403Sobrien  iterator insert(const value_type& __obj) 
32497403Sobrien    { return _M_ht.insert_equal(__obj); }
32597403Sobrien  template <class _InputIterator>
32697403Sobrien  void insert(_InputIterator __f, _InputIterator __l) 
32797403Sobrien    { _M_ht.insert_equal(__f,__l); }
32897403Sobrien  iterator insert_noresize(const value_type& __obj)
32997403Sobrien    { return _M_ht.insert_equal_noresize(__obj); }    
33097403Sobrien
33197403Sobrien  iterator find(const key_type& __key) { return _M_ht.find(__key); }
33297403Sobrien  const_iterator find(const key_type& __key) const 
33397403Sobrien    { return _M_ht.find(__key); }
33497403Sobrien
33597403Sobrien  size_type count(const key_type& __key) const { return _M_ht.count(__key); }
33697403Sobrien  
33797403Sobrien  pair<iterator, iterator> equal_range(const key_type& __key)
33897403Sobrien    { return _M_ht.equal_range(__key); }
33997403Sobrien  pair<const_iterator, const_iterator>
34097403Sobrien  equal_range(const key_type& __key) const
34197403Sobrien    { return _M_ht.equal_range(__key); }
34297403Sobrien
34397403Sobrien  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
34497403Sobrien  void erase(iterator __it) { _M_ht.erase(__it); }
34597403Sobrien  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
34697403Sobrien  void clear() { _M_ht.clear(); }
34797403Sobrien
34897403Sobrienpublic:
34997403Sobrien  void resize(size_type __hint) { _M_ht.resize(__hint); }
35097403Sobrien  size_type bucket_count() const { return _M_ht.bucket_count(); }
35197403Sobrien  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
35297403Sobrien  size_type elems_in_bucket(size_type __n) const
35397403Sobrien    { return _M_ht.elems_in_bucket(__n); }
35497403Sobrien};
35597403Sobrien
35697403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
35797403Sobrieninline bool 
35897403Sobrienoperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
35997403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
36097403Sobrien{
36197403Sobrien  return __hm1._M_ht == __hm2._M_ht;
36297403Sobrien}
36397403Sobrien
36497403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
36597403Sobrieninline bool 
36697403Sobrienoperator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
36797403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {
36897403Sobrien  return !(__hm1 == __hm2);
36997403Sobrien}
37097403Sobrien
37197403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
37297403Sobrieninline void 
37397403Sobrienswap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
37497403Sobrien     hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
37597403Sobrien{
37697403Sobrien  __hm1.swap(__hm2);
37797403Sobrien}
37897403Sobrien
37997403Sobrien} // namespace __gnu_cxx
38097403Sobrien
38197403Sobriennamespace std
38297403Sobrien{
38397403Sobrien// Specialization of insert_iterator so that it will work for hash_map
38497403Sobrien// and hash_multimap.
38597403Sobrien
38697403Sobrientemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
38797403Sobrienclass insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
38897403Sobrienprotected:
38997403Sobrien  typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
39097403Sobrien  _Container* container;
39197403Sobrienpublic:
39297403Sobrien  typedef _Container          container_type;
39397403Sobrien  typedef output_iterator_tag iterator_category;
39497403Sobrien  typedef void                value_type;
39597403Sobrien  typedef void                difference_type;
39697403Sobrien  typedef void                pointer;
39797403Sobrien  typedef void                reference;
39897403Sobrien
39997403Sobrien  insert_iterator(_Container& __x) : container(&__x) {}
40097403Sobrien  insert_iterator(_Container& __x, typename _Container::iterator)
40197403Sobrien    : container(&__x) {}
40297403Sobrien  insert_iterator<_Container>&
40397403Sobrien  operator=(const typename _Container::value_type& __value) { 
40497403Sobrien    container->insert(__value);
40597403Sobrien    return *this;
40697403Sobrien  }
40797403Sobrien  insert_iterator<_Container>& operator*() { return *this; }
40897403Sobrien  insert_iterator<_Container>& operator++() { return *this; }
40997403Sobrien  insert_iterator<_Container>& operator++(int) { return *this; }
41097403Sobrien};
41197403Sobrien
41297403Sobrientemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
41397403Sobrienclass insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
41497403Sobrienprotected:
41597403Sobrien  typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
41697403Sobrien  _Container* container;
41797403Sobrien  typename _Container::iterator iter;
41897403Sobrienpublic:
41997403Sobrien  typedef _Container          container_type;
42097403Sobrien  typedef output_iterator_tag iterator_category;
42197403Sobrien  typedef void                value_type;
42297403Sobrien  typedef void                difference_type;
42397403Sobrien  typedef void                pointer;
42497403Sobrien  typedef void                reference;
42597403Sobrien
42697403Sobrien  insert_iterator(_Container& __x) : container(&__x) {}
42797403Sobrien  insert_iterator(_Container& __x, typename _Container::iterator)
42897403Sobrien    : container(&__x) {}
42997403Sobrien  insert_iterator<_Container>&
43097403Sobrien  operator=(const typename _Container::value_type& __value) { 
43197403Sobrien    container->insert(__value);
43297403Sobrien    return *this;
43397403Sobrien  }
43497403Sobrien  insert_iterator<_Container>& operator*() { return *this; }
43597403Sobrien  insert_iterator<_Container>& operator++() { return *this; }
43697403Sobrien  insert_iterator<_Container>& operator++(int) { return *this; }
43797403Sobrien};
43897403Sobrien
43997403Sobrien} // namespace std
44097403Sobrien
44197403Sobrien#endif /* __SGI_STL_INTERNAL_HASH_MAP_H */
44297403Sobrien
44397403Sobrien// Local Variables:
44497403Sobrien// mode:C++
44597403Sobrien// End:
446