blob: 4fd7747c9ae19af423359e277c0f46cde6df36f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#ifndef STACK_H_
#define STACK_H_
#include <stddef.h>
#include "structs.h"
#define STACK_INITIAL_CAPACITY 4096
#define STACK_SIZE_COEFFICIENT 2
struct PositionStack_s {
Position *arr; /* The array with all the values */
size_t capacity;
size_t top; /* Shows where the top of the stack is.
* Points to the empty spot after the last element */
};
typedef struct PositionStack_s PositionStack;
PositionStack ps_new(void); /* Returns an empty position stack */
void ps_push(PositionStack *ps, Position pos); /* Returns -1 if failed to realloc() */
Position ps_pop(PositionStack *ps);
Position ps_peek(PositionStack ps);
void ps_free(PositionStack ps);
#endif /* STACK_H_ */
|