generated from freudenreichan/info2Praktikum-DobleSpiel
addToTree ueberarbeitet
This commit is contained in:
parent
51fb18ad5a
commit
d7dc3b4820
10
bintree.c
10
bintree.c
@ -33,18 +33,18 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
|||||||
|
|
||||||
if(isDuplicate!= NULL)
|
if(isDuplicate!= NULL)
|
||||||
{
|
{
|
||||||
*isDuplicate = 1;
|
*isDuplicate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
int cmp = compareFct(root->data, &data);
|
int cmp = compareFct(root->data, data);
|
||||||
if(cmp > 0)
|
if(cmp > 0)
|
||||||
{
|
{
|
||||||
root->left = addToTree(root->left, &data, dataSize, compareFct, &isDuplicate);
|
root->left = addToTree(root->left, data, dataSize, compareFct, isDuplicate);
|
||||||
}
|
}
|
||||||
else if(cmp < 0){
|
else if(cmp < 0){
|
||||||
root->right = addToTree(root->right, &data, dataSize, compareFct, &isDuplicate);
|
root->right = addToTree(root->right, data, dataSize, compareFct, isDuplicate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -56,6 +56,7 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
|
|||||||
root->right = addToTree(root->right, data, dataSize, compareFct, NULL);
|
root->right = addToTree(root->right, data, dataSize, compareFct, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return root;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ void *nextTreeData(TreeNode *root)
|
|||||||
void clearTree(TreeNode *root)
|
void clearTree(TreeNode *root)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of entries in the tree given by root.
|
// Returns the number of entries in the tree given by root.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user