replace hash_map with map ,because hash_map use 10 times memory than map

This commit is contained in:
gwdwyy 2013-07-04 23:33:16 +08:00
parent ba0cdb3e92
commit 077b40de54
2 changed files with 8 additions and 6 deletions

View File

@ -177,10 +177,11 @@ using namespace CppJieba;
int main()
{
Trie trie;
trie.init("test/dict.txt");
cout<<trie.begin()->count<<endl;
trie.init("dict.utf8");
//trie.init("test/dict.txt");
//cout<<trie.begin()->count<<endl;
return 0;
//return 0;
//trie.init("dict.txt");
//trie.display();
//const char * utf = "B";

7
Trie.h
View File

@ -2,7 +2,8 @@
#define TRIE_H
#include <iostream>
#include <fstream>
#include <ext/hash_map>
//#include <ext/hash_map>
#include <map>
#include <cstring>
#include "cppcommon/str_functs.h"
#include "cppcommon/vec_functs.h"
@ -14,9 +15,9 @@ namespace CppJieba
{
using namespace CPPCOMMON;
using namespace std;
using __gnu_cxx::hash_map;
//using __gnu_cxx::hash_map;
typedef uint16_t ChUnicode;
typedef hash_map<ChUnicode, struct TrieNode*> TrieNodeHashMap;
typedef map<ChUnicode, struct TrieNode*> TrieNodeHashMap;
struct TrieNode
{