init
This commit is contained in:
37
src/stack.h
Normal file
37
src/stack.h
Normal 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);
|
||||
Reference in New Issue
Block a user