65,210
社区成员
发帖
与我相关
我的任务
分享
enum {DOLLAR_START_POS=0, DIGIT_START_POS=1, UPPERCASE_START_POS=11,LOWERCASE_START_POS=37, BLANK_SPACE_START_POS=63};
enum tagNodeType {BRANCH, LEAVE};
typedef struct tagLeaveNode
{
char szKeyword[80];
longlong offset;
}LeaveNode;
typedef struct tagTrieTreeNode
{
enum tagNodeType NodeType;
union tagNodeData
{
struct tagTrieTreeNode *branch[64];
struct tagLeaveNode *leave;
}Node;
}TrieTreeNode;
typedef struct tagResult
{
char szKeyWord[80];
longlong offset;
struct tagResult *next;
}Result;
class CTrieTree
{
private:
TrieTreeNode *pTrieTreeRoot;
public:
int AddItem(char *szItem); //将一个关键字添加到Trie树中
LeaveNode *SearchItem(char *szItem); //查询关键字为szItem的记录
TrieTreeNode *GetBranch(char *szItem); //找到szItem所对应的分支节点
void TraverseTree(TrieTreeNode *pRoot, Result **ppResult); //从pRoot开始遍历Trie树
void ClearAll(); //释放所有结点
};