unordered_map.h (__unordered_map): Remove.
2012-04-12 Benjamin Kosnik <bkoz@redhat.com> * include/bits/unordered_map.h (__unordered_map): Remove. (__unordered_multimap): Remove. Add aliases for __umap_traits, __umap_hashtable, __ummap_traits, __ummap_hashtable. (unordered_map): Derive from __umap_hashtable. (unordered_multimap): Derive from __ummap_hashtable. * include/bits/unordered_set.h (__unordered_set): Remove. (__unordered_multiset): Remove. Add aliases for __uset_traits, __uset_hashtable, __umset_traits, __umset_hashtable. (unordered_set): Derive from __uset_hashtable. (unordered_multiset): Derive from __umset_hashtable. * include/bits/hashtable.h (__cache_default): New, consolidated cache defaults for _Hashtable. Adjust comments for doxygen. (_Hashtable): Consolidate bool template parameters into new, _Traits class. Inherited base classes synthesize _Hashtable in CRTP via original 10 parameters. Prefer using declarations to typedefs, add __node_type, __bucket_type, etc. Push many nested types down hierarchy to _Hashtable_base. Add constructors necessary for top-level unordered_containers. Consolidate insert member functions and logic in new base class, __detail::_Insert and __detail::_Insert_base. (_Hashtable::operator=(initializer_list)): Add. * include/bits/hashtable_policy.h: Convert to doxygen markup. (_Hashtable_traits) New. Consolidate bool template parameters here. (_Insert, _Insert_base): New, consolidated insert member functions. (_Map_base, _Equality, _Rehash_base): Adjust template parameters, use base types. (_Hashtable_base): Move type declarations useful to other base classes into this class. * python/libstdcxx/v6/printers.py (Tr1HashtableIterator): Update. * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust traits, line numbers. From-SVN: r186403
This commit is contained in:
parent
3f5c27c683
commit
4dad8b49ee
@ -1,3 +1,39 @@
|
|||||||
|
2012-04-12 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/unordered_map.h (__unordered_map): Remove.
|
||||||
|
(__unordered_multimap): Remove.
|
||||||
|
Add aliases for __umap_traits, __umap_hashtable, __ummap_traits,
|
||||||
|
__ummap_hashtable.
|
||||||
|
(unordered_map): Derive from __umap_hashtable.
|
||||||
|
(unordered_multimap): Derive from __ummap_hashtable.
|
||||||
|
* include/bits/unordered_set.h (__unordered_set): Remove.
|
||||||
|
(__unordered_multiset): Remove.
|
||||||
|
Add aliases for __uset_traits, __uset_hashtable, __umset_traits,
|
||||||
|
__umset_hashtable.
|
||||||
|
(unordered_set): Derive from __uset_hashtable.
|
||||||
|
(unordered_multiset): Derive from __umset_hashtable.
|
||||||
|
* include/bits/hashtable.h (__cache_default): New, consolidated
|
||||||
|
cache defaults for _Hashtable. Adjust comments for doxygen.
|
||||||
|
(_Hashtable): Consolidate bool template parameters into new,
|
||||||
|
_Traits class. Inherited base classes synthesize _Hashtable in
|
||||||
|
CRTP via original 10 parameters. Prefer using declarations to
|
||||||
|
typedefs, add __node_type, __bucket_type, etc. Push many nested
|
||||||
|
types down hierarchy to _Hashtable_base. Add constructors
|
||||||
|
necessary for top-level unordered_containers. Consolidate insert
|
||||||
|
member functions and logic in new base class, __detail::_Insert
|
||||||
|
and __detail::_Insert_base.
|
||||||
|
(_Hashtable::operator=(initializer_list)): Add.
|
||||||
|
* include/bits/hashtable_policy.h: Convert to doxygen markup.
|
||||||
|
(_Hashtable_traits) New. Consolidate bool template parameters here.
|
||||||
|
(_Insert, _Insert_base): New, consolidated insert member functions.
|
||||||
|
(_Map_base, _Equality, _Rehash_base): Adjust template parameters,
|
||||||
|
use base types.
|
||||||
|
(_Hashtable_base): Move type declarations useful to other base
|
||||||
|
classes into this class.
|
||||||
|
* python/libstdcxx/v6/printers.py (Tr1HashtableIterator): Update.
|
||||||
|
* testsuite/23_containers/unordered_set/instantiation_neg.cc:
|
||||||
|
Adjust traits, line numbers.
|
||||||
|
|
||||||
2012-04-12 Jeffrey Yasskin <jyasskin@google.com>
|
2012-04-12 Jeffrey Yasskin <jyasskin@google.com>
|
||||||
|
|
||||||
PR libstdc++/52822
|
PR libstdc++/52822
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
// unordered_map implementation -*- C++ -*-
|
// unordered_map implementation -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
// Copyright (C) 2010, 2011, 2012 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
|
||||||
@ -34,208 +34,41 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
|||||||
{
|
{
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
|
|
||||||
// NB: When we get typedef templates these class definitions
|
/// Base types for unordered_map.
|
||||||
// will be unnecessary.
|
template<bool _Cache>
|
||||||
template<class _Key, class _Tp,
|
using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>;
|
||||||
class _Hash = hash<_Key>,
|
|
||||||
class _Pred = std::equal_to<_Key>,
|
|
||||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
|
||||||
bool __cache_hash_code =
|
|
||||||
__not_<__and_<is_integral<_Key>, is_empty<_Hash>,
|
|
||||||
integral_constant<bool, !__is_final(_Hash)>,
|
|
||||||
__detail::__is_noexcept_hash<_Key, _Hash>>>::value>
|
|
||||||
class __unordered_map
|
|
||||||
: public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
|
|
||||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, false, true>
|
|
||||||
{
|
|
||||||
typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
|
|
||||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, false, true>
|
|
||||||
_Base;
|
|
||||||
|
|
||||||
public:
|
template<typename _Key,
|
||||||
typedef typename _Base::value_type value_type;
|
typename _Tp,
|
||||||
typedef typename _Base::size_type size_type;
|
typename _Hash = hash<_Key>,
|
||||||
typedef typename _Base::hasher hasher;
|
typename _Pred = std::equal_to<_Key>,
|
||||||
typedef typename _Base::key_equal key_equal;
|
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>>
|
||||||
|
using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||||
|
_Alloc,
|
||||||
|
std::_Select1st<std::pair<const _Key, _Tp>>,
|
||||||
|
_Pred, _Hash,
|
||||||
|
__detail::_Mod_range_hashing,
|
||||||
|
__detail::_Default_ranged_hash,
|
||||||
|
__detail::_Prime_rehash_policy, _Tr>;
|
||||||
|
|
||||||
explicit
|
/// Base types for unordered_multimap.
|
||||||
__unordered_map(size_type __n = 10,
|
template<bool _Cache>
|
||||||
const hasher& __hf = hasher(),
|
using __ummap_traits = __detail::_Hashtable_traits<_Cache, false, false>;
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(),
|
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _Key,
|
||||||
__unordered_map(_InputIterator __f, _InputIterator __l,
|
typename _Tp,
|
||||||
size_type __n = 0,
|
typename _Hash = hash<_Key>,
|
||||||
const hasher& __hf = hasher(),
|
typename _Pred = std::equal_to<_Key>,
|
||||||
const key_equal& __eql = key_equal(),
|
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
||||||
const allocator_type& __a = allocator_type())
|
typename _Tr = __ummap_traits<__cache_default<_Key, _Hash>::value>>
|
||||||
: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
|
using __ummap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
||||||
__detail::_Default_ranged_hash(),
|
_Alloc,
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
std::_Select1st<std::pair<const _Key, _Tp>>,
|
||||||
{ }
|
_Pred, _Hash,
|
||||||
|
__detail::_Mod_range_hashing,
|
||||||
__unordered_map(initializer_list<value_type> __l,
|
__detail::_Default_ranged_hash,
|
||||||
size_type __n = 0,
|
__detail::_Prime_rehash_policy, _Tr>;
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
|
||||||
__detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(),
|
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_map&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class _Key, class _Tp,
|
|
||||||
class _Hash = hash<_Key>,
|
|
||||||
class _Pred = std::equal_to<_Key>,
|
|
||||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
|
|
||||||
bool __cache_hash_code =
|
|
||||||
__not_<__and_<is_integral<_Key>, is_empty<_Hash>,
|
|
||||||
integral_constant<bool, !__is_final(_Hash)>,
|
|
||||||
__detail::__is_noexcept_hash<_Key, _Hash>>>::value>
|
|
||||||
class __unordered_multimap
|
|
||||||
: public _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
|
||||||
_Alloc,
|
|
||||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, false, false>
|
|
||||||
{
|
|
||||||
typedef _Hashtable<_Key, std::pair<const _Key, _Tp>,
|
|
||||||
_Alloc,
|
|
||||||
std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, false, false>
|
|
||||||
_Base;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef typename _Base::value_type value_type;
|
|
||||||
typedef typename _Base::size_type size_type;
|
|
||||||
typedef typename _Base::hasher hasher;
|
|
||||||
typedef typename _Base::key_equal key_equal;
|
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
__unordered_multimap(size_type __n = 10,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(),
|
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
|
||||||
__unordered_multimap(_InputIterator __f, _InputIterator __l,
|
|
||||||
size_type __n = 0,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(),
|
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_multimap(initializer_list<value_type> __l,
|
|
||||||
size_type __n = 0,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
|
||||||
__detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(),
|
|
||||||
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_multimap&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline void
|
|
||||||
swap(__unordered_map<_Key, _Tp, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __x,
|
|
||||||
__unordered_map<_Key, _Tp, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __y)
|
|
||||||
{ __x.swap(__y); }
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline void
|
|
||||||
swap(__unordered_multimap<_Key, _Tp, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __x,
|
|
||||||
__unordered_multimap<_Key, _Tp, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __y)
|
|
||||||
{ __x.swap(__y); }
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator==(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return __x._M_equal(__y); }
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator!=(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return !(__x == __y); }
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator==(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return __x._M_equal(__y); }
|
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator!=(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return !(__x == __y); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A standard container composed of unique keys (containing
|
* @brief A standard container composed of unique keys (containing
|
||||||
@ -247,22 +80,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||||
* <a href="tables.html#xx">unordered associative container</a>
|
* <a href="tables.html#xx">unordered associative container</a>
|
||||||
*
|
*
|
||||||
* @param Key Type of key objects.
|
* @tparam _Key Type of key objects.
|
||||||
* @param Tp Type of mapped objects.
|
* @tparam _Tp Type of mapped objects.
|
||||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
* @tparam _Pred Predicate function object type, defaults
|
||||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
* to equal_to<_Value>.
|
||||||
|
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||||
*
|
*
|
||||||
* The resulting value type of the container is std::pair<const Key, Tp>.
|
* The resulting value type of the container is std::pair<const _Key, _Tp>.
|
||||||
|
*
|
||||||
|
* Base is _Hashtable, dispatched at compile time via template
|
||||||
|
* alias __umap_hashtable.
|
||||||
*/
|
*/
|
||||||
template<class _Key, class _Tp,
|
template<class _Key, class _Tp,
|
||||||
class _Hash = hash<_Key>,
|
class _Hash = hash<_Key>,
|
||||||
class _Pred = std::equal_to<_Key>,
|
class _Pred = std::equal_to<_Key>,
|
||||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
||||||
class unordered_map
|
class unordered_map
|
||||||
: public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
|
: public __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||||
{
|
{
|
||||||
typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
@ -280,13 +117,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_map(_InputIterator __f, _InputIterator __l,
|
unordered_map(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_map(initializer_list<value_type> __l,
|
unordered_map(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
@ -295,16 +132,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_map&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A standard container composed of equivalent keys
|
* @brief A standard container composed of equivalent keys
|
||||||
* (possibly containing multiple of each key value) that associates
|
* (possibly containing multiple of each key value) that associates
|
||||||
@ -315,22 +144,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||||
* <a href="tables.html#xx">unordered associative container</a>
|
* <a href="tables.html#xx">unordered associative container</a>
|
||||||
*
|
*
|
||||||
* @param Key Type of key objects.
|
* @tparam _Key Type of key objects.
|
||||||
* @param Tp Type of mapped objects.
|
* @tparam _Tp Type of mapped objects.
|
||||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
* @tparam _Pred Predicate function object type, defaults
|
||||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
* to equal_to<_Value>.
|
||||||
|
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||||
*
|
*
|
||||||
* The resulting value type of the container is std::pair<const Key, Tp>.
|
* The resulting value type of the container is std::pair<const _Key, _Tp>.
|
||||||
|
*
|
||||||
|
* Base is _Hashtable, dispatched at compile time via template
|
||||||
|
* alias __ummap_hashtable.
|
||||||
*/
|
*/
|
||||||
template<class _Key, class _Tp,
|
template<class _Key, class _Tp,
|
||||||
class _Hash = hash<_Key>,
|
class _Hash = hash<_Key>,
|
||||||
class _Pred = std::equal_to<_Key>,
|
class _Pred = std::equal_to<_Key>,
|
||||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
|
||||||
class unordered_multimap
|
class unordered_multimap
|
||||||
: public __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
|
: public __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>
|
||||||
{
|
{
|
||||||
typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
@ -338,7 +171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_multimap(size_type __n = 10,
|
unordered_multimap(size_type __n = 10,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
@ -348,13 +181,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_multimap(_InputIterator __f, _InputIterator __l,
|
unordered_multimap(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_multimap(initializer_list<value_type> __l,
|
unordered_multimap(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
@ -363,14 +196,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_multimap&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// unordered_set implementation -*- C++ -*-
|
// unordered_set implementation -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
// Copyright (C) 2010, 2011, 2012 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
|
||||||
@ -34,228 +34,36 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
|||||||
{
|
{
|
||||||
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
||||||
|
|
||||||
// NB: When we get typedef templates these class definitions
|
/// Base types for unordered_set.
|
||||||
// will be unnecessary.
|
template<bool _Cache>
|
||||||
template<class _Value,
|
using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>;
|
||||||
class _Hash = hash<_Value>,
|
|
||||||
class _Pred = std::equal_to<_Value>,
|
|
||||||
class _Alloc = std::allocator<_Value>,
|
|
||||||
bool __cache_hash_code =
|
|
||||||
__not_<__and_<is_integral<_Value>, is_empty<_Hash>,
|
|
||||||
integral_constant<bool, !__is_final(_Hash)>,
|
|
||||||
__detail::__is_noexcept_hash<_Value, _Hash>>>::value>
|
|
||||||
class __unordered_set
|
|
||||||
: public _Hashtable<_Value, _Value, _Alloc,
|
|
||||||
std::_Identity<_Value>, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, true, true>
|
|
||||||
{
|
|
||||||
typedef _Hashtable<_Value, _Value, _Alloc,
|
|
||||||
std::_Identity<_Value>, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, true, true>
|
|
||||||
_Base;
|
|
||||||
|
|
||||||
public:
|
template<typename _Value,
|
||||||
typedef typename _Base::value_type value_type;
|
typename _Hash = hash<_Value>,
|
||||||
typedef typename _Base::size_type size_type;
|
typename _Pred = std::equal_to<_Value>,
|
||||||
typedef typename _Base::hasher hasher;
|
typename _Alloc = std::allocator<_Value>,
|
||||||
typedef typename _Base::key_equal key_equal;
|
typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>>
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
|
||||||
typedef typename _Base::iterator iterator;
|
std::_Identity<_Value>, _Pred, _Hash,
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
__detail::_Mod_range_hashing,
|
||||||
|
__detail::_Default_ranged_hash,
|
||||||
|
__detail::_Prime_rehash_policy, _Tr>;
|
||||||
|
|
||||||
explicit
|
/// Base types for unordered_multiset.
|
||||||
__unordered_set(size_type __n = 10,
|
template<bool _Cache>
|
||||||
const hasher& __hf = hasher(),
|
using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>;
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
|
||||||
std::_Identity<value_type>(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _Value,
|
||||||
__unordered_set(_InputIterator __f, _InputIterator __l,
|
typename _Hash = hash<_Value>,
|
||||||
size_type __n = 0,
|
typename _Pred = std::equal_to<_Value>,
|
||||||
const hasher& __hf = hasher(),
|
typename _Alloc = std::allocator<_Value>,
|
||||||
const key_equal& __eql = key_equal(),
|
typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>>
|
||||||
const allocator_type& __a = allocator_type())
|
using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
|
||||||
: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
|
std::_Identity<_Value>,
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
_Pred, _Hash,
|
||||||
std::_Identity<value_type>(), __a)
|
__detail::_Mod_range_hashing,
|
||||||
{ }
|
__detail::_Default_ranged_hash,
|
||||||
|
__detail::_Prime_rehash_policy, _Tr>;
|
||||||
__unordered_set(initializer_list<value_type> __l,
|
|
||||||
size_type __n = 0,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
|
||||||
__detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
|
||||||
std::_Identity<value_type>(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_set&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
using _Base::insert;
|
|
||||||
|
|
||||||
std::pair<iterator, bool>
|
|
||||||
insert(value_type&& __v)
|
|
||||||
{ return this->_M_insert(std::move(__v), std::true_type()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
insert(const_iterator, value_type&& __v)
|
|
||||||
{ return insert(std::move(__v)).first; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class _Value,
|
|
||||||
class _Hash = hash<_Value>,
|
|
||||||
class _Pred = std::equal_to<_Value>,
|
|
||||||
class _Alloc = std::allocator<_Value>,
|
|
||||||
bool __cache_hash_code =
|
|
||||||
__not_<__and_<is_integral<_Value>, is_empty<_Hash>,
|
|
||||||
integral_constant<bool, !__is_final(_Hash)>,
|
|
||||||
__detail::__is_noexcept_hash<_Value, _Hash>>>::value>
|
|
||||||
class __unordered_multiset
|
|
||||||
: public _Hashtable<_Value, _Value, _Alloc,
|
|
||||||
std::_Identity<_Value>, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, true, false>
|
|
||||||
{
|
|
||||||
typedef _Hashtable<_Value, _Value, _Alloc,
|
|
||||||
std::_Identity<_Value>, _Pred,
|
|
||||||
_Hash, __detail::_Mod_range_hashing,
|
|
||||||
__detail::_Default_ranged_hash,
|
|
||||||
__detail::_Prime_rehash_policy,
|
|
||||||
__cache_hash_code, true, false>
|
|
||||||
_Base;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef typename _Base::value_type value_type;
|
|
||||||
typedef typename _Base::size_type size_type;
|
|
||||||
typedef typename _Base::hasher hasher;
|
|
||||||
typedef typename _Base::key_equal key_equal;
|
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
|
||||||
typedef typename _Base::iterator iterator;
|
|
||||||
typedef typename _Base::const_iterator const_iterator;
|
|
||||||
|
|
||||||
explicit
|
|
||||||
__unordered_multiset(size_type __n = 10,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
|
||||||
std::_Identity<value_type>(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
|
||||||
__unordered_multiset(_InputIterator __f, _InputIterator __l,
|
|
||||||
size_type __n = 0,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
|
||||||
std::_Identity<value_type>(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_multiset(initializer_list<value_type> __l,
|
|
||||||
size_type __n = 0,
|
|
||||||
const hasher& __hf = hasher(),
|
|
||||||
const key_equal& __eql = key_equal(),
|
|
||||||
const allocator_type& __a = allocator_type())
|
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf,
|
|
||||||
__detail::_Mod_range_hashing(),
|
|
||||||
__detail::_Default_ranged_hash(), __eql,
|
|
||||||
std::_Identity<value_type>(), __a)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
__unordered_multiset&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
using _Base::insert;
|
|
||||||
|
|
||||||
iterator
|
|
||||||
insert(value_type&& __v)
|
|
||||||
{ return this->_M_insert(std::move(__v), std::false_type()); }
|
|
||||||
|
|
||||||
iterator
|
|
||||||
insert(const_iterator, value_type&& __v)
|
|
||||||
{ return insert(std::move(__v)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline void
|
|
||||||
swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
|
|
||||||
__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
|
|
||||||
{ __x.swap(__y); }
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline void
|
|
||||||
swap(__unordered_multiset<_Value, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __x,
|
|
||||||
__unordered_multiset<_Value, _Hash, _Pred,
|
|
||||||
_Alloc, __cache_hash_code>& __y)
|
|
||||||
{ __x.swap(__y); }
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator==(const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return __x._M_equal(__y); }
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator!=(const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_set<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return !(__x == __y); }
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator==(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return __x._M_equal(__y); }
|
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc,
|
|
||||||
bool __cache_hash_code>
|
|
||||||
inline bool
|
|
||||||
operator!=(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __x,
|
|
||||||
const __unordered_multiset<_Value, _Hash, _Pred, _Alloc,
|
|
||||||
__cache_hash_code>& __y)
|
|
||||||
{ return !(__x == __y); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A standard container composed of unique keys (containing
|
* @brief A standard container composed of unique keys (containing
|
||||||
@ -267,19 +75,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||||
* <a href="tables.html#xx">unordered associative container</a>
|
* <a href="tables.html#xx">unordered associative container</a>
|
||||||
*
|
*
|
||||||
* @param Value Type of key objects.
|
* @tparam _Value Type of key objects.
|
||||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
|
||||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
* @tparam _Pred Predicate function object type, defaults to
|
||||||
|
* equal_to<_Value>.
|
||||||
|
*
|
||||||
|
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||||
|
*
|
||||||
|
* Base is _Hashtable, dispatched at compile time via template
|
||||||
|
* alias __uset_hashtable.
|
||||||
*/
|
*/
|
||||||
template<class _Value,
|
template<class _Value,
|
||||||
class _Hash = hash<_Value>,
|
class _Hash = hash<_Value>,
|
||||||
class _Pred = std::equal_to<_Value>,
|
class _Pred = std::equal_to<_Value>,
|
||||||
class _Alloc = std::allocator<_Value> >
|
class _Alloc = std::allocator<_Value> >
|
||||||
class unordered_set
|
class unordered_set
|
||||||
: public __unordered_set<_Value, _Hash, _Pred, _Alloc>
|
: public __uset_hashtable<_Value, _Hash, _Pred, _Alloc>
|
||||||
{
|
{
|
||||||
typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base;
|
typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
@ -287,7 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_set(size_type __n = 10,
|
unordered_set(size_type __n = 10,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
@ -297,13 +111,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_set(_InputIterator __f, _InputIterator __l,
|
unordered_set(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_set(initializer_list<value_type> __l,
|
unordered_set(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
@ -312,14 +126,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_set&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,19 +138,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
* Meets the requirements of a <a href="tables.html#65">container</a>, and
|
||||||
* <a href="tables.html#xx">unordered associative container</a>
|
* <a href="tables.html#xx">unordered associative container</a>
|
||||||
*
|
*
|
||||||
* @param Value Type of key objects.
|
* @tparam _Value Type of key objects.
|
||||||
* @param Hash Hashing function object type, defaults to hash<Value>.
|
* @tparam _Hash Hashing function object type, defaults to hash<_Value>.
|
||||||
* @param Pred Predicate function object type, defaults to equal_to<Value>.
|
* @tparam _Pred Predicate function object type, defaults
|
||||||
* @param Alloc Allocator type, defaults to allocator<Key>.
|
* to equal_to<_Value>.
|
||||||
|
* @tparam _Alloc Allocator type, defaults to allocator<_Key>.
|
||||||
|
*
|
||||||
|
* Base is _Hashtable, dispatched at compile time via template
|
||||||
|
* alias __umset_hashtable.
|
||||||
*/
|
*/
|
||||||
template<class _Value,
|
template<class _Value,
|
||||||
class _Hash = hash<_Value>,
|
class _Hash = hash<_Value>,
|
||||||
class _Pred = std::equal_to<_Value>,
|
class _Pred = std::equal_to<_Value>,
|
||||||
class _Alloc = std::allocator<_Value> >
|
class _Alloc = std::allocator<_Value> >
|
||||||
class unordered_multiset
|
class unordered_multiset
|
||||||
: public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
|
: public __umset_hashtable<_Value, _Hash, _Pred, _Alloc>
|
||||||
{
|
{
|
||||||
typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base;
|
typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename _Base::value_type value_type;
|
typedef typename _Base::value_type value_type;
|
||||||
@ -352,7 +162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
typedef typename _Base::hasher hasher;
|
typedef typename _Base::hasher hasher;
|
||||||
typedef typename _Base::key_equal key_equal;
|
typedef typename _Base::key_equal key_equal;
|
||||||
typedef typename _Base::allocator_type allocator_type;
|
typedef typename _Base::allocator_type allocator_type;
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
unordered_multiset(size_type __n = 10,
|
unordered_multiset(size_type __n = 10,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
@ -363,13 +173,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
|
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
unordered_multiset(_InputIterator __f, _InputIterator __l,
|
unordered_multiset(_InputIterator __f, _InputIterator __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
const hasher& __hf = hasher(),
|
const hasher& __hf = hasher(),
|
||||||
const key_equal& __eql = key_equal(),
|
const key_equal& __eql = key_equal(),
|
||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__f, __l, __n, __hf, __eql, __a)
|
: _Base(__f, __l, __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_multiset(initializer_list<value_type> __l,
|
unordered_multiset(initializer_list<value_type> __l,
|
||||||
size_type __n = 0,
|
size_type __n = 0,
|
||||||
@ -378,14 +188,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||||||
const allocator_type& __a = allocator_type())
|
const allocator_type& __a = allocator_type())
|
||||||
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
: _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
unordered_multiset&
|
|
||||||
operator=(initializer_list<value_type> __l)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
this->insert(__l.begin(), __l.end());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class _Value, class _Hash, class _Pred, class _Alloc>
|
template<class _Value, class _Hash, class _Pred, class _Alloc>
|
||||||
@ -428,4 +230,3 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
|
|||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
#endif /* _UNORDERED_SET_H */
|
#endif /* _UNORDERED_SET_H */
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ class StdStringPrinter:
|
|||||||
class Tr1HashtableIterator:
|
class Tr1HashtableIterator:
|
||||||
def __init__ (self, hash):
|
def __init__ (self, hash):
|
||||||
self.node = hash['_M_before_begin']['_M_nxt']
|
self.node = hash['_M_before_begin']['_M_nxt']
|
||||||
self.node_type = find_type(hash.type, '_Node').pointer()
|
self.node_type = find_type(hash.type, '__node_type').pointer()
|
||||||
|
|
||||||
def __iter__ (self):
|
def __iter__ (self):
|
||||||
return self
|
return self
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
// { dg-require-normal-mode "" }
|
// { dg-require-normal-mode "" }
|
||||||
|
|
||||||
// Copyright (C) 2011 Free Software Foundation, Inc.
|
// Copyright (C) 2011, 2012 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
|
||||||
@ -19,7 +19,7 @@
|
|||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 185 }
|
// { dg-error "with noexcept" "" { target *-*-* } 248 }
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
@ -35,7 +35,10 @@ namespace
|
|||||||
void
|
void
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
std::__unordered_set<int, hash_without_noexcept,
|
using traits = std::__detail::_Hashtable_traits<false, true, true>;
|
||||||
std::equal_to<int>, std::allocator<int>,
|
using hashtable = std::__uset_hashtable<int, hash_without_noexcept,
|
||||||
false> us;
|
std::equal_to<int>,
|
||||||
|
std::allocator<int>, traits>;
|
||||||
|
|
||||||
|
hashtable ht;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user