hash_map revision 132720
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
62132720Skan#ifndef _HASH_MAP
63132720Skan#define _HASH_MAP 1
6497403Sobrien
65132720Skan#include <ext/hashtable.h>
6697403Sobrien#include <bits/concept_check.h>
6797403Sobrien
6897403Sobriennamespace __gnu_cxx
6997403Sobrien{
70132720Skan  using std::equal_to;
71132720Skan  using std::allocator;
72132720Skan  using std::pair;
73132720Skan  using std::_Select1st;
7497403Sobrien
75132720Skan  // Forward declaration of equality operator; needed for friend
76132720Skan  // declaration.
77132720Skan  template<class _Key, class _Tp, class _HashFcn  = hash<_Key>,
78132720Skan	    class _EqualKey = equal_to<_Key>, class _Alloc =  allocator<_Tp> >
79132720Skan    class hash_map;
8097403Sobrien
81132720Skan  template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
82132720Skan  inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
83132720Skan			 const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
84102782Skan/**
85102782Skan *  This is an SGI extension.
86102782Skan *  @ingroup SGIextensions
87102782Skan *  @doctodo
88102782Skan*/
8997403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey,
9097403Sobrien          class _Alloc>
9197403Sobrienclass hash_map
9297403Sobrien{
9397403Sobrienprivate:
9497403Sobrien  typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn,
9597403Sobrien                    _Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht;
9697403Sobrien  _Ht _M_ht;
9797403Sobrien
9897403Sobrienpublic:
9997403Sobrien  typedef typename _Ht::key_type key_type;
10097403Sobrien  typedef _Tp data_type;
10197403Sobrien  typedef _Tp mapped_type;
10297403Sobrien  typedef typename _Ht::value_type value_type;
10397403Sobrien  typedef typename _Ht::hasher hasher;
10497403Sobrien  typedef typename _Ht::key_equal key_equal;
105132720Skan
10697403Sobrien  typedef typename _Ht::size_type size_type;
10797403Sobrien  typedef typename _Ht::difference_type difference_type;
10897403Sobrien  typedef typename _Ht::pointer pointer;
10997403Sobrien  typedef typename _Ht::const_pointer const_pointer;
11097403Sobrien  typedef typename _Ht::reference reference;
11197403Sobrien  typedef typename _Ht::const_reference const_reference;
11297403Sobrien
11397403Sobrien  typedef typename _Ht::iterator iterator;
11497403Sobrien  typedef typename _Ht::const_iterator const_iterator;
11597403Sobrien
11697403Sobrien  typedef typename _Ht::allocator_type allocator_type;
11797403Sobrien
11897403Sobrien  hasher hash_funct() const { return _M_ht.hash_funct(); }
11997403Sobrien  key_equal key_eq() const { return _M_ht.key_eq(); }
12097403Sobrien  allocator_type get_allocator() const { return _M_ht.get_allocator(); }
12197403Sobrien
12297403Sobrienpublic:
12397403Sobrien  hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
12497403Sobrien  explicit hash_map(size_type __n)
12597403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
12697403Sobrien  hash_map(size_type __n, const hasher& __hf)
12797403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
12897403Sobrien  hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
12997403Sobrien           const allocator_type& __a = allocator_type())
13097403Sobrien    : _M_ht(__n, __hf, __eql, __a) {}
13197403Sobrien
13297403Sobrien  template <class _InputIterator>
13397403Sobrien  hash_map(_InputIterator __f, _InputIterator __l)
13497403Sobrien    : _M_ht(100, hasher(), key_equal(), allocator_type())
13597403Sobrien    { _M_ht.insert_unique(__f, __l); }
13697403Sobrien  template <class _InputIterator>
13797403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
13897403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type())
13997403Sobrien    { _M_ht.insert_unique(__f, __l); }
14097403Sobrien  template <class _InputIterator>
14197403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
14297403Sobrien           const hasher& __hf)
14397403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type())
14497403Sobrien    { _M_ht.insert_unique(__f, __l); }
14597403Sobrien  template <class _InputIterator>
14697403Sobrien  hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
14797403Sobrien           const hasher& __hf, const key_equal& __eql,
14897403Sobrien           const allocator_type& __a = allocator_type())
14997403Sobrien    : _M_ht(__n, __hf, __eql, __a)
15097403Sobrien    { _M_ht.insert_unique(__f, __l); }
15197403Sobrien
15297403Sobrienpublic:
15397403Sobrien  size_type size() const { return _M_ht.size(); }
15497403Sobrien  size_type max_size() const { return _M_ht.max_size(); }
15597403Sobrien  bool empty() const { return _M_ht.empty(); }
15697403Sobrien  void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
15797403Sobrien
15897403Sobrien  template <class _K1, class _T1, class _HF, class _EqK, class _Al>
15997403Sobrien  friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
16097403Sobrien                          const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
16197403Sobrien
16297403Sobrien  iterator begin() { return _M_ht.begin(); }
16397403Sobrien  iterator end() { return _M_ht.end(); }
16497403Sobrien  const_iterator begin() const { return _M_ht.begin(); }
16597403Sobrien  const_iterator end() const { return _M_ht.end(); }
16697403Sobrien
16797403Sobrienpublic:
16897403Sobrien  pair<iterator,bool> insert(const value_type& __obj)
16997403Sobrien    { return _M_ht.insert_unique(__obj); }
17097403Sobrien  template <class _InputIterator>
17197403Sobrien  void insert(_InputIterator __f, _InputIterator __l)
17297403Sobrien    { _M_ht.insert_unique(__f,__l); }
17397403Sobrien  pair<iterator,bool> insert_noresize(const value_type& __obj)
174132720Skan    { return _M_ht.insert_unique_noresize(__obj); }
17597403Sobrien
17697403Sobrien  iterator find(const key_type& __key) { return _M_ht.find(__key); }
177132720Skan  const_iterator find(const key_type& __key) const
17897403Sobrien    { return _M_ht.find(__key); }
17997403Sobrien
18097403Sobrien  _Tp& operator[](const key_type& __key) {
18197403Sobrien    return _M_ht.find_or_insert(value_type(__key, _Tp())).second;
18297403Sobrien  }
18397403Sobrien
18497403Sobrien  size_type count(const key_type& __key) const { return _M_ht.count(__key); }
185132720Skan
18697403Sobrien  pair<iterator, iterator> equal_range(const key_type& __key)
18797403Sobrien    { return _M_ht.equal_range(__key); }
18897403Sobrien  pair<const_iterator, const_iterator>
18997403Sobrien  equal_range(const key_type& __key) const
19097403Sobrien    { return _M_ht.equal_range(__key); }
19197403Sobrien
19297403Sobrien  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
19397403Sobrien  void erase(iterator __it) { _M_ht.erase(__it); }
19497403Sobrien  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
19597403Sobrien  void clear() { _M_ht.clear(); }
19697403Sobrien
19797403Sobrien  void resize(size_type __hint) { _M_ht.resize(__hint); }
19897403Sobrien  size_type bucket_count() const { return _M_ht.bucket_count(); }
19997403Sobrien  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
20097403Sobrien  size_type elems_in_bucket(size_type __n) const
20197403Sobrien    { return _M_ht.elems_in_bucket(__n); }
20297403Sobrien};
20397403Sobrien
20497403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
205132720Skaninline bool
20697403Sobrienoperator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
20797403Sobrien           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
20897403Sobrien{
20997403Sobrien  return __hm1._M_ht == __hm2._M_ht;
21097403Sobrien}
21197403Sobrien
21297403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
213132720Skaninline bool
21497403Sobrienoperator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
21597403Sobrien           const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
21697403Sobrien  return !(__hm1 == __hm2);
21797403Sobrien}
21897403Sobrien
21997403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
220132720Skaninline void
22197403Sobrienswap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
22297403Sobrien     hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
22397403Sobrien{
22497403Sobrien  __hm1.swap(__hm2);
22597403Sobrien}
22697403Sobrien
22797403Sobrien// Forward declaration of equality operator; needed for friend declaration.
22897403Sobrien
22997403Sobrientemplate <class _Key, class _Tp,
23097403Sobrien          class _HashFcn  = hash<_Key>,
23197403Sobrien          class _EqualKey = equal_to<_Key>,
23297403Sobrien          class _Alloc =  allocator<_Tp> >
23397403Sobrienclass hash_multimap;
23497403Sobrien
23597403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
236132720Skaninline bool
23797403Sobrienoperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
23897403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2);
23997403Sobrien
240102782Skan/**
241102782Skan *  This is an SGI extension.
242102782Skan *  @ingroup SGIextensions
243102782Skan *  @doctodo
244102782Skan*/
24597403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc>
24697403Sobrienclass hash_multimap
24797403Sobrien{
24897403Sobrien  // concept requirements
249132720Skan  __glibcxx_class_requires(_Key, _SGIAssignableConcept)
250132720Skan  __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
251132720Skan  __glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept)
252132720Skan  __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
25397403Sobrien
25497403Sobrienprivate:
25597403Sobrien  typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
256132720Skan                    _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
25797403Sobrien          _Ht;
25897403Sobrien  _Ht _M_ht;
25997403Sobrien
26097403Sobrienpublic:
26197403Sobrien  typedef typename _Ht::key_type key_type;
26297403Sobrien  typedef _Tp data_type;
26397403Sobrien  typedef _Tp mapped_type;
26497403Sobrien  typedef typename _Ht::value_type value_type;
26597403Sobrien  typedef typename _Ht::hasher hasher;
26697403Sobrien  typedef typename _Ht::key_equal key_equal;
26797403Sobrien
26897403Sobrien  typedef typename _Ht::size_type size_type;
26997403Sobrien  typedef typename _Ht::difference_type difference_type;
27097403Sobrien  typedef typename _Ht::pointer pointer;
27197403Sobrien  typedef typename _Ht::const_pointer const_pointer;
27297403Sobrien  typedef typename _Ht::reference reference;
27397403Sobrien  typedef typename _Ht::const_reference const_reference;
27497403Sobrien
27597403Sobrien  typedef typename _Ht::iterator iterator;
27697403Sobrien  typedef typename _Ht::const_iterator const_iterator;
27797403Sobrien
27897403Sobrien  typedef typename _Ht::allocator_type allocator_type;
27997403Sobrien
28097403Sobrien  hasher hash_funct() const { return _M_ht.hash_funct(); }
28197403Sobrien  key_equal key_eq() const { return _M_ht.key_eq(); }
28297403Sobrien  allocator_type get_allocator() const { return _M_ht.get_allocator(); }
28397403Sobrien
28497403Sobrienpublic:
28597403Sobrien  hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
28697403Sobrien  explicit hash_multimap(size_type __n)
28797403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
28897403Sobrien  hash_multimap(size_type __n, const hasher& __hf)
28997403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
29097403Sobrien  hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
29197403Sobrien                const allocator_type& __a = allocator_type())
29297403Sobrien    : _M_ht(__n, __hf, __eql, __a) {}
29397403Sobrien
29497403Sobrien  template <class _InputIterator>
29597403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l)
29697403Sobrien    : _M_ht(100, hasher(), key_equal(), allocator_type())
29797403Sobrien    { _M_ht.insert_equal(__f, __l); }
29897403Sobrien  template <class _InputIterator>
29997403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
30097403Sobrien    : _M_ht(__n, hasher(), key_equal(), allocator_type())
30197403Sobrien    { _M_ht.insert_equal(__f, __l); }
30297403Sobrien  template <class _InputIterator>
30397403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
30497403Sobrien                const hasher& __hf)
30597403Sobrien    : _M_ht(__n, __hf, key_equal(), allocator_type())
30697403Sobrien    { _M_ht.insert_equal(__f, __l); }
30797403Sobrien  template <class _InputIterator>
30897403Sobrien  hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
30997403Sobrien                const hasher& __hf, const key_equal& __eql,
31097403Sobrien                const allocator_type& __a = allocator_type())
31197403Sobrien    : _M_ht(__n, __hf, __eql, __a)
31297403Sobrien    { _M_ht.insert_equal(__f, __l); }
31397403Sobrien
31497403Sobrienpublic:
31597403Sobrien  size_type size() const { return _M_ht.size(); }
31697403Sobrien  size_type max_size() const { return _M_ht.max_size(); }
31797403Sobrien  bool empty() const { return _M_ht.empty(); }
31897403Sobrien  void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
31997403Sobrien
32097403Sobrien  template <class _K1, class _T1, class _HF, class _EqK, class _Al>
32197403Sobrien  friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
32297403Sobrien                          const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
32397403Sobrien
32497403Sobrien  iterator begin() { return _M_ht.begin(); }
32597403Sobrien  iterator end() { return _M_ht.end(); }
32697403Sobrien  const_iterator begin() const { return _M_ht.begin(); }
32797403Sobrien  const_iterator end() const { return _M_ht.end(); }
32897403Sobrien
32997403Sobrienpublic:
330132720Skan  iterator insert(const value_type& __obj)
33197403Sobrien    { return _M_ht.insert_equal(__obj); }
33297403Sobrien  template <class _InputIterator>
333132720Skan  void insert(_InputIterator __f, _InputIterator __l)
33497403Sobrien    { _M_ht.insert_equal(__f,__l); }
33597403Sobrien  iterator insert_noresize(const value_type& __obj)
336132720Skan    { return _M_ht.insert_equal_noresize(__obj); }
33797403Sobrien
33897403Sobrien  iterator find(const key_type& __key) { return _M_ht.find(__key); }
339132720Skan  const_iterator find(const key_type& __key) const
34097403Sobrien    { return _M_ht.find(__key); }
34197403Sobrien
34297403Sobrien  size_type count(const key_type& __key) const { return _M_ht.count(__key); }
343132720Skan
34497403Sobrien  pair<iterator, iterator> equal_range(const key_type& __key)
34597403Sobrien    { return _M_ht.equal_range(__key); }
34697403Sobrien  pair<const_iterator, const_iterator>
34797403Sobrien  equal_range(const key_type& __key) const
34897403Sobrien    { return _M_ht.equal_range(__key); }
34997403Sobrien
35097403Sobrien  size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
35197403Sobrien  void erase(iterator __it) { _M_ht.erase(__it); }
35297403Sobrien  void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
35397403Sobrien  void clear() { _M_ht.clear(); }
35497403Sobrien
35597403Sobrienpublic:
35697403Sobrien  void resize(size_type __hint) { _M_ht.resize(__hint); }
35797403Sobrien  size_type bucket_count() const { return _M_ht.bucket_count(); }
35897403Sobrien  size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
35997403Sobrien  size_type elems_in_bucket(size_type __n) const
36097403Sobrien    { return _M_ht.elems_in_bucket(__n); }
36197403Sobrien};
36297403Sobrien
36397403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
364132720Skaninline bool
36597403Sobrienoperator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
36697403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2)
36797403Sobrien{
36897403Sobrien  return __hm1._M_ht == __hm2._M_ht;
36997403Sobrien}
37097403Sobrien
37197403Sobrientemplate <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
372132720Skaninline bool
37397403Sobrienoperator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
37497403Sobrien           const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {
37597403Sobrien  return !(__hm1 == __hm2);
37697403Sobrien}
37797403Sobrien
37897403Sobrientemplate <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
379132720Skaninline void
38097403Sobrienswap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
38197403Sobrien     hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
38297403Sobrien{
38397403Sobrien  __hm1.swap(__hm2);
38497403Sobrien}
38597403Sobrien
38697403Sobrien} // namespace __gnu_cxx
38797403Sobrien
38897403Sobriennamespace std
38997403Sobrien{
39097403Sobrien// Specialization of insert_iterator so that it will work for hash_map
39197403Sobrien// and hash_multimap.
39297403Sobrien
39397403Sobrientemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
39497403Sobrienclass insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
39597403Sobrienprotected:
39697403Sobrien  typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
39797403Sobrien  _Container* container;
39897403Sobrienpublic:
39997403Sobrien  typedef _Container          container_type;
40097403Sobrien  typedef output_iterator_tag iterator_category;
40197403Sobrien  typedef void                value_type;
40297403Sobrien  typedef void                difference_type;
40397403Sobrien  typedef void                pointer;
40497403Sobrien  typedef void                reference;
40597403Sobrien
40697403Sobrien  insert_iterator(_Container& __x) : container(&__x) {}
40797403Sobrien  insert_iterator(_Container& __x, typename _Container::iterator)
40897403Sobrien    : container(&__x) {}
40997403Sobrien  insert_iterator<_Container>&
410132720Skan  operator=(const typename _Container::value_type& __value) {
41197403Sobrien    container->insert(__value);
41297403Sobrien    return *this;
41397403Sobrien  }
41497403Sobrien  insert_iterator<_Container>& operator*() { return *this; }
41597403Sobrien  insert_iterator<_Container>& operator++() { return *this; }
41697403Sobrien  insert_iterator<_Container>& operator++(int) { return *this; }
41797403Sobrien};
41897403Sobrien
41997403Sobrientemplate <class _Key, class _Tp, class _HashFn,  class _EqKey, class _Alloc>
42097403Sobrienclass insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
42197403Sobrienprotected:
42297403Sobrien  typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
42397403Sobrien  _Container* container;
42497403Sobrien  typename _Container::iterator iter;
42597403Sobrienpublic:
42697403Sobrien  typedef _Container          container_type;
42797403Sobrien  typedef output_iterator_tag iterator_category;
42897403Sobrien  typedef void                value_type;
42997403Sobrien  typedef void                difference_type;
43097403Sobrien  typedef void                pointer;
43197403Sobrien  typedef void                reference;
43297403Sobrien
43397403Sobrien  insert_iterator(_Container& __x) : container(&__x) {}
43497403Sobrien  insert_iterator(_Container& __x, typename _Container::iterator)
43597403Sobrien    : container(&__x) {}
43697403Sobrien  insert_iterator<_Container>&
437132720Skan  operator=(const typename _Container::value_type& __value) {
43897403Sobrien    container->insert(__value);
43997403Sobrien    return *this;
44097403Sobrien  }
44197403Sobrien  insert_iterator<_Container>& operator*() { return *this; }
44297403Sobrien  insert_iterator<_Container>& operator++() { return *this; }
44397403Sobrien  insert_iterator<_Container>& operator++(int) { return *this; }
44497403Sobrien};
44597403Sobrien} // namespace std
44697403Sobrien
447132720Skan#endif
448