mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add shrink for vector in DictTrie.hpp
This commit is contained in:
parent
0ca598b747
commit
bb6c3f9e78
@ -80,6 +80,7 @@ namespace CppJieba
|
||||
{
|
||||
assert(!_getInitFlag());
|
||||
_loadDict(filePath, _nodeInfos);
|
||||
_shrink(_nodeInfos);
|
||||
_freqSum = _calculateFreqSum(_nodeInfos);
|
||||
assert(_freqSum);
|
||||
_minLogFreq = _calculateLogFreqAndGetMinValue(_nodeInfos, _freqSum);
|
||||
@ -114,6 +115,7 @@ namespace CppJieba
|
||||
words.push_back(dictUnits[i].word);
|
||||
valuePointers.push_back(&dictUnits[i]);
|
||||
}
|
||||
|
||||
TrieType * trie = new TrieType(words, valuePointers);
|
||||
return trie;
|
||||
}
|
||||
@ -172,6 +174,11 @@ namespace CppJieba
|
||||
return minLogFreq;
|
||||
}
|
||||
|
||||
void _shrink(vector<DictUnit>& units) const
|
||||
{
|
||||
vector<DictUnit>(units.begin(), units.end()).swap(units);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user