20#define VL_HASHTABLE_ITER_INVALID 0
22#ifndef VL_HASHTABLE_RESIZE_FACTOR
23#define VL_HASHTABLE_RESIZE_FACTOR 0.8
26#ifndef VL_HASHTABLE_DEFAULT_SIZE
27#define VL_HASHTABLE_DEFAULT_SIZE 128
36#define VL_HASHTABLE_FOREACH(table, trackVar) \
37 for (vl_hash_iter trackVar = vlHashTableFront(table); trackVar != VL_HASHTABLE_ITER_INVALID; \
38 trackVar = vlHashTableNext(table, trackVar))
210 vl_memsize_t dataSize);
An arena allocator for efficient memory management.
Definition vl_arena.h:84
vl_hash(* vl_hash_function)(const void *data, vl_memsize_t dataSize)
Hash function typedef.
Definition vl_hash.h:33
VL_API vl_hash_iter vlHashTableFront(vl_hashtable *table)
Returns the "first" iterator for the specified table.
Definition vl_hashtable.c:338
VL_API int vlHashTableCopy(vl_hashtable *src, vl_hashtable *dest)
Copies the entirety of one hashtable to another.
Definition vl_hashtable.c:268
vl_memory * table
Definition vl_hashtable.h:80
VL_API vl_hash_iter vlHashTableInsert(vl_hashtable *table, const void *key, vl_memsize_t keySize, vl_memsize_t dataSize)
Claims a chunk of memory associated with the specified key. If the key already exists,...
Definition vl_hashtable.c:75
VL_API void vlHashTableRemoveIter(vl_hashtable *table, vl_hash_iter iter)
Removes the hash element represented by the specified iterator.
Definition vl_hashtable.c:181
vl_dsidx_t totalElements
Definition vl_hashtable.h:85
VL_API vl_transient * vlHashTableSampleValue(vl_hashtable *table, vl_hash_iter iter, vl_memsize_t *size)
Samples the value of the key-value pair indicated by the specified iterator.
Definition vl_hashtable.c:330
VL_API vl_hash_iter vlHashTableFind(vl_hashtable *table, const void *key, vl_memsize_t keySize)
Searches the hashtable for an element with the specified key.
Definition vl_hashtable.c:152
VL_API void vlHashTableInit(vl_hashtable *table, vl_hash_function hashFunc)
Initializes the specified table with a hash function.
Definition vl_hashtable.c:47
vl_arena_ptr vl_hash_iter
Definition vl_hashtable.h:40
VL_API void vlHashTableRemoveKey(vl_hashtable *table, const void *key, vl_memsize_t keyLen)
Removes the element represented by the specified key.
Definition vl_hashtable.c:176
VL_API vl_hash_iter vlHashTableNext(vl_hashtable *table, vl_hash_iter iter)
Returns the "next" iterator relative to the specified iterator.
Definition vl_hashtable.c:363
vl_arena data
Definition vl_hashtable.h:82
vl_hash_function hashFunc
Definition vl_hashtable.h:83
VL_API vl_hashtable * vlHashTableClone(const vl_hashtable *table, vl_hashtable *dest)
Clones the specified hashtable to another.
Definition vl_hashtable.c:235
VL_API void vlHashTableFree(vl_hashtable *table)
De-initializes and frees the internal resources of the specified table.
Definition vl_hashtable.c:56
VL_API void vlHashTableDelete(vl_hashtable *table)
De-initializes and deletes the specified table and its resources.
Definition vl_hashtable.c:69
VL_API const vl_transient * vlHashTableSampleKey(vl_hashtable *table, vl_hash_iter iter, vl_memsize_t *size)
Samples the key of the key-value pair indicated by the specified iterator.
Definition vl_hashtable.c:322
VL_API vl_hashtable * vlHashTableNew(vl_hash_function func)
Allocates on the heap, initializes, and returns a new hash table instance.
Definition vl_hashtable.c:62
VL_API void vlHashTableClear(vl_hashtable *table)
Clears the specified hash table so it can be used as if it was just created.
Definition vl_hashtable.c:228
VL_API vl_hash_iter vlHashTableCopyElement(vl_hashtable *src, vl_hash_iter iter, vl_hashtable *dest)
Copies a single element of a hashtable from one table to another.
Definition vl_hashtable.c:253
VL_API void vlHashTableReserve(vl_hashtable *table, vl_memsize_t buckets, vl_memsize_t heapSize)
Reserves memory in the hashtable before requiring it.
Definition vl_hashtable.c:289
A dynamically-sized hash table with variable-sized keys and values.
Definition vl_hashtable.h:79
VL_MEMORY_T vl_memory
Definition vl_memory.h:108
VL_MEMORY_T vl_transient
Definition vl_memory.h:118
VL_STRUCTURE_INDEX_T vl_dsidx_t
Index type for data structures.
Definition vl_numtypes.h:75