-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
44 lines (28 loc) · 771 Bytes
/
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
#ifndef STACK_H
#define STACK_H
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "consts.h"
#define STACK_ELEMENT Token
#define STACK_ELEMENT_SIZE (sizeof(Token))
// A structure to represent a stack
struct Stack {
int top;
bool empty;
int capacity;
STACK_ELEMENT* array;
};
struct Stack* createStack(int capacity);
bool isFull(struct Stack* stack);
int length(struct Stack* stack);
bool isEmpty(struct Stack* stack);
bool push(struct Stack* stack, STACK_ELEMENT* item);
void clear(struct Stack* stack);
void freeStack(struct Stack* stack);
void reverse(struct Stack* stack);
STACK_ELEMENT* pop(struct Stack* stack);
STACK_ELEMENT* peek(struct Stack* stack);
typedef struct Stack Stack;
#endif