Пример #1
0
	void eraseTree(AVLNode* node) {
		if (node) {
			eraseTree(node->left);
			eraseTree(node->right);
			delete node;
		}
	}
Пример #2
0
Файл: E.c Проект: jpbat/aed2011
void eraseTree(nodePtr leaf)
{
	if (leaf == NULL)
		return;
	eraseTree(leaf->left);
	eraseTree(leaf->right);
	free(leaf);
}
Пример #3
0
PsmAddress	Sm_rbt_create(char *file, int line, PsmPartition partition)
{
	sm_SemId	lock;
	PsmAddress	rbt;
	SmRbt		*rbtPtr;

	lock = sm_SemCreate(SM_NO_KEY, SM_SEM_FIFO);
	if (lock < 0)
	{
		putErrmsg("Can't create semaphore for rbt.", NULL);
		return 0;
	}

	rbt = Psm_zalloc(file, line, partition, sizeof(SmRbt));
	if (rbt == 0)
	{
		sm_SemDelete(lock);
		putErrmsg("Can't allocate space for rbt object.", NULL);
		return 0;
	}

	rbtPtr = (SmRbt *) psp(partition, rbt);
	eraseTree(rbtPtr);
	rbtPtr->lock = lock;
	return rbt;
}
Пример #4
0
Файл: E.c Проект: jpbat/aed2011
int main()
{
	nodePtr tree=NULL;
	char word[256];
	
	while( (scanf("%s", word)) != EOF )
		tree = worker (word, tree);
	
	emOrdem(tree);
	
	eraseTree(tree);

	return 0;
}
Пример #5
0
void	Sm_rbt_destroy(char *file, int line, PsmPartition partition,
		PsmAddress rbt, SmRbtDeleteFn deleteFn, void *arg)
{
	SmRbt	*rbtPtr;

	CHKVOID(partition);
	CHKVOID(rbt);
	rbtPtr = (SmRbt *) psp(partition, rbt);
	oK(lockSmrbt(rbtPtr));
	destroyRbtNodes(file, line, partition, rbtPtr, deleteFn, arg);

	/*	Now destroy the tree itself.				*/

	sm_SemDelete(rbtPtr->lock);

	/*	just in case user mistakenly accesses later...		*/
	eraseTree(rbtPtr);
	Psm_free(file, line, partition, rbt);
}
Пример #6
0
	~AVLTree() {
		eraseTree(root_);
	}