basic vector complete but untested, added destroy callback to vector
This commit is contained in:
parent
6e814f12e6
commit
4c0c5d377d
4 changed files with 445 additions and 97 deletions
|
|
@ -26,9 +26,9 @@ typedef ARC_Bool (* ARC_Vector_CompareDataFn)(void *dataA, void *dataB);
|
|||
/**
|
||||
* @brief a callback that cleans up memory when it is removed from the vector
|
||||
*
|
||||
* @param[in] data the item to delete
|
||||
* @param[in] data the item to destroy
|
||||
*/
|
||||
typedef void (* ARC_Vector_DeleteDataFn)(void *data);
|
||||
typedef void (* ARC_Vector_DestroyDataFn)(void *data);
|
||||
|
||||
/**
|
||||
* @brief creates an ARC_Vector which is an "expandable" array
|
||||
|
|
@ -39,9 +39,9 @@ typedef void (* ARC_Vector_DeleteDataFn)(void *data);
|
|||
* @param[out] vector ARC_Vector to initialize
|
||||
* @param[in] compareDataFn a callback that checks if data stored in the array matches,
|
||||
* if set to NULL and ARC_Vector_Remove is called, the pointer addresses will be compared
|
||||
* @param[in] deleteDataFn a callback that frees an item on remove or clear, can be set to NULL to do nothing
|
||||
* @param[in] destroyDataFn a callback that frees an item on remove or clear, can be set to NULL to do nothing
|
||||
*/
|
||||
void ARC_Vector_Create(ARC_Vector **vector, ARC_Vector_CompareDataFn *compareDataFn, ARC_Vector_DeleteDataFn *deleteDataFn);
|
||||
void ARC_Vector_Create(ARC_Vector **vector, ARC_Vector_CompareDataFn *compareDataFn, ARC_Vector_DestroyDataFn *destroyDataFn);
|
||||
|
||||
/**
|
||||
* @brief destroys an ARC_Vector
|
||||
|
|
@ -86,6 +86,15 @@ void ARC_Vector_Remove(ARC_Vector *vector, void *data);
|
|||
*/
|
||||
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t index);
|
||||
|
||||
/**
|
||||
* @brief clears all items from a vector
|
||||
*
|
||||
* @note this function will call ARC_Vector_RemoveIndex, so it's notes are also applicable to this function
|
||||
*
|
||||
* @param[in] vector ARC_Vector to clear
|
||||
*/
|
||||
void ARC_Vector_Clear(ARC_Vector *vector);
|
||||
|
||||
/**
|
||||
* @brief gets the current size of an ARC_Vector as an unsigned 32 bit integer
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue