diff options
author | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-16 09:17:46 +0000 |
---|---|---|
committer | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-16 09:17:46 +0000 |
commit | 0b93ab3317ac2a8d8f144eac85449768409a41e8 (patch) | |
tree | 5010e67c0524397d49cb90390152bb6ff6e31556 | |
parent | 708e59d0e908b24bac36ec36956ad013268253b0 (diff) |
fixed vector iter invalid. from push_back
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@561 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-x | decoder/cfg.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/decoder/cfg.cc b/decoder/cfg.cc index 0fbb6a03..b0d4eab6 100755 --- a/decoder/cfg.cc +++ b/decoder/cfg.cc @@ -366,15 +366,16 @@ RHS null_for<RHS>::null(1,std::numeric_limits<int>::min()); void CFG::BinarizeSplit(CFGBinarize const& b) { add_virtual_rules<RHS> v(*this,b.bin_name_nts); CFG_FOR_RULES(i,v.split_rhs(rules[i].rhs,false,false)); + Rules &newr=v.new_rules; #undef CFG_FOR_VIRT #define CFG_FOR_VIRT(r,expr) \ - for (Rules::iterator ri=v.new_rules.begin(),e=v.new_rules.end();ri!=e;++ri) { \ - Rule &r=*ri;expr; } + for (int i=0,e=newr.size();i<e;++i) { \ + Rule &r=newr[i];expr; } // NOTE: must use indices since we'll be adding rules as we iterate. int n_changed_total=0; #define CFG_SPLIT_PASS(N,free,just1) \ - for (int i=0;i<b.N;++i) { \ + for (int pass=0;pass<b.N;++pass) { \ int n_changed=0; \ CFG_FOR_VIRT(r,n_changed+=v.split_rhs(r.rhs,free,just1)); \ if (!n_changed) { \ |