generated from freudenreichan/info2Praktikum-DobleSpiel
code_2
This commit is contained in:
parent
7135abe9a6
commit
39e0758dbd
17
bintree.c
17
bintree.c
@ -72,8 +72,6 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
||||
*isDuplicate = 1;
|
||||
}
|
||||
return root;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Iterates over the tree given by root. Follows the usage of strtok. If tree is NULL, the next entry of the last tree given is returned in ordering direction.
|
||||
@ -81,9 +79,22 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
||||
// push the top node and push all its left nodes.
|
||||
void *nextTreeData(TreeNode *root)
|
||||
{
|
||||
static StackNode *stack = NULL;
|
||||
|
||||
if (root != NULL)
|
||||
stack = push_left(root, stack);
|
||||
|
||||
if (stack == NULL)
|
||||
return NULL;
|
||||
|
||||
TreeNode *node;
|
||||
node = pop(&stack);
|
||||
|
||||
if (node->right != NULL)
|
||||
stack = push_left(node->right, stack);
|
||||
|
||||
return node->data;
|
||||
}
|
||||
|
||||
// Releases all memory resources (including data copies).
|
||||
void clearTree(TreeNode *root)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user