mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-09-10 09:56:11 -05:00
Add initial stack implementation
This commit is contained in:
26
include/data_structures/stack.h
Normal file
26
include/data_structures/stack.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file stack.h
|
||||
*
|
||||
* @brief Stack implementation, no frills
|
||||
*/
|
||||
#ifndef STACK_H
|
||||
#define STACK_H
|
||||
|
||||
#define STACK_DEFINE(name, size) \
|
||||
static void* name##_data_array[size]; \
|
||||
static Stack name = { .data_array = name##_data_array, .top = -1, .max = size };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void** data_array;
|
||||
int top;
|
||||
int max;
|
||||
} Stack;
|
||||
|
||||
void stack_reset(Stack* stack);
|
||||
bool stack_empty(Stack* stack);
|
||||
int stack_len(Stack* stack);
|
||||
void stack_push(Stack* stack, void* data);
|
||||
void* stack_pop(Stack* stack);
|
||||
|
||||
#endif // STACK_H
|
||||
Reference in New Issue
Block a user