HashTableIteratorGetItem
int HashTableIteratorGetItem (HashTableType table, HashTableIterator iterator, void *key, size_t keyBufferSize, void *value, size_t valueBufferSize);
Purpose
Fetches the key and value data at the current position of the iterator.
An iterator traverses all the key-value pairs stored in the hash table. The iterator is like a pointer with two primary operations: referencing a given key-value pair in the hash table and modifying itself to point to the next key-value pair. You can create an iterator with HashTableIteratorCreate.
If you add or remove a key-value pair or resize the table, all iterators on the table are invalidated. HashTableIteratorGetItem returns an error if you use an invalidated iterator.
Parameters
Input | ||||
Name | Type | Description | ||
table | HashTableType | Hash table through which to iterate. | ||
iterator | HashTableIterator |
Iterator to read. |
||
keyBufferSize | size_t | The size, in bytes, of the provided key buffer. This function returns an error if the buffer is not large enough to hold the key. Query the required size by passing 0. | ||
valueBufferSize | size_t |
The size, in bytes, of the provided value buffer. Returns an error if the buffer is not large enough to hold the value. Query the required size by passing 0.
|
||
Output | ||||
Name | Type | Description | ||
key | void * |
A buffer or variable reference in which to store the key. |
||
value | void * |
A buffer or variable reference in which to store the value. |
Return Value
Name | Type | Description |
status | int |
Returns a value indicating if the function was successful.
A negative number means an error occurred. If you pass 0 for keyBufferSize, the function returns the number of bytes needed to store the key. If you pass 0 for valueBufferSize, the function returns the value size originally passed to HashTableCreate. 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 HashTableIteratorGetItem function.