设为首页 加入收藏

TOP

VC++ 树的孩子兄弟表示法 (三)
2014-11-23 19:09:43 来源: 作者: 【 】 浏览:67
Tags:孩子 兄弟 表示


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
作 用: 设置当前结点
形参数:
返回值:
修改记录:
************************************************************************/
void CTree::SetCurrent(TreeNode *t)
{
curr = t;
}

首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇图像编程学习笔记2――bmp位图平.. 下一篇VC笔记

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: