-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
59 lines (37 loc) · 1.07 KB
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @file stack.h
* @author Jakub Vlk ([email protected])
* @brief Generic stack implemented using void pointer
* Implementation IFJ22 compiler
*/
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "common.h"
#ifndef STACK_STACK_H
#define STACK_STACK_H
#define STACK_DEBUG 0
struct stackMem;
struct stackMem {
void *data;
struct stackMem *next;
};
typedef struct stackMem stackMem_t;
//stack
struct stack {
int c;
stackMem_t *top;
};
typedef struct stack genericStack;
genericStack *gStackInit();
int gStackPush(genericStack *s, void *nm);
void *gStackPop(genericStack *s);
bool gStackIsEmpty(genericStack *st);
stackMem_t *gStackBottom(genericStack *s, stackMem_t **pLast);
void *gStackPopBack(genericStack *s);
void gStackPrint(genericStack *s, void (*printMem)(void *));
void *gStackGetNth(genericStack *s, unsigned int numberForTop);
void*gStackTop(genericStack *s);
void gStackPushBefore(genericStack *s, unsigned elementNum, void *data);
void *getFromTop(genericStack *s, unsigned int numberForTop);
#endif//STACK_STACK_H