tagParent; newNode->tagSelf = ++tag; p->nextSibling = newNode; curr = p->nextSibling; } } } /************************************************************************ 函数名: CreateOptionTree 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-7 作 用: 形参数: 返回值: TRUE:成功 FALSE:失败 修改记录: ************************************************************************/ BOOL CTree::CreateOptionTree(CString strValue) { if (root == NULL) { root = new TreeNode; root->firstChild = NULL; root->tagParent = 0; root->tagSelf = tag; curr = root; } if (strValue == "") { return TRUE; } InsertChild(strValue); return TRUE; } /************************************************************************ 函数名: GetTreeDepth 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-8 作 用: 形参数: 返回值: 修改记录:未完成 ************************************************************************/ int CTree::GetTreeDepth(TreeNode *parent) { int num = 1; if (parent->firstChild == NULL) { return num; } else { TreeNode *p = parent; } } /************************************************************************ 函数名: PreOrderTree 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-8 作 用: 形参数: 返回值: 修改记录: ************************************************************************/ void CTree::PreOrderTree(TreeNode *parent) { if (parent->firstChild != NULL) { PreOrderTree(parent->firstChild); } if (parent->nextSibling != NULL) { PreOrderTree(parent->nextSibling); } } /************************************************************************ 函数名: GetChildNums 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-8 作 用: 得到节点的孩子数 形参数: 返回值: 修改记录: ************************************************************************/ int CTree::GetChildNums(TreeNode *parent) { if (parent->firstChild == NULL) { return 0; } else { int num = 1; TreeNode *p = parent->firstChild; while(p->nextSibling != NULL) { num++; p = p->nextSibling; } return num; } } /************************************************************************ 函数名: DeleteTree 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-11 作 用: 删除以parent为根结点的树 形参数: 返回值: 修改记录: ************************************************************************/ void CTree::DeleteTree(TreeNode *parent) { if (parent == NULL) { return; } TreeNode *p = parent->firstChild, *q; while(p != NULL) { q = p->nextSibling; DeleteTree(p); p = q; } delete parent; } /************************************************************************ 函数名: SetCurrent 作 者: 谭友亮(Charles Tan) 日 期: 2013-3-11 作 用: 设置当前结点 形参数: 返回值: 修改记录: ****************************************************************** |