mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-09-10 01:45:54 -05:00
Add initial stack implementation
This commit is contained in:
29
source/data_structures/stack.c
Normal file
29
source/data_structures/stack.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "stack.h"
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
void stack_reset(Stack* stack)
|
||||
{
|
||||
stack->top = -1;
|
||||
}
|
||||
|
||||
bool stack_empty(Stack* stack)
|
||||
{
|
||||
return stack->top < 0;
|
||||
}
|
||||
|
||||
int stack_len(Stack* stack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void stack_push(Stack* stack, void* data)
|
||||
{
|
||||
if (stack->top < stack->max)
|
||||
stack->data_array[++stack->top] = data;
|
||||
}
|
||||
|
||||
void* stack_pop(Stack* stack)
|
||||
{
|
||||
return (stack->top < 0) ? NULL : stack->data_array[stack->top--];
|
||||
}
|
||||
Reference in New Issue
Block a user