use trie for map lookup
This commit is contained in:
22
dat.h
22
dat.h
@@ -45,7 +45,6 @@ typedef struct Emit Emit;
|
||||
struct Emit
|
||||
{
|
||||
int eat;
|
||||
int flush;
|
||||
Str s;
|
||||
Str next;
|
||||
Str dict;
|
||||
@@ -62,6 +61,25 @@ struct Hnode
|
||||
int vlen;
|
||||
};
|
||||
|
||||
typedef struct Tnode Tnode;
|
||||
struct Tnode
|
||||
{
|
||||
int child;
|
||||
int sibling;
|
||||
char c;
|
||||
char *val;
|
||||
int vlen;
|
||||
};
|
||||
|
||||
typedef struct Trie Trie;
|
||||
struct Trie
|
||||
{
|
||||
int root;
|
||||
Tnode *nodes;
|
||||
int n;
|
||||
int cap;
|
||||
};
|
||||
|
||||
typedef struct Hmap Hmap;
|
||||
struct Hmap
|
||||
{
|
||||
@@ -79,7 +97,7 @@ struct Lang
|
||||
int lang;
|
||||
char *mapname;
|
||||
char *dictname;
|
||||
Hmap *map;
|
||||
Trie *map;
|
||||
Hmap *dict;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user