generated from freudenreichan/info2Praktikum-DobleSpiel
rebuilt everything to be as buggy, as 3 Versions ago
This commit is contained in:
parent
85b05133ea
commit
fdfa3c5769
18
bintree.c
18
bintree.c
@ -55,25 +55,31 @@ void *nextTreeData(TreeNode *root)
|
||||
printf("nextTreeData wurde gecallt!\n");
|
||||
if(root)
|
||||
{
|
||||
addTreeToStack(stackRoot, root);
|
||||
stackRoot = addTreeToStack(stackRoot, root);
|
||||
printf("Baum wurde geladen!\n");
|
||||
}
|
||||
void *buffer = pop(stackRoot);
|
||||
printf("\n\nstackRoot ist: %x\n\n", stackRoot);
|
||||
StackNode *stackPuffer = pop(stackRoot);
|
||||
if(!stackPuffer)
|
||||
printf("Something went horriffically wrong! There is no Data!");
|
||||
void *buffer = (stackPuffer->stackData);
|
||||
printf("neuer Eintrag wurde geholt: %x\n", buffer);
|
||||
return buffer;
|
||||
}
|
||||
// Adds all Treenode-Datas of a root into a stack ordered from left to right
|
||||
void addTreeToStack(StackNode *start, TreeNode *root)
|
||||
StackNode *addTreeToStack(StackNode *start, TreeNode *root)
|
||||
{
|
||||
if(root->left)
|
||||
{
|
||||
addTreeToStack(start, root->left);
|
||||
start = addTreeToStack(start, root->left);
|
||||
}
|
||||
push(start, root->data);
|
||||
start = push(start, root->data);
|
||||
printf("\na new Dataset has been added! new stackRoot: %x", start);
|
||||
if(root->right)
|
||||
{
|
||||
addTreeToStack(start, root->right);
|
||||
start = addTreeToStack(start, root->right);
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
// Releases all memory resources (including data copies).
|
||||
|
||||
@ -26,5 +26,5 @@ void clearTree(TreeNode *root);
|
||||
// Returns the number of entries in the tree given by root.
|
||||
unsigned int treeSize(const TreeNode *root);
|
||||
// Adds all Treenode-Datas of a root into a stack ordered from left to right
|
||||
void addTreeToStack(StackNode *start, TreeNode *root);
|
||||
StackNode *addTreeToStack(StackNode *start, TreeNode *root);
|
||||
#endif
|
||||
@ -0,0 +1,10 @@
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
Ottp;4522070
|
||||
11
stack.c
11
stack.c
@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "stack.h"
|
||||
|
||||
//TODO: grundlegende Stackfunktionen implementieren:
|
||||
@ -33,14 +34,18 @@ StackNode *push(StackNode *stack, void *data)
|
||||
// freed by caller.)
|
||||
StackNode *pop(StackNode *stack)
|
||||
{
|
||||
printf("A stack is being popped");
|
||||
if(stack) {
|
||||
StackNode* temp = stack;
|
||||
stack = stack->below;
|
||||
temp->stackData = NULL;
|
||||
free(temp);
|
||||
temp = NULL;
|
||||
//free(temp);
|
||||
//temp = NULL;
|
||||
printf("Stack returns stack at: %x\n", stack);
|
||||
return stack;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user