changed comments on bintree.c

This commit is contained in:
Jonas Stamm 2025-12-15 13:38:05 +01:00
parent e0537dda8f
commit 99c1135bcf
2 changed files with 6 additions and 14 deletions

View File

@ -2,8 +2,7 @@
#include "stack.h" #include "stack.h"
#include "bintree.h" #include "bintree.h"
// Adds a copy of data's pointer destination to the tree using compareFct for ordering. Accepts duplicates //fügt einen kopierten Datensatz in einen binären Suchbaum ein und meldet optional Duplikate.
// if isDuplicate is NULL, otherwise ignores duplicates and sets isDuplicate to 1 (or to 0 if a new entry is added).
TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFctType compareFct, int *isDuplicate) TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFctType compareFct, int *isDuplicate)
{ {
if (root == NULL) if (root == NULL)
@ -49,6 +48,8 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
// 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. // 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.
// Use your implementation of a stack to organize the iterator. Push the root node and all left nodes first. On returning the next element, // Use your implementation of a stack to organize the iterator. Push the root node and all left nodes first. On returning the next element,
// push the top node and push all its left nodes. // push the top node and push all its left nodes.
//liefert nacheinander die Elemente in aufsteigender Reihenfolge (Inorder) und merkt sich den Zustand zwischen Aufrufen mit einem Stack.
void *nextTreeData(TreeNode *root) void *nextTreeData(TreeNode *root)
{ {
/* static iterator state using stack.c */ /* static iterator state using stack.c */
@ -104,7 +105,7 @@ void *nextTreeData(TreeNode *root)
return result; return result;
} }
// Releases all memory resources (including data copies). // Gibnt alle Knoten und ihre daten frei.
void clearTree(TreeNode *root) void clearTree(TreeNode *root)
{ {
if (root == NULL) if (root == NULL)
@ -119,7 +120,7 @@ void clearTree(TreeNode *root)
free(root); free(root);
} }
// Returns the number of entries in the tree given by root. // Zählt rekursiv die anzahl an knoten ab *root.
unsigned int treeSize(const TreeNode *root) unsigned int treeSize(const TreeNode *root)
{ {
if (root == NULL) if (root == NULL)

View File

@ -1,10 +1 @@
player_name;19803 player1;3999
player;19540
player_name;19102
player_test2;9976
player_test;9967
player;9960
player_name;9960
player_name;9953
miguel;9935
player;9920