From 90d228000286a8dde4d424f5aceb5978884d9bc9 Mon Sep 17 00:00:00 2001 From: wyy Date: Tue, 11 Mar 2014 10:28:10 +0800 Subject: [PATCH] use map as DagType to fix a unordered bug in different environment , by the way, it improves 1/6 speed --- src/Trie.hpp | 4 ++-- test/unittest/TTrie.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Trie.hpp b/src/Trie.hpp index 55e118d..c88a4ef 100644 --- a/src/Trie.hpp +++ b/src/Trie.hpp @@ -62,7 +62,7 @@ namespace CppJieba return os << nodeInfo.word << ":" << nodeInfo.freq << ":" << nodeInfo.tag << ":" << nodeInfo.logFreq ; } - typedef unordered_map DagType; + typedef map 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 & res) const + bool find(Unicode::const_iterator begin, Unicode::const_iterator end, uint offset, DagType & res) const { if(!_getInitFlag()) { diff --git a/test/unittest/TTrie.cpp b/test/unittest/TTrie.cpp index a8cbf8c..4645d91 100644 --- a/test/unittest/TTrie.cpp +++ b/test/unittest/TTrie.cpp @@ -22,8 +22,8 @@ TEST(TrieTest, Test1) EXPECT_EQ(nodeInfo, *trie.find(uni.begin(), uni.end())); word = "清华大学"; vector > res; - unordered_map resMap; - unordered_map map; + map resMap; + map map; const char * words[] = {"清", "清华", "清华大学"}; for(uint i = 0; i < sizeof(words)/sizeof(words[0]); i++) {