generated from freudenreichan/info2Praktikum-DobleSpiel
Kommentare in stack hinzugefügt
This commit is contained in:
parent
3c7785bac9
commit
a04005486d
7
stack.c
7
stack.c
@ -9,8 +9,9 @@
|
|||||||
|
|
||||||
|
|
||||||
// Pushes data as pointer onto the stack.
|
// Pushes data as pointer onto the stack.
|
||||||
// *ist das ganze konstrukt
|
// *stack zeiger auf das ganze konstrukt
|
||||||
// *data soll gepusht werden
|
// *data soll oben drauf gepusht werden; daten die davor drin waren werden runtergeschoben
|
||||||
|
// stack wird zurückgegeben
|
||||||
StackNode *push(StackNode *stack, void *data)
|
StackNode *push(StackNode *stack, void *data)
|
||||||
{
|
{
|
||||||
if(data != NULL)
|
if(data != NULL)
|
||||||
@ -37,6 +38,7 @@ StackNode *push(StackNode *stack, void *data)
|
|||||||
|
|
||||||
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
// Deletes the top element of the stack (latest added element) and releases its memory. (Pointer to data has to be
|
||||||
// freed by caller.)
|
// freed by caller.)
|
||||||
|
// data wird entfernt-> next wird der neue stack
|
||||||
StackNode *pop(StackNode *stack)
|
StackNode *pop(StackNode *stack)
|
||||||
{
|
{
|
||||||
if(stack != NULL)
|
if(stack != NULL)
|
||||||
@ -49,6 +51,7 @@ StackNode *pop(StackNode *stack)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns the data of the top element.
|
// Returns the data of the top element.
|
||||||
|
// gibt das oberste Element aus (data)
|
||||||
void *top(StackNode *stack)
|
void *top(StackNode *stack)
|
||||||
{
|
{
|
||||||
if(stack == 0)
|
if(stack == 0)
|
||||||
|
|||||||
4
stack.h
4
stack.h
@ -9,8 +9,8 @@ The latest element is taken from the stack. */
|
|||||||
|
|
||||||
//TODO: passenden Datentyp als struct anlegen
|
//TODO: passenden Datentyp als struct anlegen
|
||||||
typedef struct Stack{
|
typedef struct Stack{
|
||||||
void *data;
|
void *data; //zeiger auf variable
|
||||||
struct Stack *next;
|
struct Stack *next; // zeiger auf ein weiteres stack (data und next)
|
||||||
} StackNode;
|
} StackNode;
|
||||||
|
|
||||||
// Pushes data as pointer onto the stack.
|
// Pushes data as pointer onto the stack.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user