82 lines
1.7 KiB
C
82 lines
1.7 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
|
||
|
|
*/
|
||
|
|
typedef int8_t (* ARC_Vector_CompareDataFn)(void *a, void *b);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief creates ARC_Vector type
|
||
|
|
*
|
||
|
|
* @param config ARC_Vector to initialize
|
||
|
|
*/
|
||
|
|
void ARC_Vector_Create(ARC_Vector **vector, uint32_t dataSize);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @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
|
||
|
|
*/
|
||
|
|
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
|
||
|
|
*/
|
||
|
|
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_
|