From d700b023b3b9aa9e79e7821e8c4b51ff94b080c7 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 13 Jul 2017 17:28:45 +0900 Subject: [PATCH] Fixed keepSomeMatchingFunctions Previous implementation would fail if functionIndex had wrapped around --- src/EC/Manager.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/EC/Manager.hpp b/src/EC/Manager.hpp index fd7f894..d3c297e 100644 --- a/src/EC/Manager.hpp +++ b/src/EC/Manager.hpp @@ -664,12 +664,16 @@ namespace EC std::size_t keepSomeMatchingFunctions(List list) { 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() - && std::find(list.begin(), list.end(), i) == list.end()) + if(std::find(list.begin(), list.end(), iter->first) == list.end()) { - deletedCount += forMatchingFunctions.erase(i); + iter = forMatchingFunctions.erase(iter); + ++deletedCount; + } + else + { + ++iter; } } -- 2.49.0