generated from freudenreichan/info2Praktikum-DobleSpiel
not working, but a potential way I want to possilby iterarte back to
This commit is contained in:
parent
53f4716354
commit
85b05133ea
26
bintree.c
26
bintree.c
@ -3,7 +3,7 @@
|
||||
#include "bintree.h"
|
||||
#include <stdio.h>
|
||||
|
||||
StackNode *stackRoot = NULL;//Generates a new, empty stack for next tree data
|
||||
StackNode *stackRoot;//Generates a new, empty stack for next tree data
|
||||
|
||||
//TODO: binären Suchbaum implementieren
|
||||
/* * `addToTree`: fügt ein neues Element in den Baum ein (rekursiv),
|
||||
@ -52,15 +52,29 @@ 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)
|
||||
{
|
||||
printf("nextTreeData wurde gecallt!\n");
|
||||
if(root)
|
||||
{
|
||||
stackRoot = push(root->data, stackRoot);
|
||||
nextTreeData(root->left);
|
||||
nextTreeData(root->right);
|
||||
addTreeToStack(stackRoot, root);
|
||||
printf("Baum wurde geladen!\n");
|
||||
}
|
||||
void *buffer = pop(stackRoot);
|
||||
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)
|
||||
{
|
||||
if(root->left)
|
||||
{
|
||||
addTreeToStack(start, root->left);
|
||||
}
|
||||
push(start, root->data);
|
||||
if(root->right)
|
||||
{
|
||||
addTreeToStack(start, root->right);
|
||||
}
|
||||
return stackRoot;
|
||||
}
|
||||
|
||||
|
||||
// Releases all memory resources (including data copies).
|
||||
void clearTree(TreeNode *root)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef BINTREE_H
|
||||
#define BINTREE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "stack.h"
|
||||
|
||||
@ -24,6 +25,6 @@ void *nextTreeData(TreeNode *root);
|
||||
void clearTree(TreeNode *root);
|
||||
// Returns the number of entries in the tree given by root.
|
||||
unsigned int treeSize(const TreeNode *root);
|
||||
//Function to aid nextTreeData
|
||||
StackNode *iterateThroughTree(TreeNode *root, StackNode *stackRoot);
|
||||
// Adds all Treenode-Datas of a root into a stack ordered from left to right
|
||||
void addTreeToStack(StackNode *start, TreeNode *root);
|
||||
#endif
|
||||
@ -52,7 +52,6 @@ static int calculateScore(double timeInSeconds, unsigned int len)
|
||||
// Load highscores from file into memory.
|
||||
void loadHighscores(const char *path)
|
||||
{
|
||||
printf("pointer ist: %x", highscoreTree);
|
||||
FILE *file = fopen(path, "r");
|
||||
|
||||
if(file != NULL)
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Παhύ;0
|
||||
Loading…
x
Reference in New Issue
Block a user