HashTableInsertItem
int HashTableInsertItem (HashTableType table, const void *key, const void *value);
Purpose
Adds a key-value pair to a hash table.
This function allocates storage for the key and the value and adds the pair to the table. If there is already a value associated with the key, the function replaces the old value with the new value.
If adding the pair increases the load of the table beyond the grow load of the table, LabWindows/CVI resizes the table to twice its size. Resizing can be very slow because it requires rehashing all keys stored in the table.
Parameters
Input | ||||
Name | Type | Description | ||
table | HashTableType | Hash table into which to insert the item. | ||
key | const void * |
Pointer to the first byte of the key data.
The following code demonstrates the appropriate ways to pass various types of keys: {
HashTableType table; } |
||
value | const void * |
Pointer to the first byte of the value data. The following code demonstrates the appropriate ways to pass various types of values. {
HashTableType table; }
|
Return Value
Name | Type | Description |
status | int |
Returns a value indicating if the function was successful.
A negative number means an error occurred. For a detailed error message, pass the returned value to GetGeneralErrorString. |
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 8.5 and later
Example
Refer to toolbox\hashtable.cws for an example of using the HashTableInsertItem function.