433bool strEq(
const void* a,
const void* b);
436uint32_t
hashBytes(
const uint8_t* bytes,
size_t length);
437bool bytesEq(
const uint8_t* a,
size_t aLength,
const uint8_t* b,
size_t bLength);
440uint32_t
hashInt(
const void* intKey);
441bool intsEq(
const void* keyA,
const void* keyB);
A single element of the hash map array, holding either one value or a list of values.
Definition hashMap.c:47
The internal state of a hash map iterator.
Definition hashMap.c:66
void * value
The value of the current key-value pair.
Definition hashMap.h:404
uint32_t hashBytes(const uint8_t *bytes, size_t length)
Convert an arbitrary byte sequence to a hash value.
Definition hashMap.c:489
eqFunction_t eqFunc
The key equality function to use, or NULL to use strEq()
Definition hashMap.h:428
uint32_t(* hashFunction_t)(const void *data)
A function that takes a pointer to key data and returns its hash value.
Definition hashMap.h:385
void * hashRemove(hashMap_t *map, const char *key)
Remove the value with a given string key from the hash map.
Definition hashMap.c:582
void hashDeinit(hashMap_t *map)
Deinitialize and free all memory associated with the given hash map.
Definition hashMap.c:722
int size
The total number of allocated buckets in the hash map.
Definition hashMap.h:416
void * hashGet(hashMap_t *map, const char *key)
Return the value in the hash map associated with the given string key.
Definition hashMap.c:570
void hashPut(hashMap_t *map, const char *key, void *value)
Create or update a key-value pair in the hash map with a string key.
Definition hashMap.c:558
void hashInit(hashMap_t *map, int initialSize)
Initialize a hash map for string keys.
Definition hashMap.c:692
hashFunction_t hashFunc
The key hash function to use, or NULL to use hashString()
Definition hashMap.h:425
bool bytesEq(const uint8_t *a, size_t aLength, const uint8_t *b, size_t bLength)
Compare two byte arrays.
Definition hashMap.c:512
bool hashIterRemove(hashMap_t *map, hashIterator_t *iter)
Remove the last item returned by the iterator from the hash map.
Definition hashMap.c:902
bool hashIterate(const hashMap_t *map, hashIterator_t *iterator)
Advance the given iterator to the next item, or return false if there is no next item.
Definition hashMap.c:847
void hashReport(const hashMap_t *map)
Prints out a detailed report on the hash map state.
Definition hashMap.c:967
hashIterState_t * _state
Definition hashMap.h:407
void hashInitBin(hashMap_t *map, int initialSize, hashFunction_t hashFunc, eqFunction_t eqFunc)
Initialize a hash map for non-string keys, using the given functions for hashing and comparison.
Definition hashMap.c:709
const void * key
The key of the current key-value pair.
Definition hashMap.h:402
uint32_t hashString(const void *str)
Convert a NULL-terminated string to a hash value.
Definition hashMap.c:453
bool strEq(const void *a, const void *b)
Compare two NUL-terminated strings.
Definition hashMap.c:475
void hashPutBin(hashMap_t *map, const void *key, void *value)
Create or update a key-value pair in the hash map with a non-string key.
Definition hashMap.c:594
void * hashRemoveBin(hashMap_t *map, const void *key)
Remove the value with a given non-string key from the hash map.
Definition hashMap.c:657
int count
The actual number of items stored in the hash map.
Definition hashMap.h:419
bool(* eqFunction_t)(const void *a, const void *b)
A function that takes two pointers to keys and returns true if the values they point to are equal.
Definition hashMap.h:390
void hashIterReset(hashIterator_t *iterator)
Reset the given iterator struct, freeing any memory associated with it.
Definition hashMap.c:948
hashBucket_t * values
The array of bucket values.
Definition hashMap.h:422
uint32_t hashInt(const void *intKey)
Convert a pointer address or integral value to a hash value.
Definition hashMap.c:525
void * hashGetBin(hashMap_t *map, const void *key)
Return the value in the hash map associated with the given key.
Definition hashMap.c:636
bool intsEq(const void *keyA, const void *keyB)
Compare two void pointers based on their address, or two integer types cast to a void pointer.
Definition hashMap.c:544
Struct used for iterating through a hash map efficiently.
Definition hashMap.h:400
A hash map for storing key-value pairs.
Definition hashMap.h:414