summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-11-11 16:05:32 -0500
committerChris Dyer <cdyer@Chriss-MacBook-Air.local>2013-11-11 16:05:32 -0500
commit7f9041447dcca317bae7663daebdf68bb7cccc2b (patch)
tree425350f221ed4594c97dbf72c2a0639d59dd089d
parent5b3f31d49b22b9503a4524b74722e1eb2c65f87d (diff)
fix iterator misuse
-rw-r--r--utils/atools.cc8
1 files changed, 5 insertions, 3 deletions
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<pair<int, int> >::iterator pi = p.begin();
- pi != p.end(); ++pi) {
+ set<pair<int, int> > added;
+ for (set<pair<int, int> >::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<pair<int, int> >::iterator ai = added.begin(); ai != added.end(); ++ai)
+ p.erase(*ai);
}
}
Array2D<bool> res_; // refined alignment