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
commitae282ff1c3b9669496af3308e0f7889658f564cc (patch)
treeed49f8b1a0e3b94ab3dab80cab8d8ed751d80245
parent9ca01c6c3baf480424e6c6a573f18afc086736aa (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