mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
replace hash_map with map ,because hash_map use 10 times memory than map
This commit is contained in:
parent
ba0cdb3e92
commit
077b40de54
7
Trie.cpp
7
Trie.cpp
@ -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
7
Trie.h
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user