Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Functions | |
vl_memsize_t | vl_HashTableGrow (vl_hashtable *table) |
void | vlHashTableInit (vl_hashtable *table, vl_hash_function hashFunc) |
Initializes the specified table. Specifies the hash function to use on keys. | |
void | vlHashTableFree (vl_hashtable *table) |
Frees the specified table. | |
vl_hashtable * | vlHashTableNew (vl_hash_function func) |
Allocates on the heap, initializes, and returns a new hash table. Specifies the hash function to use on keys. | |
void | vlHashTableDelete (vl_hashtable *table) |
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, the associated chunk is reallocated to match the specified size. | |
vl_hash_iter | vlHashTableFind (vl_hashtable *table, const void *key, vl_memsize_t keySize) |
void | vlHashTableRemoveKey (vl_hashtable *table, const void *key, vl_memsize_t keyLen) |
void | vlHashTableRemoveIter (vl_hashtable *table, vl_hash_iter iter) |
void | vlHashTableClear (vl_hashtable *table) |
Clears the specified hash table so it can be used as if it was just created. | |
vl_hashtable * | vlHashTableClone (const vl_hashtable *src, vl_hashtable *dest) |
Clones the specified hashtable to another. | |
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. | |
int | vlHashTableCopy (vl_hashtable *src, vl_hashtable *dest) |
Copies the entirety of one hashtable to another. | |
void | vlHashTableReserve (vl_hashtable *table, vl_memsize_t buckets, vl_memsize_t heapSize) |
Reserves memory in the hashtable before requiring it. | |
const vl_transient * | vlHashTableSampleKey (vl_hashtable *table, vl_hash_iter iter, vl_memsize_t *outSize) |
vl_transient * | vlHashTableSampleValue (vl_hashtable *table, vl_hash_iter iter, vl_memsize_t *outSize) |
vl_hash_iter | vlHashTableFront (vl_hashtable *table) |
vl_hash_iter | vlHashTableNext (vl_hashtable *table, vl_hash_iter iter) |
vl_memsize_t vl_HashTableGrow | ( | vl_hashtable * | table | ) |
void vlHashTableClear | ( | vl_hashtable * | table | ) |
Clears the specified hash table so it can be used as if it was just created.
No data in the underlying virtual arena allocator is touched. Rather, book-keeping variables are reset to their initial state.
table | pointer |
vl_hashtable * vlHashTableClone | ( | const vl_hashtable * | table, |
vl_hashtable * | dest ) |
Clones the specified hashtable to another.
Clones the entirety of the src table to the dest table.
The 'src' table must be non-null and initialized. The 'dest' table may be null, but if it is not null it must be initialized.
If the 'dest' table pointer is null, a new list is created via vlHashTableNew.
src | pointer |
dest | pointer |
int vlHashTableCopy | ( | vl_hashtable * | src, |
vl_hashtable * | dest ) |
Copies the entirety of one hashtable to another.
Both tables must have the same hash function, otherwise this is a no-op. If any elements with matching keys exist between the two maps, they are overwritten by the contents of the element in the source table.
src | pointer |
dest | pointer |
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.
Both tables must have the same hash function, otherwise this is a no-op and will return VL_HASHTABLE_ITER_INVALID.
If an element by the key specified by the iterator already exists in the dest table, its element data is overwritten by the contents of the element in the source table.
src | pointer |
iter | element to copy |
dest | pointer |
void vlHashTableDelete | ( | vl_hashtable * | table | ) |
Deallocates and deinitializes the specified table. The table MUST be initialized via vlHashTableNew.
table | pointer |
vl_hash_iter vlHashTableFind | ( | vl_hashtable * | table, |
const void * | key, | ||
vl_memsize_t | keySize ) |
Searches the hashtable for an element with the specified key.
table | pointer |
key | |
keySize |
void vlHashTableFree | ( | vl_hashtable * | table | ) |
Frees the specified table.
The table instance should have been initialized via vlHashTableInit.
table | pointer |
vl_hash_iter vlHashTableFront | ( | vl_hashtable * | table | ) |
Returns the "first" iterator for the specified table.
table | pointer |
void vlHashTableInit | ( | vl_hashtable * | table, |
vl_hash_function | hashFunc ) |
Initializes the specified table. Specifies the hash function to use on keys.
The table instance should be freed via vlHashTableFree.
table | pointer |
hashFunc | hash function pointer |
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, the associated chunk is reallocated to match the specified size.
table | pointer |
key | pointer to key data |
keySize | size of key data, in bytes |
dataSize | size of element data, in bytes |
vl_hashtable * vlHashTableNew | ( | vl_hash_function | func | ) |
Allocates on the heap, initializes, and returns a new hash table. Specifies the hash function to use on keys.
The created hashtable instance should be deleted via vlHashTableDelete.
func |
vl_hash_iter vlHashTableNext | ( | vl_hashtable * | table, |
vl_hash_iter | iter ) |
Returns the "next" iterator relative to the specified iterator.
table | pointer |
iter |
void vlHashTableRemoveIter | ( | vl_hashtable * | table, |
vl_hash_iter | iter ) |
Removes the hash element represented by the specified iterator.
table | pointer |
iter |
void vlHashTableRemoveKey | ( | vl_hashtable * | table, |
const void * | key, | ||
vl_memsize_t | keyLen ) |
Removes the element represented by the specified key.
table | pointer |
key | pointer to key data |
keyLen | length of key data, in bytes. |
void vlHashTableReserve | ( | vl_hashtable * | table, |
vl_memsize_t | buckets, | ||
vl_memsize_t | heapSize ) |
Reserves memory in the hashtable before requiring it.
This function will reserve memory for buckets, element, and key data.
This is used to avoid resizing the underlying virtual heap and bucket allocations. Resizing is a costly operation which can noticeably harm the efficiency of the table if done frequently.
table | pointer |
buckets | total buckets to reserve (spots in the table) |
heapSize | total bytes to reserve for element and key data |
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.
table | pointer |
iter | |
size | output pointer representing size of the key, in bytes. may be null. |
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.
table | pointer |
iter | |
size | output pointer representing the size of the value, in bytes. may be null. |