generated from freudenreichan/info2Praktikum-DobleSpiel
Anfänge von stack
This commit is contained in:
1 parent
c2cdde6707
commit
b9e81dbbac
3 files changed
+51
-2
No files matched your search
+10
-1
@@ -5,7 +5,10 @@
|
||||
/* * `push`: legt ein Element oben auf den Stack,
|
||||
* `pop`: entfernt das oberste Element,
|
||||
* `top`: liefert das oberste Element zurück,
|
||||
* `clearStack`: gibt den gesamten Speicher frei. */
|
||||
* `clearStack`: gibt den gesamten Speicher frei.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Pushes data as pointer onto the stack.
|
||||
StackNode *push(StackNode *stack, void *data)
|
||||
@@ -13,6 +16,8 @@ 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
|
||||
// freed by caller.)
|
||||
StackNode *pop(StackNode *stack)
|
||||
@@ -20,12 +25,16 @@ StackNode *pop(StackNode *stack)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns the data of the top element.
|
||||
void *top(StackNode *stack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Clears stack and releases all memory.
|
||||
void clearStack(StackNode *stack)
|
||||
{
|
||||
|
||||
+5
-1
@@ -5,9 +5,13 @@
|
||||
This means that with each new element all other elements are pushed deeper into the stack.
|
||||
The latest element is taken from the stack. */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//TODO: passenden Datentyp als struct anlegen
|
||||
|
||||
|
||||
//Erschaft den stack.
|
||||
StackNode *create();
|
||||
|
||||
// Pushes data as pointer onto the stack.
|
||||
StackNode *push(StackNode *stack, void *data);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "stack.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
|
||||
//Gebastelt von Maxi
|
||||
/*Unit-Tests sollen:
|
||||
Integer-Werte auf den Stack legen
|
||||
Integer-Werte auf den Stack wieder entfernen
|
||||
*/
|
||||
|
||||
|
||||
//TODO Testcases einfügen
|
||||
//void test_name(void){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
||||
printf("============================\nStack tests\n============================\n");
|
||||
RUN_TEST();
|
||||
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Reference in new issue
Block a user