Data Structures | |
struct | _UaServer_TableEntry |
A UaServer TableEntry Struct. More... | |
struct | _UaServer_HashTable |
A UaServer HashTable Struct. More... | |
Typedefs | |
typedef struct _UaServer_TableEntry | UaServer_TableEntry |
A UaServer TableEntry Struct. | |
typedef struct _UaServer_HashTable | UaServer_HashTable |
A UaServer HashTable Struct. | |
Functions | |
OpcUa_Void | UaServer_HashTable_Initialize (UaServer_HashTable *pTable, int size, pt2GetKeyFromValue fctPtr) |
Initializes a hash table. | |
OpcUa_Void | UaServer_HashTable_Cleanup (UaServer_HashTable *pTable) |
Cleans up hash table struct. | |
OpcUa_Void | UaServer_HashTable_AddElement (UaServer_HashTable *pTable, char *szKey, OpcUa_Void *pData) |
Adds the given value pData with the key pKey to the hash table. | |
OpcUa_Void | UaServer_HashTable_AddAt (UaServer_HashTable *pTable, int index, OpcUa_Void *pData) |
Adds the given value pData to the hash table at position index. | |
UaServer_TableEntry * | UaServer_HashTable_GetAt (UaServer_HashTable *pTable, int index) |
Returns the table entry at the given position. | |
OpcUa_Void * | UaServer_HashTable_RemoveElement (UaServer_HashTable *pTable, char *szKey) |
Removes the given element from hash table and returns it. | |
OpcUa_Void * | UaServer_HashTable_Lookup (UaServer_HashTable *pTable, char *szKey) |
Looks up the given element from hash table and returns it. | |
unsigned int | UaServer_HashTable_HashString (UaServer_HashTable *pTable, char *szKey) |
Simple wrapper function for hashing strings. | |
unsigned int | UaServer_HashTable_Hash (UaServer_HashTable *pTable, OpcUa_Void *pKey, OpcUa_UInt32 iKeyLen) |
Rotating hash algorithm. |
OpcUa_Void UaServer_HashTable_AddAt | ( | UaServer_HashTable * | pTable, | |
int | index, | |||
OpcUa_Void * | pData | |||
) |
Adds the given value pData to the hash table at position index.
This is used for prehashed keys or index based data. The differences to a simple array is that this function still uses the hash table's collision reduction stratagy and you can add multiple items at the same position without an error.
pTable | hash table object | |
index | index where the value is stored. | |
pData | data to add |
pTable | hash table object | |
index | index where the value is stored. | |
pData | value to add |
OpcUa_Void UaServer_HashTable_AddElement | ( | UaServer_HashTable * | pTable, | |
char * | szKey, | |||
OpcUa_Void * | pData | |||
) |
Adds the given value pData with the key pKey to the hash table.
pTable | hash table object | |
szKey | key which identifies the value | |
pData | data to add |
pTable | hash table object | |
szKey | key which identifies the value | |
pData | value to add |
OpcUa_Void UaServer_HashTable_Cleanup | ( | UaServer_HashTable * | pTable | ) |
Cleans up hash table struct.
This deletes all memory allocated by hash table, but not the data referenced by the table.
pTable | hash table object |
UaServer_TableEntry * UaServer_HashTable_GetAt | ( | UaServer_HashTable * | pTable, | |
int | index | |||
) |
Returns the table entry at the given position.
Use this to iterate over the list yourself.
pTable | hash table object that should be initialized. | |
index | index where the value is stored. |
unsigned int UaServer_HashTable_Hash | ( | UaServer_HashTable * | pTable, | |
OpcUa_Void * | pKey, | |||
OpcUa_UInt32 | iKeyLen | |||
) |
Rotating hash algorithm.
This simple and fast algorithm is ideal for hash table searches. It's not a cryptographic hash!
!!! 'int' is used consciously instead of OpcUa_Int32, !!! because the hash is an array index, !!! which is 'int' by definition (address bus width).This works for 16, 32 and 64 bit systems.
pTable | hash table object that should be initialized. | |
pKey | key which identifies the value | |
iKeyLen | the length of the key. |
!!! 'int' is used consciously instead of OpcUa_Int32, !!! because the hash is an array index, !!! which is 'int' by definition (address bus width).This works for 16, 32 and 64 bit systems.
unsigned int UaServer_HashTable_HashString | ( | UaServer_HashTable * | pTable, | |
char * | szKey | |||
) |
Simple wrapper function for hashing strings.
You can configure this to work case sensitive or case insensitive, by using the define CASE_SENSITIVE. The first variant is much faster.
OpcUa_Void UaServer_HashTable_Initialize | ( | UaServer_HashTable * | pTable, | |
int | size, | |||
pt2GetKeyFromValue | fctPtr | |||
) |
Initializes a hash table.
pTable | hash table object that should be initialized. | |
size | Size of hash table. Use a predefined size HASH_SIZE_XXX. | |
fctPtr | function pointer to function that retrieves the key string from the data value. |
OpcUa_Void * UaServer_HashTable_Lookup | ( | UaServer_HashTable * | pTable, | |
char * | szKey | |||
) |
Looks up the given element from hash table and returns it.
pTable | hash table object | |
szKey | key to search for |
OpcUa_Void * UaServer_HashTable_RemoveElement | ( | UaServer_HashTable * | pTable, | |
char * | szKey | |||
) |
Removes the given element from hash table and returns it.
It searches the element simalar to UaServer_HashTable_Lookup, removes the entry from table and returns the data value.
pTable | hash table object | |
szKey | key to search for |