From 7f9041447dcca317bae7663daebdf68bb7cccc2b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 11 Nov 2013 16:05:32 -0500 Subject: fix iterator misuse --- utils/atools.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'utils') diff --git a/utils/atools.cc b/utils/atools.cc index 1726c4ac..559eadef 100644 --- a/utils/atools.cc +++ b/utils/atools.cc @@ -203,14 +203,16 @@ struct RefineCommand : public Command { bool keep_going = !p.empty(); while (keep_going) { keep_going = false; - for (set >::iterator pi = p.begin(); - pi != p.end(); ++pi) { + set > added; + for (set >::iterator pi = p.begin(); pi != p.end(); ++pi) { if ((this->*pred)(pi->first, pi->second)) { Align(pi->first, pi->second); - p.erase(pi); + added.insert(make_pair(pi->first, pi->second)); keep_going = true; } } + for (set >::iterator ai = added.begin(); ai != added.end(); ++ai) + p.erase(*ai); } } Array2D res_; // refined alignment -- cgit v1.2.3