-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.h
43 lines (41 loc) · 834 Bytes
/
tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _TEEE_H_
#define _TEEE_H_
#include "../commom/func.h"
#include <math.h>
#include <algorithm>
typedef struct{
std::string word;
size_t freq;
size_t wlen;
} node;
struct treenode {
std::map <uint16_t, treenode* > childlist;
bool leaftag;
bool wordtag;
size_t index;
treenode(){
leaftag = true;
wordtag=false;
index = 0;
}
};
typedef std::map<uint16_t, treenode* > trienodemap;
namespace seg{
class Dict{
public:
//////commom::Func f; ; ;
treenode* root;
std::vector<node> nodelist;
public:
Dict();
~Dict();
bool LoadDict(const char * filepath);
bool Insert(node& nodeInfo);
bool DeleteNode(treenode* node);
node* find(std::string str);
node* find(intvector& intvec,intvector::const_iterator begin , intvector::const_iterator end );
private:
void FreeTree();
};
}
#endif