aboutsummaryrefslogtreecommitdiff
path: root/stack.h
blob: 68fdb78010d21ab1e8034dd310345b3f6d7c57cf (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
#ifndef STACK_H_
#define STACK_H_

#include <stddef.h>
#include "structs.h"

/* So, the implementation of the stack is array-based, for hyperspeed.
 * For bigger maps we have to increase the STACK_SIZE, but it should
 * work fine most of the time. I guess */
#define STACK_SIZE 4096

struct PositionStack_s {
    Position arr[STACK_SIZE]; /* The array with all the values */
    size_t top; /* Shows where the top of the stack is */
};
typedef struct PositionStack_s PositionStack;

PositionStack ps_new(void); /* Returns an empty position stack */
int ps_push(PositionStack *ps, Position pos); /* Returns -1 if overflow */
Position ps_pop(PositionStack *ps);
Position ps_peek(PositionStack ps);

#endif /* STACK_H_ */