mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
use map as DagType to fix a unordered bug in different environment , by the way, it improves 1/6 speed
This commit is contained in:
parent
485383c669
commit
90d2280002
@ -62,7 +62,7 @@ namespace CppJieba
|
||||
return os << nodeInfo.word << ":" << nodeInfo.freq << ":" << nodeInfo.tag << ":" << nodeInfo.logFreq ;
|
||||
}
|
||||
|
||||
typedef unordered_map<uint, const TrieNodeInfo*> DagType;
|
||||
typedef map<uint, const TrieNodeInfo*> DagType;
|
||||
|
||||
class Trie
|
||||
{
|
||||
@ -227,7 +227,7 @@ namespace CppJieba
|
||||
return !res.empty();
|
||||
}
|
||||
|
||||
bool find(Unicode::const_iterator begin, Unicode::const_iterator end, uint offset, unordered_map<uint, const TrieNodeInfo* > & res) const
|
||||
bool find(Unicode::const_iterator begin, Unicode::const_iterator end, uint offset, DagType & res) const
|
||||
{
|
||||
if(!_getInitFlag())
|
||||
{
|
||||
|
@ -22,8 +22,8 @@ TEST(TrieTest, Test1)
|
||||
EXPECT_EQ(nodeInfo, *trie.find(uni.begin(), uni.end()));
|
||||
word = "清华大学";
|
||||
vector<pair<uint, const TrieNodeInfo*> > res;
|
||||
unordered_map<uint, const TrieNodeInfo* > resMap;
|
||||
unordered_map<uint, const TrieNodeInfo* > map;
|
||||
map<uint, const TrieNodeInfo* > resMap;
|
||||
map<uint, const TrieNodeInfo* > map;
|
||||
const char * words[] = {"清", "清华", "清华大学"};
|
||||
for(uint i = 0; i < sizeof(words)/sizeof(words[0]); i++)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user