use reverse_iterator

This commit is contained in:
yanyiwu 2015-05-18 23:57:13 +08:00
parent c04b2dd0d4
commit 6e3bb7d057

View File

@ -74,11 +74,11 @@ class MPSegment: public SegmentBase {
const DictUnit* p; const DictUnit* p;
double val; double val;
for(ssize_t i = segmentChars.size() - 1; i >= 0; i--) { for(vector<SegmentChar>::reverse_iterator rit = segmentChars.rbegin(); rit != segmentChars.rend(); rit++) {
segmentChars[i].pInfo = NULL; rit->pInfo = NULL;
segmentChars[i].weight = MIN_DOUBLE; rit->weight = MIN_DOUBLE;
assert(!segmentChars[i].dag.empty()); assert(!rit->dag.empty());
for(DagType::const_iterator it = segmentChars[i].dag.begin(); it != segmentChars[i].dag.end(); it++) { for(DagType::const_iterator it = rit->dag.begin(); it != rit->dag.end(); it++) {
nextPos = it->first; nextPos = it->first;
p = it->second; p = it->second;
val = 0.0; val = 0.0;
@ -91,9 +91,9 @@ class MPSegment: public SegmentBase {
} else { } else {
val += dictTrie_.getMinWeight(); val += dictTrie_.getMinWeight();
} }
if(val > segmentChars[i].weight) { if(val > rit->weight) {
segmentChars[i].pInfo = p; rit->pInfo = p;
segmentChars[i].weight = val; rit->weight = val;
} }
} }
} }