mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
use reverse_iterator
This commit is contained in:
parent
c04b2dd0d4
commit
6e3bb7d057
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user