This commit is contained in:
2026-07-27 21:02:50 +12:00
commit 2b6a4ac89e
7 changed files with 2739 additions and 0 deletions

37
src/stack.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
typedef struct Stack_s{
uint8_t length;
uint8_t index;
int32_t* data;
} Stack_t;
typedef enum {
none = 0,
stack_size_can_not_be_zero,
failed_to_alloc_data,
stack_is_null,
stack_is_full,
stack_is_empty,
}StackErrors_e;
StackErrors_e initStackAlloc(Stack_t* stack_to_init, uint8_t size);
StackErrors_e initStackStatic(
Stack_t* stack_to_init,
int32_t* data,
uint8_t size
);
void deinitStackAlloc(Stack_t* stack);
void deinitStackStatic(Stack_t* stack);
StackErrors_e pushStack(Stack_t* stack, int32_t value);
StackErrors_e popStack(Stack_t* stack, int32_t* popped_value);
bool isStackEmpty(Stack_t* stack);
bool isStackFull(Stack_t* stack);
uint8_t getStackSize(Stack_t* stack);
uint8_t getStackRemainingCapacity(Stack_t* stack);