Fixed keepSomeMatchingFunctions

Previous implementation would fail if functionIndex had wrapped around
This commit is contained in:
Stephen Seo 2017-07-13 17:28:45 +09:00
parent 1f052154ad
commit d700b023b3

View file

@ -664,12 +664,16 @@ namespace EC
std::size_t keepSomeMatchingFunctions(List list) std::size_t keepSomeMatchingFunctions(List list)
{ {
std::size_t deletedCount = 0; std::size_t deletedCount = 0;
for(std::size_t i = 0; i < functionIndex; ++i) for(auto iter = forMatchingFunctions.begin(); iter != forMatchingFunctions.end();)
{ {
if(forMatchingFunctions.find(i) != forMatchingFunctions.end() if(std::find(list.begin(), list.end(), iter->first) == list.end())
&& std::find(list.begin(), list.end(), i) == list.end())
{ {
deletedCount += forMatchingFunctions.erase(i); iter = forMatchingFunctions.erase(iter);
++deletedCount;
}
else
{
++iter;
} }
} }