-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.h
97 lines (83 loc) · 1.5 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
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
/**
*
* @file Stack.h
* @author Max Base ([email protected])
* @brief Stack Implementation in C
* @version 0.1
* @date 2022-12-02
* @copyright Copyright (c) 2022
*
*/
#ifndef STACK_H
#define STACK_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct Stack
{
int top;
unsigned size;
int *items;
} Stack;
/**
* @brief Create a new stack
* @param size
* @return Stack*
*/
Stack* newStack(int size);
/**
* @brief Check if the stack is full
* @param stack
* @return true
* @return false
*/
bool isFull(Stack* stack);
/**
* @brief Check if the stack is empty
* @param stack
* @return true
* @return false
*/
bool isEmpty(Stack* stack);
/**
* @brief Push an item to stack
* @param stack
* @param item
*/
void push(Stack* stack, int item);
/**
* @brief Pop an item from stack
* @param stack
* @return int
*/
int pop(Stack* stack);
/**
* @brief Peek the top item from stack
* @param stack
* @return int
*/
int peek(Stack* stack);
/**
* @brief Print the stack
* @param stack
*/
void printStack(Stack* stack);
/**
* @brief Destroy the stack
* @param stack
*/
void destroyStack(Stack* stack);
/**
* @brief Convert the stack to string
* @param stack
* @return char*
*/
char* stackToString(Stack* stack);
/**
* @brief Resize the stack
* @param stack
* @param size
* @return Stack*
*/
Stack* resizeStack(Stack* stack, int size);
#endif