summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/profile/unordered_map
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-02-10 16:09:42 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-02-10 16:09:42 +0000
commit73e1eac5f56ff2de695704895b6ad2cb8faf8225 (patch)
tree88ec53b5787238bd38592fc81959492719765e0c /libstdc++-v3/include/profile/unordered_map
parent5b0b615625dfd3508b2e891413adf3a2c8dd270c (diff)
downloadppe42-gcc-73e1eac5f56ff2de695704895b6ad2cb8faf8225.tar.gz
ppe42-gcc-73e1eac5f56ff2de695704895b6ad2cb8faf8225.zip
2010-02-10 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/hashtable.h: Fold in include/tr1_impl/hashtable.h for C++0x use. * include/bits/hashtable_policy.h: New, copy and adjust for C++0x use, include/tr1_impl/hashtable_policy.h; fix erase and insert member functions per n3000. * include/bits/unordered_map.h: Likewise for include/tr1_impl/ unordered_map. * include/bits/unordered_set.h: Likewise for include/tr1_impl/ unordered_set. * include/Makefile.am: Adjust. * include/Makefile.in: Regenerate. * include/tr1/unordered_map: Adjust. * include/tr1/unordered_set: Likewise. * include/tr1_impl/unordered_map: Adjust, now used only by tr1. * include/tr1_impl/hashtable: Likewise. * include/tr1_impl/hashtable_policy.h: Likewise. * include/tr1_impl/unordered_set: Likewise. * include/std/unordered_map: Adjust and simplify includes. * include/std/unordered_set: Likewise. * include/debug/unordered_map: Adjuse erase and insert members. * include/debug/unordered_set: Likewise. * include/profile/unordered_map: Likewise. * include/profile/unordered_set: Likewise. * testsuite/util/exception/safety.h: Fix for the updated erase and insert member functions of the unordered_containers. * testsuite/23_containers/unordered_map/erase/1.cc: New. * testsuite/23_containers/unordered_map/erase/24061-map.cc: Likewise. * testsuite/23_containers/unordered_map/insert/map_single.cc: Likewise. * testsuite/23_containers/unordered_map/insert/array_syntax.cc: Likewise. * testsuite/23_containers/unordered_map/insert/24061-map.cc: Likewise. * testsuite/23_containers/unordered_map/insert/map_range.cc: Likewise. * testsuite/23_containers/set/operators/1_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/erase/1.cc: Likewise. * testsuite/23_containers/unordered_multimap/erase/ 24061-multimap.cc: Likewise. * testsuite/23_containers/unordered_multimap/insert/ 24061-multimap.cc: Likewise. * testsuite/23_containers/unordered_multimap/insert/ multimap_range.cc: Likewise. * testsuite/23_containers/unordered_multimap/insert/ multimap_single.cc: Likewise. * testsuite/23_containers/unordered_set/erase/1.cc: Likewise. * testsuite/23_containers/unordered_set/erase/24061-set.cc: Likewise. * testsuite/23_containers/unordered_set/insert/set_single.cc: Likewise. * testsuite/23_containers/unordered_set/insert/24061-set.cc: Likewise. * testsuite/23_containers/unordered_set/insert/set_range.cc: Likewise. * testsuite/23_containers/unordered_multiset/erase/1.cc: Likewise. * testsuite/23_containers/unordered_multiset/erase/ 24061-multiset.cc: Likewise. * testsuite/23_containers/unordered_multiset/insert/ 24061-multiset.cc: Likewise. * testsuite/23_containers/unordered_multiset/insert/ multiset_range.cc: Likewise. * testsuite/23_containers/unordered_multiset/insert/ multiset_single.cc: Likewise. * testsuite/23_containers/set/operators/1_neg.cc: Tweak dg-errors to avoid spurious fails in debug-mode. * testsuite/23_containers/map/operators/1_neg.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156661 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/profile/unordered_map')
-rw-r--r--libstdc++-v3/include/profile/unordered_map154
1 files changed, 71 insertions, 83 deletions
diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map
index 74781de2dd4..61f32f3036f 100644
--- a/libstdc++-v3/include/profile/unordered_map
+++ b/libstdc++-v3/include/profile/unordered_map
@@ -186,31 +186,22 @@ namespace __profile
}
iterator
- insert(iterator __iter, const value_type& __v)
- {
- size_type __old_size = _Base::bucket_count();
- iterator res = _Base::insert(__iter, __v);
- _M_profile_resize(__old_size, _Base::bucket_count());
- return res;
- }
-
- const_iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
- const_iterator res =_Base::insert(__iter, __v);
+ iterator __res = _Base::insert(__iter, __v);
_M_profile_resize(__old_size, _Base::bucket_count());
- return res;
+ return __res;
}
template<typename _InputIter>
- void
- insert(_InputIter __first, _InputIter __last)
- {
- size_type __old_size = _Base::bucket_count();
- _Base::insert(__first.base(), __last.base());
- _M_profile_resize(__old_size, _Base::bucket_count());
- }
+ void
+ insert(_InputIter __first, _InputIter __last)
+ {
+ size_type __old_size = _Base::bucket_count();
+ _Base::insert(__first.base(), __last.base());
+ _M_profile_resize(__old_size, _Base::bucket_count());
+ }
void
insert(const value_type* __first, const value_type* __last)
@@ -233,51 +224,54 @@ namespace __profile
void
swap(unordered_map& __x)
- {
- _Base::swap(__x);
- }
-
+ { _Base::swap(__x); }
+
void rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
_M_profile_resize(__old_size, _Base::bucket_count());
}
+
private:
- void _M_profile_resize(size_type __old_size, size_type __new_size)
+ void
+ _M_profile_resize(size_type __old_size, size_type __new_size)
{
if (__old_size != __new_size)
- {
- __profcxx_hashtable_resize(this, __old_size, __new_size);
- }
+ __profcxx_hashtable_resize(this, __old_size, __new_size);
}
- void _M_profile_destruct()
+
+ void
+ _M_profile_destruct()
{
size_type __hops = 0, __lc = 0, __chain = 0;
- for (iterator it = _M_base().begin(); it != _M_base().end(); it++)
- {
- while (it._M_cur_node->_M_next) {
- __chain++;
- it++;
- }
- if (__chain) {
- __chain++;
- __lc = __lc > __chain ? __lc : __chain;
- __hops += __chain * (__chain - 1) / 2;
- __chain = 0;
- }
- }
+ for (iterator __it = _M_base().begin(); __it != _M_base().end();
+ ++__it)
+ {
+ while (__it._M_cur_node->_M_next)
+ {
+ ++__chain;
+ ++__it;
+ }
+ if (__chain)
+ {
+ ++__chain;
+ __lc = __lc > __chain ? __lc : __chain;
+ __hops += __chain * (__chain - 1) / 2;
+ __chain = 0;
+ }
+ }
__profcxx_hashtable_destruct2(this, __lc, _Base::size(), __hops);
}
};
+
template<typename _Key, typename _Tp, typename _Hash,
- typename _Pred, typename _Alloc>
+ typename _Pred, typename _Alloc>
inline void
swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
- unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ __x.swap(__y); }
-
#undef _GLIBCXX_BASE
#undef _GLIBCXX_STD_BASE
#define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
@@ -412,31 +406,22 @@ namespace __profile
}
iterator
- insert(iterator __iter, const value_type& __v)
- {
- size_type __old_size = _Base::bucket_count();
- iterator res = _Base::insert(__iter, __v);
- _M_profile_resize(__old_size, _Base::bucket_count());
- return res;
- }
-
- const_iterator
insert(const_iterator __iter, const value_type& __v)
{
size_type __old_size = _Base::bucket_count();
- const_iterator res =_Base::insert(__iter, __v);
+ iterator __res =_Base::insert(__iter, __v);
_M_profile_resize(__old_size, _Base::bucket_count());
- return res;
+ return __res;
}
template<typename _InputIter>
- void
- insert(_InputIter __first, _InputIter __last)
- {
- size_type __old_size = _Base::bucket_count();
- _Base::insert(__first.base(), __last.base());
- _M_profile_resize(__old_size, _Base::bucket_count());
- }
+ void
+ insert(_InputIter __first, _InputIter __last)
+ {
+ size_type __old_size = _Base::bucket_count();
+ _Base::insert(__first.base(), __last.base());
+ _M_profile_resize(__old_size, _Base::bucket_count());
+ }
void
insert(const value_type* __first, const value_type* __last)
@@ -448,9 +433,7 @@ namespace __profile
void
swap(unordered_multimap& __x)
- {
- _Base::swap(__x);
- }
+ { _Base::swap(__x); }
void rehash(size_type __n)
{
@@ -458,40 +441,45 @@ namespace __profile
_Base::rehash(__n);
_M_profile_resize(__old_size, _Base::bucket_count());
}
+
private:
- void _M_profile_resize(size_type __old_size, size_type __new_size)
+ void
+ _M_profile_resize(size_type __old_size, size_type __new_size)
{
if (__old_size != __new_size)
- {
__profcxx_hashtable_resize(this, __old_size, __new_size);
- }
}
- void _M_profile_destruct()
+ void
+ _M_profile_destruct()
{
size_type __hops = 0, __lc = 0, __chain = 0;
- for (iterator it = _M_base().begin(); it != _M_base().end(); it++)
- {
- while (it._M_cur_node->_M_next) {
- __chain++;
- it++;
- }
- if (__chain) {
- __chain++;
- __lc = __lc > __chain ? __lc : __chain;
- __hops += __chain * (__chain - 1) / 2;
- __chain = 0;
- }
- }
+ for (iterator __it = _M_base().begin(); __it != _M_base().end();
+ ++__it)
+ {
+ while (__it._M_cur_node->_M_next)
+ {
+ ++__chain;
+ ++__it;
+ }
+ if (__chain)
+ {
+ ++__chain;
+ __lc = __lc > __chain ? __lc : __chain;
+ __hops += __chain * (__chain - 1) / 2;
+ __chain = 0;
+ }
+ }
__profcxx_hashtable_destruct2(this, __lc, _Base::size(), __hops);
}
};
+
template<typename _Key, typename _Tp, typename _Hash,
- typename _Pred, typename _Alloc>
+ typename _Pred, typename _Alloc>
inline void
swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
- unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{ __x.swap(__y); }
} // namespace __profile
OpenPOWER on IntegriCloud