Exemplo n.º 1
0
/**
*	Name...........:    Status  destroyAVLTree(AVLTreePtr *t);
*	Description....:	销毁平衡二叉树
*	Param..........:	t:指向平衡二叉树指针的指针
*	Return.........:    TRUE:销毁成功
                        FALSE:销毁失败
*	Precondition...:
*	Postcondition..:    如果树中有数据,那么所有数据会被销毁,*t指向一棵空树
**/
Status  destroyAVLTree(AVLTreePtr *t)
{
    if (NULL != *t)
    {
        destroyAVLTree(&(*t)->lchild);
        destroyAVLTree(&(*t)->rchild);
        free(*t);
        *t = NULL;
        return TRUE;
    }
    return FALSE;
}
Exemplo n.º 2
0
int main()
{
	Tree * testTree;
	int (*compare)(void *, void *, void*, void*);
    void (*destroy)(void *);
    compare = &comparePointer;
    destroy = &destroyPointer;
	testTree = createAVLTree(compare,destroy);
	parseDirectory("testdir/", testTree);
	findInTree(testTree, "file.c");
	removeFromTree(testTree, "testdir/", "file.c");
	destroyAVLTree(testTree);
	return(0);
}