Commit d962e073 by Paolo Carlini Committed by Paolo Carlini

hash_map: Trivial formatting fixes.

2004-06-14  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/hash_map: Trivial formatting fixes.
	* include/ext/hash_set: Likewise.
	* include/ext/memory: Likewise.
	* include/ext/numeric: Likewise.

From-SVN: r83131
parent f51d8522
2004-06-14 Paolo Carlini <pcarlini@suse.de>
* include/ext/hash_map: Trivial formatting fixes.
* include/ext/hash_set: Likewise.
* include/ext/memory: Likewise.
* include/ext/numeric: Likewise.
2004-06-14 Benjamin Kosnik <bkoz@redhat.com> 2004-06-14 Benjamin Kosnik <bkoz@redhat.com>
* Makefile.in: Regenerate with automake 1.8.5. * Makefile.in: Regenerate with automake 1.8.5.
......
// Hashing map implementation -*- C++ -*- // Hashing map implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -79,23 +79,27 @@ namespace __gnu_cxx ...@@ -79,23 +79,27 @@ namespace __gnu_cxx
class hash_map; class hash_map;
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&, inline bool
operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&); const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
/**
/**
* This is an SGI extension. * This is an SGI extension.
* @ingroup SGIextensions * @ingroup SGIextensions
* @doctodo * @doctodo
*/ */
template <class _Key, class _Tp, class _HashFcn, class _EqualKey, template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
class _Alloc> class _Alloc>
class hash_map class hash_map
{ {
private: private:
typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn, typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFcn,
_Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht; _Select1st<pair<const _Key, _Tp> >,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht; _Ht _M_ht;
public: public:
typedef typename _Ht::key_type key_type; typedef typename _Ht::key_type key_type;
typedef _Tp data_type; typedef _Tp data_type;
typedef _Tp mapped_type; typedef _Tp mapped_type;
...@@ -115,16 +119,29 @@ public: ...@@ -115,16 +119,29 @@ public:
typedef typename _Ht::allocator_type allocator_type; typedef typename _Ht::allocator_type allocator_type;
hasher hash_funct() const { return _M_ht.hash_funct(); } hasher
key_equal key_eq() const { return _M_ht.key_eq(); } hash_funct() const
allocator_type get_allocator() const { return _M_ht.get_allocator(); } { return _M_ht.hash_funct(); }
public: key_equal
hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} key_eq() const
explicit hash_map(size_type __n) { return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
public:
hash_map()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_map(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_map(size_type __n, const hasher& __hf) hash_map(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {} : _M_ht(__n, __hf, __eql, __a) {}
...@@ -133,15 +150,18 @@ public: ...@@ -133,15 +150,18 @@ public:
hash_map(_InputIterator __f, _InputIterator __l) hash_map(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type()) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n) hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n, hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf) const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) : _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n, hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql, const hasher& __hf, const key_equal& __eql,
...@@ -149,115 +169,169 @@ public: ...@@ -149,115 +169,169 @@ public:
: _M_ht(__n, __hf, __eql, __a) : _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
public: public:
size_type size() const { return _M_ht.size(); } size_type
size_type max_size() const { return _M_ht.max_size(); } size() const
bool empty() const { return _M_ht.empty(); } { return _M_ht.size(); }
void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_map& __hs)
{ _M_ht.swap(__hs._M_ht); }
template <class _K1, class _T1, class _HF, class _EqK, class _Al> template <class _K1, class _T1, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, friend bool
operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
const hash_map<_K1, _T1, _HF, _EqK, _Al>&); const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
iterator begin() { return _M_ht.begin(); } iterator
iterator end() { return _M_ht.end(); } begin()
const_iterator begin() const { return _M_ht.begin(); } { return _M_ht.begin(); }
const_iterator end() const { return _M_ht.end(); }
public: iterator
pair<iterator,bool> insert(const value_type& __obj) end()
{ return _M_ht.end(); }
const_iterator
begin() const
{ return _M_ht.begin(); }
const_iterator
end() const
{ return _M_ht.end(); }
public:
pair<iterator, bool>
insert(const value_type& __obj)
{ return _M_ht.insert_unique(__obj); } { return _M_ht.insert_unique(__obj); }
template <class _InputIterator> template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l) void
{ _M_ht.insert_unique(__f,__l); } insert(_InputIterator __f, _InputIterator __l)
pair<iterator,bool> insert_noresize(const value_type& __obj) { _M_ht.insert_unique(__f, __l); }
pair<iterator, bool>
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_unique_noresize(__obj); } { return _M_ht.insert_unique_noresize(__obj); }
iterator find(const key_type& __key) { return _M_ht.find(__key); } iterator
const_iterator find(const key_type& __key) const find(const key_type& __key)
{ return _M_ht.find(__key); } { return _M_ht.find(__key); }
_Tp& operator[](const key_type& __key) { const_iterator
return _M_ht.find_or_insert(value_type(__key, _Tp())).second; find(const key_type& __key) const
} { return _M_ht.find(__key); }
_Tp&
operator[](const key_type& __key)
{ return _M_ht.find_or_insert(value_type(__key, _Tp())).second; }
size_type count(const key_type& __key) const { return _M_ht.count(__key); } size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator> equal_range(const key_type& __key) pair<iterator, iterator>
equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator> pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } size_type
void erase(iterator __it) { _M_ht.erase(__it); } erase(const key_type& __key)
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } {return _M_ht.erase(__key); }
void clear() { _M_ht.clear(); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
void resize(size_type __hint) { _M_ht.resize(__hint); } size_type
size_type bucket_count() const { return _M_ht.bucket_count(); } bucket_count() const
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } { return _M_ht.bucket_count(); }
size_type elems_in_bucket(size_type __n) const
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); } { return _M_ht.elems_in_bucket(__n); }
}; };
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline bool inline bool
operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, operator==(const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
{ { return __hm1._M_ht == __hm2._M_ht; }
return __hm1._M_ht == __hm2._M_ht;
} template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline bool
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> operator!=(const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
inline bool const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, { return !(__hm1 == __hm2); }
const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) {
return !(__hm1 == __hm2);
}
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline void
swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
{
__hm1.swap(__hm2);
}
// Forward declaration of equality operator; needed for friend declaration. template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline void
swap(hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
{ __hm1.swap(__hm2); }
template <class _Key, class _Tp, // Forward declaration of equality operator; needed for friend declaration.
template <class _Key, class _Tp,
class _HashFcn = hash<_Key>, class _HashFcn = hash<_Key>,
class _EqualKey = equal_to<_Key>, class _EqualKey = equal_to<_Key>,
class _Alloc = allocator<_Tp> > class _Alloc = allocator<_Tp> >
class hash_multimap; class hash_multimap;
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool inline bool
operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2); const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2);
/** /**
* This is an SGI extension. * This is an SGI extension.
* @ingroup SGIextensions * @ingroup SGIextensions
* @doctodo * @doctodo
*/ */
template <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc> template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
class hash_multimap class _Alloc>
{ class hash_multimap
{
// concept requirements // concept requirements
__glibcxx_class_requires(_Key, _SGIAssignableConcept) __glibcxx_class_requires(_Key, _SGIAssignableConcept)
__glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept) __glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
private: private:
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn, typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
_Ht; _Ht;
_Ht _M_ht; _Ht _M_ht;
public: public:
typedef typename _Ht::key_type key_type; typedef typename _Ht::key_type key_type;
typedef _Tp data_type; typedef _Tp data_type;
typedef _Tp mapped_type; typedef _Tp mapped_type;
...@@ -277,16 +351,29 @@ public: ...@@ -277,16 +351,29 @@ public:
typedef typename _Ht::allocator_type allocator_type; typedef typename _Ht::allocator_type allocator_type;
hasher hash_funct() const { return _M_ht.hash_funct(); } hasher
key_equal key_eq() const { return _M_ht.key_eq(); } hash_funct() const
allocator_type get_allocator() const { return _M_ht.get_allocator(); } { return _M_ht.hash_funct(); }
public: key_equal
hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} key_eq() const
explicit hash_multimap(size_type __n) { return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
public:
hash_multimap()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_multimap(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_multimap(size_type __n, const hasher& __hf) hash_multimap(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {} : _M_ht(__n, __hf, __eql, __a) {}
...@@ -295,15 +382,18 @@ public: ...@@ -295,15 +382,18 @@ public:
hash_multimap(_InputIterator __f, _InputIterator __l) hash_multimap(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type()) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf) const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) : _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql, const hasher& __hf, const key_equal& __eql,
...@@ -311,77 +401,129 @@ public: ...@@ -311,77 +401,129 @@ public:
: _M_ht(__n, __hf, __eql, __a) : _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
public: public:
size_type size() const { return _M_ht.size(); } size_type
size_type max_size() const { return _M_ht.max_size(); } size() const
bool empty() const { return _M_ht.empty(); } { return _M_ht.size(); }
void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_multimap& __hs)
{ _M_ht.swap(__hs._M_ht); }
template <class _K1, class _T1, class _HF, class _EqK, class _Al> template <class _K1, class _T1, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, friend bool
operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
iterator begin() { return _M_ht.begin(); } iterator
iterator end() { return _M_ht.end(); } begin()
const_iterator begin() const { return _M_ht.begin(); } { return _M_ht.begin(); }
const_iterator end() const { return _M_ht.end(); }
iterator
end()
{ return _M_ht.end(); }
const_iterator
begin() const
{ return _M_ht.begin(); }
const_iterator
end() const
{ return _M_ht.end(); }
public: public:
iterator insert(const value_type& __obj) iterator
insert(const value_type& __obj)
{ return _M_ht.insert_equal(__obj); } { return _M_ht.insert_equal(__obj); }
template <class _InputIterator> template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l) void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); } { _M_ht.insert_equal(__f,__l); }
iterator insert_noresize(const value_type& __obj)
iterator
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); } { return _M_ht.insert_equal_noresize(__obj); }
iterator find(const key_type& __key) { return _M_ht.find(__key); } iterator
const_iterator find(const key_type& __key) const find(const key_type& __key)
{ return _M_ht.find(__key); } { return _M_ht.find(__key); }
size_type count(const key_type& __key) const { return _M_ht.count(__key); } const_iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
pair<iterator, iterator> equal_range(const key_type& __key) size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator>
equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator> pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } size_type
void erase(iterator __it) { _M_ht.erase(__it); } erase(const key_type& __key)
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } { return _M_ht.erase(__key); }
void clear() { _M_ht.clear(); }
public: void
void resize(size_type __hint) { _M_ht.resize(__hint); } erase(iterator __it)
size_type bucket_count() const { return _M_ht.bucket_count(); } { _M_ht.erase(__it); }
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
size_type elems_in_bucket(size_type __n) const void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
public:
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); } { return _M_ht.elems_in_bucket(__n); }
}; };
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool inline bool
operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
{ { return __hm1._M_ht == __hm2._M_ht; }
return __hm1._M_ht == __hm2._M_ht;
} template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
inline bool const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, { return !(__hm1 == __hm2); }
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) {
return !(__hm1 == __hm2); template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
} inline void
swap(hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
inline void { __hm1.swap(__hm2); }
swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
{
__hm1.swap(__hm2);
}
} // namespace __gnu_cxx } // namespace __gnu_cxx
...@@ -390,12 +532,16 @@ namespace std ...@@ -390,12 +532,16 @@ namespace std
// Specialization of insert_iterator so that it will work for hash_map // Specialization of insert_iterator so that it will work for hash_map
// and hash_multimap. // and hash_multimap.
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn,
protected: _EqKey, _Alloc> >
typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; {
protected:
typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>
_Container;
_Container* container; _Container* container;
public:
public:
typedef _Container container_type; typedef _Container container_type;
typedef output_iterator_tag iterator_category; typedef output_iterator_tag iterator_category;
typedef void value_type; typedef void value_type;
...@@ -403,26 +549,42 @@ public: ...@@ -403,26 +549,42 @@ public:
typedef void pointer; typedef void pointer;
typedef void reference; typedef void reference;
insert_iterator(_Container& __x) : container(&__x) {} insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator) insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {} : container(&__x) {}
insert_iterator<_Container>& insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { operator=(const typename _Container::value_type& __value)
{
container->insert(__value); container->insert(__value);
return *this; return *this;
} }
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; }
};
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> insert_iterator<_Container>&
class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { operator*()
protected: { return *this; }
typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
insert_iterator<_Container>&
operator++() { return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn,
_EqKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
_Container;
_Container* container; _Container* container;
typename _Container::iterator iter; typename _Container::iterator iter;
public:
public:
typedef _Container container_type; typedef _Container container_type;
typedef output_iterator_tag iterator_category; typedef output_iterator_tag iterator_category;
typedef void value_type; typedef void value_type;
...@@ -430,18 +592,30 @@ public: ...@@ -430,18 +592,30 @@ public:
typedef void pointer; typedef void pointer;
typedef void reference; typedef void reference;
insert_iterator(_Container& __x) : container(&__x) {} insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator) insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {} : container(&__x) {}
insert_iterator<_Container>& insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { operator=(const typename _Container::value_type& __value)
{
container->insert(__value); container->insert(__value);
return *this; return *this;
} }
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; }
};
} // namespace std
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
} // namespace std
#endif #endif
// Hashing set implementation -*- C++ -*- // Hashing set implementation -*- C++ -*-
// Copyright (C) 2001, 2002 Free Software Foundation, Inc. // Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -81,28 +81,28 @@ namespace __gnu_cxx ...@@ -81,28 +81,28 @@ namespace __gnu_cxx
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
inline bool inline bool
operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2); const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2);
/** /**
* This is an SGI extension. * This is an SGI extension.
* @ingroup SGIextensions * @ingroup SGIextensions
* @doctodo * @doctodo
*/ */
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class hash_set class hash_set
{ {
// concept requirements // concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept) __glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private: private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht; _EqualKey, _Alloc> _Ht;
_Ht _M_ht; _Ht _M_ht;
public: public:
typedef typename _Ht::key_type key_type; typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type; typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher; typedef typename _Ht::hasher hasher;
...@@ -120,17 +120,29 @@ public: ...@@ -120,17 +120,29 @@ public:
typedef typename _Ht::allocator_type allocator_type; typedef typename _Ht::allocator_type allocator_type;
hasher hash_funct() const { return _M_ht.hash_funct(); } hasher
key_equal key_eq() const { return _M_ht.key_eq(); } hash_funct() const
allocator_type get_allocator() const { return _M_ht.get_allocator(); } { return _M_ht.hash_funct(); }
public: key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
public:
hash_set() hash_set()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {} : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit hash_set(size_type __n)
explicit
hash_set(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf) hash_set(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {} : _M_ht(__n, __hf, __eql, __a) {}
...@@ -139,15 +151,18 @@ public: ...@@ -139,15 +151,18 @@ public:
hash_set(_InputIterator __f, _InputIterator __l) hash_set(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type()) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n) hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n, hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf) const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) : _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n, hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql, const hasher& __hf, const key_equal& __eql,
...@@ -155,110 +170,152 @@ public: ...@@ -155,110 +170,152 @@ public:
: _M_ht(__n, __hf, __eql, __a) : _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_unique(__f, __l); } { _M_ht.insert_unique(__f, __l); }
public: public:
size_type size() const { return _M_ht.size(); } size_type
size_type max_size() const { return _M_ht.max_size(); } size() const
bool empty() const { return _M_ht.empty(); } { return _M_ht.size(); }
void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_set& __hs)
{ _M_ht.swap(__hs._M_ht); }
template <class _Val, class _HF, class _EqK, class _Al> template <class _Val, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&, friend bool
operator==(const hash_set<_Val, _HF, _EqK, _Al>&,
const hash_set<_Val, _HF, _EqK, _Al>&); const hash_set<_Val, _HF, _EqK, _Al>&);
iterator begin() const { return _M_ht.begin(); } iterator
iterator end() const { return _M_ht.end(); } begin() const
{ return _M_ht.begin(); }
public: iterator
pair<iterator, bool> insert(const value_type& __obj) end() const
{ return _M_ht.end(); }
public:
pair<iterator, bool>
insert(const value_type& __obj)
{ {
pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj); pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);
return pair<iterator,bool>(__p.first, __p.second); return pair<iterator,bool>(__p.first, __p.second);
} }
template <class _InputIterator> template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l) void
{ _M_ht.insert_unique(__f,__l); } insert(_InputIterator __f, _InputIterator __l)
pair<iterator, bool> insert_noresize(const value_type& __obj) { _M_ht.insert_unique(__f, __l); }
pair<iterator, bool>
insert_noresize(const value_type& __obj)
{ {
pair<typename _Ht::iterator, bool> __p = pair<typename _Ht::iterator, bool> __p
_M_ht.insert_unique_noresize(__obj); = _M_ht.insert_unique_noresize(__obj);
return pair<iterator, bool>(__p.first, __p.second); return pair<iterator, bool>(__p.first, __p.second);
} }
iterator find(const key_type& __key) const { return _M_ht.find(__key); } iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
size_type count(const key_type& __key) const { return _M_ht.count(__key); } size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator> equal_range(const key_type& __key) const pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } size_type
void erase(iterator __it) { _M_ht.erase(__it); } erase(const key_type& __key)
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } {return _M_ht.erase(__key); }
void clear() { _M_ht.clear(); }
void
erase(iterator __it)
{ _M_ht.erase(__it); }
void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
public: public:
void resize(size_type __hint) { _M_ht.resize(__hint); } void
size_type bucket_count() const { return _M_ht.bucket_count(); } resize(size_type __hint)
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } { _M_ht.resize(__hint); }
size_type elems_in_bucket(size_type __n) const
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); } { return _M_ht.elems_in_bucket(__n); }
}; };
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
inline bool inline bool
operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ { return __hs1._M_ht == __hs2._M_ht; }
return __hs1._M_ht == __hs2._M_ht;
} template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
inline bool const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, { return !(__hs1 == __hs2); }
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) {
return !(__hs1 == __hs2);
}
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline void
swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
{
__hs1.swap(__hs2);
}
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline void
swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ __hs1.swap(__hs2); }
template <class _Value, template <class _Value,
class _HashFcn = hash<_Value>, class _HashFcn = hash<_Value>,
class _EqualKey = equal_to<_Value>, class _EqualKey = equal_to<_Value>,
class _Alloc = allocator<_Value> > class _Alloc = allocator<_Value> >
class hash_multiset; class hash_multiset;
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool inline bool
operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2); const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2);
/** /**
* This is an SGI extension. * This is an SGI extension.
* @ingroup SGIextensions * @ingroup SGIextensions
* @doctodo * @doctodo
*/ */
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class hash_multiset class hash_multiset
{ {
// concept requirements // concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept) __glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private: private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht; _EqualKey, _Alloc> _Ht;
_Ht _M_ht; _Ht _M_ht;
public: public:
typedef typename _Ht::key_type key_type; typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type; typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher; typedef typename _Ht::hasher hasher;
...@@ -276,17 +333,29 @@ public: ...@@ -276,17 +333,29 @@ public:
typedef typename _Ht::allocator_type allocator_type; typedef typename _Ht::allocator_type allocator_type;
hasher hash_funct() const { return _M_ht.hash_funct(); } hasher
key_equal key_eq() const { return _M_ht.key_eq(); } hash_funct() const
allocator_type get_allocator() const { return _M_ht.get_allocator(); } { return _M_ht.hash_funct(); }
public: key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
public:
hash_multiset() hash_multiset()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {} : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit hash_multiset(size_type __n)
explicit
hash_multiset(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf) hash_multiset(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {} : _M_ht(__n, __hf, __eql, __a) {}
...@@ -295,15 +364,18 @@ public: ...@@ -295,15 +364,18 @@ public:
hash_multiset(_InputIterator __f, _InputIterator __l) hash_multiset(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type()) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf) const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) : _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql, const hasher& __hf, const key_equal& __eql,
...@@ -311,83 +383,131 @@ public: ...@@ -311,83 +383,131 @@ public:
: _M_ht(__n, __hf, __eql, __a) : _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
public: public:
size_type size() const { return _M_ht.size(); } size_type
size_type max_size() const { return _M_ht.max_size(); } size() const
bool empty() const { return _M_ht.empty(); } { return _M_ht.size(); }
void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }
size_type
max_size() const
{ return _M_ht.max_size(); }
bool
empty() const
{ return _M_ht.empty(); }
void
swap(hash_multiset& hs)
{ _M_ht.swap(hs._M_ht); }
template <class _Val, class _HF, class _EqK, class _Al> template <class _Val, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&, friend bool
operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&,
const hash_multiset<_Val, _HF, _EqK, _Al>&); const hash_multiset<_Val, _HF, _EqK, _Al>&);
iterator begin() const { return _M_ht.begin(); } iterator
iterator end() const { return _M_ht.end(); } begin() const
{ return _M_ht.begin(); }
iterator
end() const
{ return _M_ht.end(); }
public: public:
iterator insert(const value_type& __obj) iterator
insert(const value_type& __obj)
{ return _M_ht.insert_equal(__obj); } { return _M_ht.insert_equal(__obj); }
template <class _InputIterator> template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l) void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); } { _M_ht.insert_equal(__f,__l); }
iterator insert_noresize(const value_type& __obj)
iterator
insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); } { return _M_ht.insert_equal_noresize(__obj); }
iterator find(const key_type& __key) const { return _M_ht.find(__key); } iterator
find(const key_type& __key) const
{ return _M_ht.find(__key); }
size_type count(const key_type& __key) const { return _M_ht.count(__key); } size_type
count(const key_type& __key) const
{ return _M_ht.count(__key); }
pair<iterator, iterator> equal_range(const key_type& __key) const pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); } { return _M_ht.equal_range(__key); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } size_type
void erase(iterator __it) { _M_ht.erase(__it); } erase(const key_type& __key)
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } { return _M_ht.erase(__key); }
void clear() { _M_ht.clear(); }
public: void
void resize(size_type __hint) { _M_ht.resize(__hint); } erase(iterator __it)
size_type bucket_count() const { return _M_ht.bucket_count(); } { _M_ht.erase(__it); }
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }
size_type elems_in_bucket(size_type __n) const void
erase(iterator __f, iterator __l)
{ _M_ht.erase(__f, __l); }
void
clear()
{ _M_ht.clear(); }
public:
void
resize(size_type __hint)
{ _M_ht.resize(__hint); }
size_type
bucket_count() const
{ return _M_ht.bucket_count(); }
size_type
max_bucket_count() const
{ return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); } { return _M_ht.elems_in_bucket(__n); }
}; };
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool inline bool
operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ { return __hs1._M_ht == __hs2._M_ht; }
return __hs1._M_ht == __hs2._M_ht;
} template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
inline bool const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, { return !(__hs1 == __hs2); }
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
return !(__hs1 == __hs2); template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
} inline void
swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
inline void { __hs1.swap(__hs2); }
swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) {
__hs1.swap(__hs2);
}
} // namespace __gnu_cxx } // namespace __gnu_cxx
namespace std namespace std
{ {
// Specialization of insert_iterator so that it will work for hash_set // Specialization of insert_iterator so that it will work for hash_set
// and hash_multiset. // and hash_multiset.
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
protected: _EqualKey, _Alloc> >
typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; {
protected:
typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>
_Container;
_Container* container; _Container* container;
public:
public:
typedef _Container container_type; typedef _Container container_type;
typedef output_iterator_tag iterator_category; typedef output_iterator_tag iterator_category;
typedef void value_type; typedef void value_type;
...@@ -395,26 +515,43 @@ public: ...@@ -395,26 +515,43 @@ public:
typedef void pointer; typedef void pointer;
typedef void reference; typedef void reference;
insert_iterator(_Container& __x) : container(&__x) {} insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator) insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {} : container(&__x) {}
insert_iterator<_Container>& insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { operator=(const typename _Container::value_type& __value)
{
container->insert(__value); container->insert(__value);
return *this; return *this;
} }
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; } insert_iterator<_Container>&
insert_iterator<_Container>& operator++(int) { return *this; } operator*()
}; { return *this; }
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> insert_iterator<_Container>&
class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { operator++()
protected: { return *this; }
typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
_EqualKey, _Alloc> >
{
protected:
typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>
_Container;
_Container* container; _Container* container;
typename _Container::iterator iter; typename _Container::iterator iter;
public:
public:
typedef _Container container_type; typedef _Container container_type;
typedef output_iterator_tag iterator_category; typedef output_iterator_tag iterator_category;
typedef void value_type; typedef void value_type;
...@@ -422,18 +559,29 @@ public: ...@@ -422,18 +559,29 @@ public:
typedef void pointer; typedef void pointer;
typedef void reference; typedef void reference;
insert_iterator(_Container& __x) : container(&__x) {} insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator) insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {} : container(&__x) {}
insert_iterator<_Container>& insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { operator=(const typename _Container::value_type& __value)
{
container->insert(__value); container->insert(__value);
return *this; return *this;
} }
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; }
};
} // namespace std
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int) { return *this; }
};
} // namespace std
#endif #endif
// Memory extensions -*- C++ -*- // Memory extensions -*- C++ -*-
// Copyright (C) 2002 Free Software Foundation, Inc. // Copyright (C) 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -82,7 +82,7 @@ namespace __gnu_cxx ...@@ -82,7 +82,7 @@ namespace __gnu_cxx
_ForwardIter __cur = __result; _ForwardIter __cur = __result;
try try
{ {
for ( ; __count > 0 ; --__count, ++__first, ++__cur) for (; __count > 0 ; --__count, ++__first, ++__cur)
std::_Construct(&*__cur, *__first); std::_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur); return pair<_InputIter, _ForwardIter>(__first, __cur);
} }
...@@ -100,19 +100,16 @@ namespace __gnu_cxx ...@@ -100,19 +100,16 @@ namespace __gnu_cxx
std::random_access_iterator_tag) std::random_access_iterator_tag)
{ {
_RandomAccessIter __last = __first + __count; _RandomAccessIter __last = __first + __count;
return pair<_RandomAccessIter, _ForwardIter>( return (pair<_RandomAccessIter, _ForwardIter>
__last, (__last, std::uninitialized_copy(__first, __last, __result)));
std::uninitialized_copy(__first, __last, __result));
} }
template<typename _InputIter, typename _Size, typename _ForwardIter> template<typename _InputIter, typename _Size, typename _ForwardIter>
inline pair<_InputIter, _ForwardIter> inline pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count, __uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result) _ForwardIter __result)
{ { return __uninitialized_copy_n(__first, __count, __result,
return __uninitialized_copy_n(__first, __count, __result, __iterator_category(__first)); }
__iterator_category(__first));
}
/** /**
* @brief Copies the range [first,last) into result. * @brief Copies the range [first,last) into result.
...@@ -128,11 +125,8 @@ namespace __gnu_cxx ...@@ -128,11 +125,8 @@ namespace __gnu_cxx
inline pair<_InputIter, _ForwardIter> inline pair<_InputIter, _ForwardIter>
uninitialized_copy_n(_InputIter __first, _Size __count, uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result) _ForwardIter __result)
{ { return __uninitialized_copy_n(__first, __count, __result,
return __uninitialized_copy_n(__first, __count, __result, __iterator_category(__first)); }
__iterator_category(__first));
}
/** /**
* This class provides similar behavior and semantics of the standard * This class provides similar behavior and semantics of the standard
......
// Numeric extensions -*- C++ -*- // Numeric extensions -*- C++ -*-
// Copyright (C) 2002 Free Software Foundation, Inc. // Copyright (C) 2002, 2004 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -79,15 +79,18 @@ namespace __gnu_cxx ...@@ -79,15 +79,18 @@ namespace __gnu_cxx
{ {
if (__n == 0) if (__n == 0)
return identity_element(__monoid_op); return identity_element(__monoid_op);
else { else
while ((__n & 1) == 0) { {
while ((__n & 1) == 0)
{
__n >>= 1; __n >>= 1;
__x = __monoid_op(__x, __x); __x = __monoid_op(__x, __x);
} }
_Tp __result = __x; _Tp __result = __x;
__n >>= 1; __n >>= 1;
while (__n != 0) { while (__n != 0)
{
__x = __monoid_op(__x, __x); __x = __monoid_op(__x, __x);
if ((__n & 1) != 0) if ((__n & 1) != 0)
__result = __monoid_op(__result, __x); __result = __monoid_op(__result, __x);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment