2022-10-27 15:16:54 -06:00
|
|
|
#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
|
|
|
|
|
*
|
2024-02-08 02:48:08 -07:00
|
|
|
* @return 0 when a == b, TODO: return and ARC_Bool
|
2022-10-27 15:16:54 -06:00
|
|
|
*/
|
2022-12-15 16:45:45 -07:00
|
|
|
typedef int32_t (* ARC_Vector_CompareDataFn)(void *a, void *b);
|
2022-10-27 15:16:54 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief creates ARC_Vector type
|
|
|
|
|
*
|
2022-12-15 16:45:45 -07:00
|
|
|
* @param vector ARC_Vector to initialize
|
2022-10-27 15:16:54 -06:00
|
|
|
*/
|
2022-12-15 16:45:45 -07:00
|
|
|
void ARC_Vector_Create(ARC_Vector **vector);
|
2022-10-27 15:16:54 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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
|
|
|
|
|
*
|
2024-02-08 02:48:08 -07:00
|
|
|
* @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
|
2022-10-27 15:16:54 -06:00
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
*/
|
2024-05-20 03:46:04 -06:00
|
|
|
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t index);
|
2022-10-27 15:16:54 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief gets size of vector
|
|
|
|
|
*
|
|
|
|
|
* @param vector ARC_Vector to get size from
|
2024-02-08 02:48:08 -07:00
|
|
|
*
|
|
|
|
|
* @return the pointer of the vectors size, TODO: don't pass as a pointer
|
2022-10-27 15:16:54 -06:00
|
|
|
*/
|
2024-05-20 03:46:04 -06:00
|
|
|
uint32_t ARC_Vector_Size(ARC_Vector *vector);
|
2022-10-27 15:16:54 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
2024-05-20 03:46:04 -06:00
|
|
|
void *ARC_Vector_Get(ARC_Vector *vector, uint32_t index);
|
2022-10-27 15:16:54 -06:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-02-08 02:48:08 -07:00
|
|
|
#endif //ARC_STD_VECTOR_H_
|