-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstack.h
More file actions
98 lines (89 loc) · 2 KB
/
stack.h
File metadata and controls
98 lines (89 loc) · 2 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Course IFJ @ FIT VUT Brno, 2015
* IFJ15 Interpreter Project
*
* Authors:
* Lukas Osadsky - xosads00
* Pavol Plaskon - xplask00
* Pavel Pospisil - xpospi88
* Matej Postolka - xposto02
*
* Unless otherwise stated, all code is licensed under a
* GNU General Public License v2.0
*
*/
/**
* @file stack.h
* @brief Stack library
*
* This library allows the use of the stack ADT with automatic
* extension.
*
*/
#ifndef STACK_H
#define STACK_H
typedef struct Stack
{
void **data;
int capacity;
int used;
} TStack;
/**
* @brief Init stack
*
* Initializes an empty stack on heap with default size.
*
* @return Pointer to initialized stack
*/
TStack* stack_init();
/**
* @brief Makes stack empty.
* Clear do not free memory allocated by items
* on stack before clearing
*
* @param *stack Pointer to the stack structure
*/
void stack_clear(TStack* stack);
/**
* @brief deallocate memory
*
* @param *stack Pointer to the stack structure
*/
void stack_free(TStack* stack);
/**
* @brief Removes one item from top of the stack
*
* No effects on empty stack
*
* @param *stack Pointer to the stack structure
* @warning POP do not return item from top of stack!
*/
void stack_pop(TStack* stack);
/**
* @brief Insert item on top of the stack
*
* @param *item Pointer to item
* @param *stack Pointer to the stack structure
*/
int stack_push(TStack* stack, void* item);
/**
* @brief Returns item from top of the stack, DO NOT REMOVE IT
*
* @param *stack Pointer to the stack structure
* @warning TOP do not delete item from top of stack!
*/
void* stack_top(TStack* stack);
/**
* @brief Check if is stack empty
*
* @param *stack Pointer to the stack structure
*/
int stack_empty(TStack* stack);
/**
* @brief Copy (duplicate) a stack
*
* @param *stack Pointer to the stack which you want to duplicate
* @return Pointer to the duplicate of the stack
*/
TStack *stack_copy(TStack *stack);
#endif //STACK_H