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
...@@ -74,314 +74,456 @@ namespace __gnu_cxx ...@@ -74,314 +74,456 @@ namespace __gnu_cxx
// Forward declaration of equality operator; needed for friend // Forward declaration of equality operator; needed for friend
// declaration. // declaration.
template<class _Key, class _Tp, class _HashFcn = hash<_Key>, template<class _Key, class _Tp, class _HashFcn = hash<_Key>,
class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> >
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
const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&); operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
/** const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
* This is an SGI extension.
* @ingroup SGIextensions /**
* @doctodo * This is an SGI extension.
*/ * @ingroup SGIextensions
template <class _Key, class _Tp, class _HashFcn, class _EqualKey, * @doctodo
class _Alloc> */
class hash_map template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
{ class _Alloc>
private: class hash_map
typedef hashtable<pair<const _Key,_Tp>,_Key,_HashFcn, {
_Select1st<pair<const _Key,_Tp> >,_EqualKey,_Alloc> _Ht; private:
_Ht _M_ht; typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFcn,
_Select1st<pair<const _Key, _Tp> >,
public: _EqualKey, _Alloc> _Ht;
typedef typename _Ht::key_type key_type;
typedef _Tp data_type; _Ht _M_ht;
typedef _Tp mapped_type;
typedef typename _Ht::value_type value_type; public:
typedef typename _Ht::hasher hasher; typedef typename _Ht::key_type key_type;
typedef typename _Ht::key_equal key_equal; typedef _Tp data_type;
typedef _Tp mapped_type;
typedef typename _Ht::size_type size_type; typedef typename _Ht::value_type value_type;
typedef typename _Ht::difference_type difference_type; typedef typename _Ht::hasher hasher;
typedef typename _Ht::pointer pointer; typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::const_pointer const_pointer;
typedef typename _Ht::reference reference; typedef typename _Ht::size_type size_type;
typedef typename _Ht::const_reference const_reference; typedef typename _Ht::difference_type difference_type;
typedef typename _Ht::pointer pointer;
typedef typename _Ht::iterator iterator; typedef typename _Ht::const_pointer const_pointer;
typedef typename _Ht::const_iterator const_iterator; typedef typename _Ht::reference reference;
typedef typename _Ht::const_reference const_reference;
typedef typename _Ht::allocator_type allocator_type;
typedef typename _Ht::iterator iterator;
hasher hash_funct() const { return _M_ht.hash_funct(); } typedef typename _Ht::const_iterator const_iterator;
key_equal key_eq() const { return _M_ht.key_eq(); }
allocator_type get_allocator() const { return _M_ht.get_allocator(); } typedef typename _Ht::allocator_type allocator_type;
public: hasher
hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} hash_funct() const
explicit hash_map(size_type __n) { return _M_ht.hash_funct(); }
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_map(size_type __n, const hasher& __hf) key_equal
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} key_eq() const
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, { return _M_ht.key_eq(); }
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {} allocator_type
get_allocator() const
template <class _InputIterator> { return _M_ht.get_allocator(); }
hash_map(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type()) public:
{ _M_ht.insert_unique(__f, __l); } hash_map()
template <class _InputIterator> : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) explicit
{ _M_ht.insert_unique(__f, __l); } hash_map(size_type __n)
template <class _InputIterator> : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_map(_InputIterator __f, _InputIterator __l, 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()) {}
{ _M_ht.insert_unique(__f, __l); }
template <class _InputIterator> hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
hash_map(_InputIterator __f, _InputIterator __l, size_type __n, const allocator_type& __a = allocator_type())
const hasher& __hf, const key_equal& __eql, : _M_ht(__n, __hf, __eql, __a) {}
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) template <class _InputIterator>
{ _M_ht.insert_unique(__f, __l); } hash_map(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
public: { _M_ht.insert_unique(__f, __l); }
size_type size() const { return _M_ht.size(); }
size_type max_size() const { return _M_ht.max_size(); } template <class _InputIterator>
bool empty() const { return _M_ht.empty(); } hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); } : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template <class _K1, class _T1, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, template <class _InputIterator>
const hash_map<_K1, _T1, _HF, _EqK, _Al>&); hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
iterator begin() { return _M_ht.begin(); } : _M_ht(__n, __hf, key_equal(), allocator_type())
iterator end() { return _M_ht.end(); } { _M_ht.insert_unique(__f, __l); }
const_iterator begin() const { return _M_ht.begin(); }
const_iterator end() const { return _M_ht.end(); } template <class _InputIterator>
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
public: const hasher& __hf, const key_equal& __eql,
pair<iterator,bool> insert(const value_type& __obj) const allocator_type& __a = allocator_type())
{ return _M_ht.insert_unique(__obj); } : _M_ht(__n, __hf, __eql, __a)
template <class _InputIterator> { _M_ht.insert_unique(__f, __l); }
void insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f,__l); } public:
pair<iterator,bool> insert_noresize(const value_type& __obj) size_type
{ return _M_ht.insert_unique_noresize(__obj); } size() const
{ return _M_ht.size(); }
iterator find(const key_type& __key) { return _M_ht.find(__key); }
const_iterator find(const key_type& __key) const size_type
{ return _M_ht.find(__key); } max_size() const
{ return _M_ht.max_size(); }
_Tp& operator[](const key_type& __key) {
return _M_ht.find_or_insert(value_type(__key, _Tp())).second; bool
} empty() const
{ return _M_ht.empty(); }
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
void
pair<iterator, iterator> equal_range(const key_type& __key) swap(hash_map& __hs)
{ return _M_ht.equal_range(__key); } { _M_ht.swap(__hs._M_ht); }
pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const template <class _K1, class _T1, class _HF, class _EqK, class _Al>
{ return _M_ht.equal_range(__key); } friend bool
operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
void erase(iterator __it) { _M_ht.erase(__it); }
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } iterator
void clear() { _M_ht.clear(); } begin()
{ return _M_ht.begin(); }
void resize(size_type __hint) { _M_ht.resize(__hint); }
size_type bucket_count() const { return _M_ht.bucket_count(); } iterator
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } end()
size_type elems_in_bucket(size_type __n) const { return _M_ht.end(); }
{ return _M_ht.elems_in_bucket(__n); }
}; const_iterator
begin() const
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> { return _M_ht.begin(); }
inline bool
operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, const_iterator
const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) end() const
{ { return _M_ht.end(); }
return __hm1._M_ht == __hm2._M_ht;
} public:
pair<iterator, bool>
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> insert(const value_type& __obj)
inline bool { return _M_ht.insert_unique(__obj); }
operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) { template <class _InputIterator>
return !(__hm1 == __hm2); void
} insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f, __l); }
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline void pair<iterator, bool>
swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, insert_noresize(const value_type& __obj)
hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) { return _M_ht.insert_unique_noresize(__obj); }
{
__hm1.swap(__hm2); iterator
} find(const key_type& __key)
{ return _M_ht.find(__key); }
// Forward declaration of equality operator; needed for friend declaration.
const_iterator
template <class _Key, class _Tp, find(const key_type& __key) const
class _HashFcn = hash<_Key>, { return _M_ht.find(__key); }
class _EqualKey = equal_to<_Key>,
class _Alloc = allocator<_Tp> > _Tp&
class hash_multimap; operator[](const key_type& __key)
{ return _M_ht.find_or_insert(value_type(__key, _Tp())).second; }
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool size_type
operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, count(const key_type& __key) const
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2); { return _M_ht.count(__key); }
/** pair<iterator, iterator>
* This is an SGI extension. equal_range(const key_type& __key)
* @ingroup SGIextensions { return _M_ht.equal_range(__key); }
* @doctodo
*/ pair<const_iterator, const_iterator>
template <class _Key, class _Tp, class _HashFcn, class _EqualKey, class _Alloc> equal_range(const key_type& __key) const
class hash_multimap { return _M_ht.equal_range(__key); }
{
// concept requirements size_type
__glibcxx_class_requires(_Key, _SGIAssignableConcept) erase(const key_type& __key)
__glibcxx_class_requires(_Tp, _SGIAssignableConcept) {return _M_ht.erase(__key); }
__glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) void
erase(iterator __it)
private: { _M_ht.erase(__it); }
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> 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); }
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); }
};
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline bool
operator==(const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
{ return __hm1._M_ht == __hm2._M_ht; }
template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline bool
operator!=(const hash_map<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
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 = hash<_Key>,
class _EqualKey = equal_to<_Key>,
class _Alloc = allocator<_Tp> >
class hash_multimap;
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool
operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2);
/**
* This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
class _Alloc>
class hash_multimap
{
// concept requirements
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
private:
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFcn,
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
_Ht; _Ht;
_Ht _M_ht;
public: _Ht _M_ht;
typedef typename _Ht::key_type key_type;
typedef _Tp data_type; public:
typedef _Tp mapped_type; typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type; typedef _Tp data_type;
typedef typename _Ht::hasher hasher; typedef _Tp mapped_type;
typedef typename _Ht::key_equal key_equal; typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::size_type size_type; typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::difference_type difference_type;
typedef typename _Ht::pointer pointer; typedef typename _Ht::size_type size_type;
typedef typename _Ht::const_pointer const_pointer; typedef typename _Ht::difference_type difference_type;
typedef typename _Ht::reference reference; typedef typename _Ht::pointer pointer;
typedef typename _Ht::const_reference const_reference; typedef typename _Ht::const_pointer const_pointer;
typedef typename _Ht::reference reference;
typedef typename _Ht::iterator iterator; typedef typename _Ht::const_reference const_reference;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::iterator iterator;
typedef typename _Ht::allocator_type allocator_type; typedef typename _Ht::const_iterator const_iterator;
hasher hash_funct() const { return _M_ht.hash_funct(); } typedef typename _Ht::allocator_type allocator_type;
key_equal key_eq() const { return _M_ht.key_eq(); }
allocator_type get_allocator() const { return _M_ht.get_allocator(); } hasher
hash_funct() const
public: { return _M_ht.hash_funct(); }
hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit hash_multimap(size_type __n) key_equal
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} key_eq() const
hash_multimap(size_type __n, const hasher& __hf) { return _M_ht.key_eq(); }
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, allocator_type
const allocator_type& __a = allocator_type()) get_allocator() const
: _M_ht(__n, __hf, __eql, __a) {} { return _M_ht.get_allocator(); }
template <class _InputIterator> public:
hash_multimap(_InputIterator __f, _InputIterator __l) hash_multimap()
: _M_ht(100, hasher(), key_equal(), allocator_type()) : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator> explicit
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) hash_multimap(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); }
template <class _InputIterator> hash_multimap(size_type __n, const hasher& __hf)
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
{ _M_ht.insert_equal(__f, __l); } const allocator_type& __a = allocator_type())
template <class _InputIterator> : _M_ht(__n, __hf, __eql, __a) {}
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql, template <class _InputIterator>
const allocator_type& __a = allocator_type()) hash_multimap(_InputIterator __f, _InputIterator __l)
: _M_ht(__n, __hf, __eql, __a) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); } { _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
public:
size_type
size() const
{ return _M_ht.size(); }
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>
friend bool
operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
iterator
begin()
{ return _M_ht.begin(); }
iterator
end()
{ return _M_ht.end(); }
const_iterator
begin() const
{ return _M_ht.begin(); }
const_iterator
end() const
{ return _M_ht.end(); }
public: public:
size_type size() const { return _M_ht.size(); } iterator
size_type max_size() const { return _M_ht.max_size(); } insert(const value_type& __obj)
bool empty() const { return _M_ht.empty(); } { return _M_ht.insert_equal(__obj); }
void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
template <class _InputIterator>
template <class _K1, class _T1, class _HF, class _EqK, class _Al> void
friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, insert(_InputIterator __f, _InputIterator __l)
const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); { _M_ht.insert_equal(__f,__l); }
iterator begin() { return _M_ht.begin(); } iterator
iterator end() { return _M_ht.end(); } insert_noresize(const value_type& __obj)
const_iterator begin() const { return _M_ht.begin(); } { return _M_ht.insert_equal_noresize(__obj); }
const_iterator end() const { return _M_ht.end(); }
iterator
find(const key_type& __key)
{ return _M_ht.find(__key); }
const_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); }
pair<iterator, iterator>
equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{ return _M_ht.erase(__key); }
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:
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); }
};
public: template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
iterator insert(const value_type& __obj) inline bool
{ return _M_ht.insert_equal(__obj); } operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
template <class _InputIterator> const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
void insert(_InputIterator __f, _InputIterator __l) { return __hm1._M_ht == __hm2._M_ht; }
{ _M_ht.insert_equal(__f,__l); }
iterator insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); }
iterator find(const key_type& __key) { return _M_ht.find(__key); }
const_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); }
pair<iterator, iterator> equal_range(const key_type& __key)
{ return _M_ht.equal_range(__key); }
pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); }
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: template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
void resize(size_type __hint) { _M_ht.resize(__hint); } inline bool
size_type bucket_count() const { return _M_ht.bucket_count(); } operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
size_type elems_in_bucket(size_type __n) const { return !(__hm1 == __hm2); }
{ return _M_ht.elems_in_bucket(__n); }
};
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc>
inline bool inline void
operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, swap(hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm2)
{ { __hm1.swap(__hm2); }
return __hm1._M_ht == __hm2._M_ht;
}
template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
inline bool
operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1,
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,
hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2)
{
__hm1.swap(__hm2);
}
} // namespace __gnu_cxx } // namespace __gnu_cxx
...@@ -390,58 +532,90 @@ namespace std ...@@ -390,58 +532,90 @@ 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; {
_Container* container; protected:
public: typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>
typedef _Container container_type; _Container;
typedef output_iterator_tag iterator_category; _Container* container;
typedef void value_type;
typedef void difference_type; public:
typedef void pointer; typedef _Container container_type;
typedef void reference; typedef output_iterator_tag iterator_category;
typedef void value_type;
insert_iterator(_Container& __x) : container(&__x) {} typedef void difference_type;
insert_iterator(_Container& __x, typename _Container::iterator) typedef void pointer;
: container(&__x) {} typedef void reference;
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { insert_iterator(_Container& __x)
container->insert(__value); : container(&__x) {}
return *this;
} insert_iterator(_Container& __x, typename _Container::iterator)
insert_iterator<_Container>& operator*() { return *this; } : container(&__x) {}
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; } insert_iterator<_Container>&
}; operator=(const typename _Container::value_type& __value)
{
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> container->insert(__value);
class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { return *this;
protected: }
typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
_Container* container; insert_iterator<_Container>&
typename _Container::iterator iter; operator*()
public: { return *this; }
typedef _Container container_type;
typedef output_iterator_tag iterator_category; insert_iterator<_Container>&
typedef void value_type; operator++() { return *this; }
typedef void difference_type;
typedef void pointer; insert_iterator<_Container>&
typedef void reference; operator++(int)
{ return *this; }
insert_iterator(_Container& __x) : container(&__x) {} };
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {} template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
insert_iterator<_Container>& class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn,
operator=(const typename _Container::value_type& __value) { _EqKey, _Alloc> >
container->insert(__value); {
return *this; protected:
} typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
insert_iterator<_Container>& operator*() { return *this; } _Container;
insert_iterator<_Container>& operator++() { return *this; } _Container* container;
insert_iterator<_Container>& operator++(int) { return *this; } typename _Container::iterator iter;
};
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
insert_iterator<_Container>&
operator*()
{ return *this; }
insert_iterator<_Container>&
operator++()
{ return *this; }
insert_iterator<_Container>&
operator++(int)
{ return *this; }
};
} // namespace std } // 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
...@@ -76,364 +76,512 @@ namespace __gnu_cxx ...@@ -76,364 +76,512 @@ namespace __gnu_cxx
// declaration. // declaration.
template <class _Value, class _HashFcn = hash<_Value>, template <class _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_set; class hash_set;
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
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
typedef typename _Alloc::reference reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Ht::const_iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher hash_funct() const { return _M_ht.hash_funct(); }
key_equal key_eq() const { return _M_ht.key_eq(); }
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
public:
hash_set()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit hash_set(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_unique(__f, __l); }
template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_unique(__f, __l); }
public:
size_type size() const { return _M_ht.size(); }
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>
friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&,
const hash_set<_Val, _HF, _EqK, _Al>&);
iterator begin() const { return _M_ht.begin(); }
iterator 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); // concept requirements
return pair<iterator,bool>(__p.first, __p.second); __glibcxx_class_requires(_Value, _SGIAssignableConcept)
} __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
template <class _InputIterator> __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
void insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f,__l); } private:
pair<iterator, bool> insert_noresize(const value_type& __obj) typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
{ _EqualKey, _Alloc> _Ht;
pair<typename _Ht::iterator, bool> __p = _Ht _M_ht;
_M_ht.insert_unique_noresize(__obj);
return pair<iterator, bool>(__p.first, __p.second); public:
} typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type;
iterator find(const key_type& __key) const { return _M_ht.find(__key); } typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
size_type count(const key_type& __key) const { return _M_ht.count(__key); }
typedef typename _Ht::size_type size_type;
pair<iterator, iterator> equal_range(const key_type& __key) const typedef typename _Ht::difference_type difference_type;
{ return _M_ht.equal_range(__key); } typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } typedef typename _Alloc::reference reference;
void erase(iterator __it) { _M_ht.erase(__it); } typedef typename _Alloc::const_reference const_reference;
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); }
void clear() { _M_ht.clear(); } typedef typename _Ht::const_iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
public:
void resize(size_type __hint) { _M_ht.resize(__hint); } typedef typename _Ht::allocator_type allocator_type;
size_type bucket_count() const { return _M_ht.bucket_count(); }
size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } hasher
size_type elems_in_bucket(size_type __n) const hash_funct() const
{ return _M_ht.elems_in_bucket(__n); } { return _M_ht.hash_funct(); }
};
key_equal
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> key_eq() const
inline bool { return _M_ht.key_eq(); }
operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) allocator_type
{ get_allocator() const
return __hs1._M_ht == __hs2._M_ht; { return _M_ht.get_allocator(); }
}
public:
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> hash_set()
inline bool : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1,
const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) { explicit
return !(__hs1 == __hs2); hash_set(size_type __n)
} : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> hash_set(size_type __n, const hasher& __hf)
inline void : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
{ const allocator_type& __a = allocator_type())
__hs1.swap(__hs2); : _M_ht(__n, __hf, __eql, __a) {}
}
template <class _InputIterator>
hash_set(_InputIterator __f, _InputIterator __l)
template <class _Value, : _M_ht(100, hasher(), key_equal(), allocator_type())
class _HashFcn = hash<_Value>, { _M_ht.insert_unique(__f, __l); }
class _EqualKey = equal_to<_Value>,
class _Alloc = allocator<_Value> > template <class _InputIterator>
class hash_multiset; hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> { _M_ht.insert_unique(__f, __l); }
inline bool
operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, template <class _InputIterator>
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2); hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
/** { _M_ht.insert_unique(__f, __l); }
* This is an SGI extension.
* @ingroup SGIextensions template <class _InputIterator>
* @doctodo hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
*/ const hasher& __hf, const key_equal& __eql,
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> const allocator_type& __a = allocator_type())
class hash_multiset : _M_ht(__n, __hf, __eql, __a)
{ { _M_ht.insert_unique(__f, __l); }
// concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept) public:
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) size_type
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) size() const
{ return _M_ht.size(); }
private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, size_type
_EqualKey, _Alloc> _Ht; max_size() const
_Ht _M_ht; { 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>
friend bool
operator==(const hash_set<_Val, _HF, _EqK, _Al>&,
const hash_set<_Val, _HF, _EqK, _Al>&);
iterator
begin() const
{ return _M_ht.begin(); }
iterator
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);
return pair<iterator,bool>(__p.first, __p.second);
}
template <class _InputIterator>
void
insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_unique(__f, __l); }
pair<iterator, bool>
insert_noresize(const value_type& __obj)
{
pair<typename _Ht::iterator, bool> __p
= _M_ht.insert_unique_noresize(__obj);
return pair<iterator, bool>(__p.first, __p.second);
}
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); }
pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{return _M_ht.erase(__key); }
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:
typedef typename _Ht::key_type key_type; void
typedef typename _Ht::value_type value_type; resize(size_type __hint)
typedef typename _Ht::hasher hasher; { _M_ht.resize(__hint); }
typedef typename _Ht::key_equal key_equal;
size_type
typedef typename _Ht::size_type size_type; bucket_count() const
typedef typename _Ht::difference_type difference_type; { return _M_ht.bucket_count(); }
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer; size_type
typedef typename _Alloc::reference reference; max_bucket_count() const
typedef typename _Alloc::const_reference const_reference; { return _M_ht.max_bucket_count(); }
size_type
elems_in_bucket(size_type __n) const
{ return _M_ht.elems_in_bucket(__n); }
};
typedef typename _Ht::const_iterator iterator; template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
typedef typename _Ht::const_iterator const_iterator; inline bool
operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
typedef typename _Ht::allocator_type allocator_type; const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return __hs1._M_ht == __hs2._M_ht; }
hasher hash_funct() const { return _M_ht.hash_funct(); }
key_equal key_eq() const { return _M_ht.key_eq(); }
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
public: template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
hash_multiset() inline bool
: _M_ht(100, hasher(), key_equal(), allocator_type()) {} operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
explicit hash_multiset(size_type __n) const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} { return !(__hs1 == __hs2); }
hash_multiset(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {} template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, inline void
const allocator_type& __a = allocator_type()) swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
: _M_ht(__n, __hf, __eql, __a) {} hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ __hs1.swap(__hs2); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l) template <class _Value,
: _M_ht(100, hasher(), key_equal(), allocator_type()) class _HashFcn = hash<_Value>,
{ _M_ht.insert_equal(__f, __l); } class _EqualKey = equal_to<_Value>,
template <class _InputIterator> class _Alloc = allocator<_Value> >
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) class hash_multiset;
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
public: template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
size_type size() const { return _M_ht.size(); } inline bool
size_type max_size() const { return _M_ht.max_size(); } operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
bool empty() const { return _M_ht.empty(); } const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2);
void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); }
template <class _Val, class _HF, class _EqK, class _Al>
friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&,
const hash_multiset<_Val, _HF, _EqK, _Al>&);
iterator begin() const { return _M_ht.begin(); } /**
iterator end() const { return _M_ht.end(); } * This is an SGI extension.
* @ingroup SGIextensions
* @doctodo
*/
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class hash_multiset
{
// concept requirements
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
private:
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
_EqualKey, _Alloc> _Ht;
_Ht _M_ht;
public:
typedef typename _Ht::key_type key_type;
typedef typename _Ht::value_type value_type;
typedef typename _Ht::hasher hasher;
typedef typename _Ht::key_equal key_equal;
typedef typename _Ht::size_type size_type;
typedef typename _Ht::difference_type difference_type;
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
typedef typename _Alloc::reference reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Ht::const_iterator iterator;
typedef typename _Ht::const_iterator const_iterator;
typedef typename _Ht::allocator_type allocator_type;
hasher
hash_funct() const
{ return _M_ht.hash_funct(); }
key_equal
key_eq() const
{ return _M_ht.key_eq(); }
allocator_type
get_allocator() const
{ return _M_ht.get_allocator(); }
public:
hash_multiset()
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
explicit
hash_multiset(size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a) {}
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l)
: _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
: _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template <class _InputIterator>
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
public:
size_type
size() const
{ return _M_ht.size(); }
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>
friend bool
operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&,
const hash_multiset<_Val, _HF, _EqK, _Al>&);
iterator
begin() const
{ return _M_ht.begin(); }
iterator
end() const
{ return _M_ht.end(); }
public: public:
iterator insert(const value_type& __obj) iterator
{ return _M_ht.insert_equal(__obj); } insert(const value_type& __obj)
template <class _InputIterator> { return _M_ht.insert_equal(__obj); }
void insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); } template <class _InputIterator>
iterator insert_noresize(const value_type& __obj) void
{ return _M_ht.insert_equal_noresize(__obj); } insert(_InputIterator __f, _InputIterator __l)
{ _M_ht.insert_equal(__f,__l); }
iterator find(const key_type& __key) const { return _M_ht.find(__key); }
iterator
size_type count(const key_type& __key) const { return _M_ht.count(__key); } insert_noresize(const value_type& __obj)
{ return _M_ht.insert_equal_noresize(__obj); }
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); }
pair<iterator, iterator>
equal_range(const key_type& __key) const
{ return _M_ht.equal_range(__key); }
size_type
erase(const key_type& __key)
{ return _M_ht.erase(__key); }
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:
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); }
};
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return __hs1._M_ht == __hs2._M_ht; }
pair<iterator, iterator> equal_range(const key_type& __key) const template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
{ return _M_ht.equal_range(__key); } inline bool
operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ return !(__hs1 == __hs2); }
size_type erase(const key_type& __key) {return _M_ht.erase(__key); } template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
void erase(iterator __it) { _M_ht.erase(__it); } inline void
void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
void clear() { _M_ht.clear(); } hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
{ __hs1.swap(__hs2); }
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); }
};
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2)
{
return __hs1._M_ht == __hs2._M_ht;
}
template <class _Val, class _HashFcn, class _EqualKey, class _Alloc>
inline bool
operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
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,
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; {
_Container* container; protected:
public: typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>
typedef _Container container_type; _Container;
typedef output_iterator_tag iterator_category; _Container* container;
typedef void value_type;
typedef void difference_type; public:
typedef void pointer; typedef _Container container_type;
typedef void reference; typedef output_iterator_tag iterator_category;
typedef void value_type;
insert_iterator(_Container& __x) : container(&__x) {} typedef void difference_type;
insert_iterator(_Container& __x, typename _Container::iterator) typedef void pointer;
: container(&__x) {} typedef void reference;
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) { insert_iterator(_Container& __x)
container->insert(__value); : container(&__x) {}
return *this;
} insert_iterator(_Container& __x, typename _Container::iterator)
insert_iterator<_Container>& operator*() { return *this; } : container(&__x) {}
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; } insert_iterator<_Container>&
}; operator=(const typename _Container::value_type& __value)
{
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> container->insert(__value);
class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { return *this;
protected: }
typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
_Container* container; insert_iterator<_Container>&
typename _Container::iterator iter; operator*()
public: { return *this; }
typedef _Container container_type;
typedef output_iterator_tag iterator_category; insert_iterator<_Container>&
typedef void value_type; operator++()
typedef void difference_type; { return *this; }
typedef void pointer;
typedef void reference; insert_iterator<_Container>&
operator++(int)
insert_iterator(_Container& __x) : container(&__x) {} { return *this; }
insert_iterator(_Container& __x, typename _Container::iterator) };
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value) {
container->insert(__value);
return *this;
}
insert_iterator<_Container>& operator*() { return *this; }
insert_iterator<_Container>& operator++() { return *this; }
insert_iterator<_Container>& operator++(int) { return *this; }
};
} // namespace std
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;
typename _Container::iterator iter;
public:
typedef _Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
insert_iterator(_Container& __x)
: container(&__x) {}
insert_iterator(_Container& __x, typename _Container::iterator)
: container(&__x) {}
insert_iterator<_Container>&
operator=(const typename _Container::value_type& __value)
{
container->insert(__value);
return *this;
}
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
...@@ -155,16 +149,16 @@ namespace __gnu_cxx ...@@ -155,16 +149,16 @@ namespace __gnu_cxx
* @ingroup SGIextensions * @ingroup SGIextensions
*/ */
template <class _ForwardIterator, class _Tp template <class _ForwardIterator, class _Tp
= typename std::iterator_traits<_ForwardIterator>::value_type > = typename std::iterator_traits<_ForwardIterator>::value_type >
struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
{ {
/// Requests storage large enough to hold a copy of [first,last). /// Requests storage large enough to hold a copy of [first,last).
temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
: _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { } : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { }
/// Destroys objects and frees storage. /// Destroys objects and frees storage.
~temporary_buffer() { } ~temporary_buffer() { }
}; };
} // namespace __gnu_cxx } // namespace __gnu_cxx
#endif #endif
......
// 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,22 +79,25 @@ namespace __gnu_cxx ...@@ -79,22 +79,25 @@ 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;
__x = __monoid_op(__x, __x);
}
_Tp __result = __x;
__n >>= 1; __n >>= 1;
__x = __monoid_op(__x, __x); while (__n != 0)
{
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
} }
_Tp __result = __x;
__n >>= 1;
while (__n != 0) {
__x = __monoid_op(__x, __x);
if ((__n & 1) != 0)
__result = __monoid_op(__result, __x);
__n >>= 1;
}
return __result;
}
} }
template<typename _Tp, typename _Integer> template<typename _Tp, typename _Integer>
......
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