archeus/include/arc/std/vector.h
2024-05-20 03:46:04 -06:00

85 lines
No EOL
1.8 KiB
C

#ifndef ARC_STD_VECTOR_H_
#define ARC_STD_VECTOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* @brief a dynamic array type
*/
typedef struct ARC_Vector ARC_Vector;
/**
* @brief data comparison function ptr
*
* @param a first data struct
* @param b second data struct
*
* @return 0 when a == b, TODO: return and ARC_Bool
*/
typedef int32_t (* ARC_Vector_CompareDataFn)(void *a, void *b);
/**
* @brief creates ARC_Vector type
*
* @param vector ARC_Vector to initialize
*/
void ARC_Vector_Create(ARC_Vector **vector);
/**
* @brief destroyes ARC_Vector type
*/
void ARC_Vector_Destroy(ARC_Vector *vector);
/**
* @brief adds value to vector
*
* @param vector ARC_Vector to add to
* @param data data that is being added
*/
void ARC_Vector_Add(ARC_Vector *vector, void *data);
/**
* @brief remove from ARC_Vector
*
* @param vector ARC_Vector to remove from
* @param data data that is being removed
* @param compare comparison callback to get check if data should be removed
*/
void ARC_Vector_Remove(ARC_Vector *vector, void *data, ARC_Vector_CompareDataFn compare);
/**
* @brief remove from ARC_Vector
*
* @param vector ARC_Vector to remove from
* @param index index of data that is being removed
*/
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t index);
/**
* @brief gets size of vector
*
* @param vector ARC_Vector to get size from
*
* @return the pointer of the vectors size, TODO: don't pass as a pointer
*/
uint32_t ARC_Vector_Size(ARC_Vector *vector);
/**
* @brief gets data from ARC_Vector at position index
*
* @param vector ARC_Vector to get data from
* @param index position of data in ARC_Vector
*
* @return pointer to data on success, NULL on fail
*/
void *ARC_Vector_Get(ARC_Vector *vector, uint32_t index);
#ifdef __cplusplus
}
#endif
#endif //ARC_STD_VECTOR_H_