mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-12 20:35:57 +08:00
unordered_map (unordered_multimap<>::erase): Fix to erase all elements associated to the key.
2010-11-27 François Dumont <francois.cppdevs@free.fr> * include/debug/unordered_map (unordered_multimap<>::erase): Fix to erase all elements associated to the key. * include/debug/unordered_set (unordered_multiset<>::erase): Likewise. * testsuite/23_containers/unordered_multimap/erase/1.cc: Modify to check for multiple erase. * testsuite/23_containers/unordered_multiset/erase/1.cc: Likewise. From-SVN: r167199
This commit is contained in:
parent
d66411ba66
commit
d3b8263e20
@ -1,3 +1,12 @@
|
||||
2010-11-27 François Dumont <francois.cppdevs@free.fr>
|
||||
|
||||
* include/debug/unordered_map (unordered_multimap<>::erase): Fix to
|
||||
erase all elements associated to the key.
|
||||
* include/debug/unordered_set (unordered_multiset<>::erase): Likewise.
|
||||
* testsuite/23_containers/unordered_multimap/erase/1.cc: Modify to
|
||||
check for multiple erase.
|
||||
* testsuite/23_containers/unordered_multiset/erase/1.cc: Likewise.
|
||||
|
||||
2010-11-27 François Dumont <francois.cppdevs@free.fr>
|
||||
|
||||
* include/debug/unordered_map, unordered_set (unordered_map<>::insert,
|
||||
|
@ -538,12 +538,13 @@ namespace __debug
|
||||
erase(const key_type& __key)
|
||||
{
|
||||
size_type __ret(0);
|
||||
_Base_iterator __victim(_Base::find(__key));
|
||||
if (__victim != _Base::end())
|
||||
std::pair<_Base_iterator, _Base_iterator> __pair =
|
||||
_Base::equal_range(__key);
|
||||
for (_Base_iterator __victim = __pair.first; __victim != __pair.second;)
|
||||
{
|
||||
this->_M_invalidate_if(_Equal(__victim));
|
||||
_Base::erase(__victim);
|
||||
__ret = 1;
|
||||
_Base::erase(__victim++);
|
||||
++__ret;
|
||||
}
|
||||
return __ret;
|
||||
}
|
||||
|
@ -519,12 +519,13 @@ namespace __debug
|
||||
erase(const key_type& __key)
|
||||
{
|
||||
size_type __ret(0);
|
||||
_Base_iterator __victim(_Base::find(__key));
|
||||
if (__victim != _Base::end())
|
||||
std::pair<_Base_iterator, _Base_iterator> __pair =
|
||||
_Base::equal_range(__key);
|
||||
for (_Base_iterator __victim = __pair.first; __victim != __pair.second;)
|
||||
{
|
||||
this->_M_invalidate_if(_Equal(__victim));
|
||||
_Base::erase(__victim);
|
||||
__ret = 1;
|
||||
_Base::erase(__victim++);
|
||||
++__ret;
|
||||
}
|
||||
return __ret;
|
||||
}
|
||||
|
@ -44,15 +44,16 @@ void test01()
|
||||
mm1.insert(value_type("umbra/penumbra", 8));
|
||||
mm1.insert(value_type("belonging (no longer mix)", 9));
|
||||
mm1.insert(value_type("one line behind", 10));
|
||||
VERIFY( mm1.size() == 10 );
|
||||
mm1.insert(value_type("because to why", 11));
|
||||
VERIFY( mm1.size() == 11 );
|
||||
|
||||
VERIFY( mm1.erase("eeilo") == 1 );
|
||||
VERIFY( mm1.size() == 9 );
|
||||
VERIFY( mm1.size() == 10 );
|
||||
iterator it1 = mm1.find("eeilo");
|
||||
VERIFY( it1 == mm1.end() );
|
||||
|
||||
VERIFY( mm1.erase("tillsammans") == 1 );
|
||||
VERIFY( mm1.size() == 8 );
|
||||
VERIFY( mm1.size() == 9 );
|
||||
iterator it2 = mm1.find("tillsammans");
|
||||
VERIFY( it2 == mm1.end() );
|
||||
|
||||
@ -60,17 +61,17 @@ void test01()
|
||||
iterator it3 = mm1.find("belonging (no longer mix)");
|
||||
VERIFY( it3 != mm1.end() );
|
||||
VERIFY( mm1.erase(it3->first) == 1 );
|
||||
VERIFY( mm1.size() == 7 );
|
||||
VERIFY( mm1.size() == 8 );
|
||||
it3 = mm1.find("belonging (no longer mix)");
|
||||
VERIFY( it3 == mm1.end() );
|
||||
|
||||
VERIFY( !mm1.erase("abra") );
|
||||
VERIFY( mm1.size() == 7 );
|
||||
VERIFY( mm1.size() == 8 );
|
||||
|
||||
VERIFY( !mm1.erase("eeilo") );
|
||||
VERIFY( mm1.size() == 7 );
|
||||
VERIFY( mm1.size() == 8 );
|
||||
|
||||
VERIFY( mm1.erase("because to why") == 1 );
|
||||
VERIFY( mm1.erase("because to why") == 2 );
|
||||
VERIFY( mm1.size() == 6 );
|
||||
iterator it4 = mm1.find("because to why");
|
||||
VERIFY( it4 == mm1.end() );
|
||||
|
@ -43,15 +43,16 @@ void test01()
|
||||
ms1.insert("umbra/penumbra");
|
||||
ms1.insert("belonging (no longer mix)");
|
||||
ms1.insert("one line behind");
|
||||
VERIFY( ms1.size() == 10 );
|
||||
ms1.insert("because to why");
|
||||
VERIFY( ms1.size() == 11 );
|
||||
|
||||
VERIFY( ms1.erase("eeilo") == 1 );
|
||||
VERIFY( ms1.size() == 9 );
|
||||
VERIFY( ms1.size() == 10 );
|
||||
iterator it1 = ms1.find("eeilo");
|
||||
VERIFY( it1 == ms1.end() );
|
||||
|
||||
VERIFY( ms1.erase("tillsammans") == 1 );
|
||||
VERIFY( ms1.size() == 8 );
|
||||
VERIFY( ms1.size() == 9 );
|
||||
iterator it2 = ms1.find("tillsammans");
|
||||
VERIFY( it2 == ms1.end() );
|
||||
|
||||
@ -59,17 +60,17 @@ void test01()
|
||||
iterator it3 = ms1.find("belonging (no longer mix)");
|
||||
VERIFY( it3 != ms1.end() );
|
||||
VERIFY( ms1.erase(*it3) == 1 );
|
||||
VERIFY( ms1.size() == 7 );
|
||||
VERIFY( ms1.size() == 8 );
|
||||
it3 = ms1.find("belonging (no longer mix)");
|
||||
VERIFY( it3 == ms1.end() );
|
||||
|
||||
VERIFY( !ms1.erase("abra") );
|
||||
VERIFY( ms1.size() == 7 );
|
||||
VERIFY( ms1.size() == 8 );
|
||||
|
||||
VERIFY( !ms1.erase("eeilo") );
|
||||
VERIFY( ms1.size() == 7 );
|
||||
VERIFY( ms1.size() == 8 );
|
||||
|
||||
VERIFY( ms1.erase("because to why") == 1 );
|
||||
VERIFY( ms1.erase("because to why") == 2 );
|
||||
VERIFY( ms1.size() == 6 );
|
||||
iterator it4 = ms1.find("because to why");
|
||||
VERIFY( it4 == ms1.end() );
|
||||
|
Loading…
Reference in New Issue
Block a user