added userdata to hastable to be able to do stuff in the iterator function callback

This commit is contained in:
herbglitch 2025-03-06 03:11:16 -07:00
parent d79f9bb2ec
commit 7316f7c779
5 changed files with 80 additions and 25 deletions

View file

@ -38,10 +38,11 @@ typedef void (* ARC_Hashtable_DestroyKeyValueFn)(void *key, void *value);
/**
* @brief a callback to be used by ARC_Hashtable_RunIteration
*
* @param[in] key a key at the current iteration
* @param[in] value a value that matches the key at the current iteration
* @param[in] key a key at the current iteration
* @param[in] value a value that matches the key at the current iteration
* @param[in] userData any data passed into the function that uses this callback to be used in this callback
*/
typedef void (* ARC_Hashtable_IteratorFn)(void *key, void *value);
typedef void (* ARC_Hashtable_IteratorFn)(void *key, void *value, void *userData);
/**
* @brief a resizable hashtable data type (will find next open slot before resizing)
@ -109,8 +110,9 @@ void *ARC_Hashtable_Get(ARC_Hashtable *hashtable, void *key);
*
* @param[in] hashtable the hashtable to iterate through
* @param[in] iteratorFn the callback which will can use the iterated key value pairs
* @patam[in] userData anything to be used within the ARC_Hashtable_IteratorFn callback, can be NULL
*/
void ARC_Hashtable_RunIteration(ARC_Hashtable *hashtable, ARC_Hashtable_IteratorFn iteratorFn);
void ARC_Hashtable_RunIteration(ARC_Hashtable *hashtable, ARC_Hashtable_IteratorFn iteratorFn, void *userData);
#ifdef __cplusplus
}