generated from freudenreichan/info2Praktikum-DobleSpiel
Top Funktion des Stacks implementiert
This commit is contained in:
parent
fc5f249554
commit
09db456716
@ -66,15 +66,21 @@ 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)
|
||||
{
|
||||
if(root == NULL)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
stackNode.top(root);
|
||||
}
|
||||
|
||||
// Releases all memory resources (including data copies).
|
||||
void clearTree(TreeNode *root)
|
||||
{
|
||||
if (root == NULL)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
// Erst linken Knoten löschen
|
||||
clearTree(root->left);
|
||||
|
||||
|
||||
12
stack.c
12
stack.c
@ -10,7 +10,17 @@
|
||||
// Pushes data as pointer onto the stack.
|
||||
StackNode *push(StackNode *stack, void *data)
|
||||
{
|
||||
|
||||
if(stack && data){
|
||||
StackNode *t = (StackNode *)malloc(sizeof(StackNode));
|
||||
if(!t)
|
||||
{
|
||||
return NULL; //Speicherfehler
|
||||
}
|
||||
t->prev = stack;
|
||||
t->data = data;
|
||||
return t;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user