UA Ansi C Server Professional  1.3.1.232
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
UaServerHashTable

Data Structures

struct  _UaServer_TableEntry
 A UaServer TableEntry Struct. More...
struct  _UaServer_HashTable
 A UaServer HashTable Struct. More...

Functions

OpcUa_Void UaServer_HashTable_Initialize (UaServer_HashTable *pTable, size_t 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, unsigned int index, OpcUa_Void *pData)
 Adds the given value pData to the hash table at position index.
OpcUa_StatusCode UaServer_HashTable_RemoveAt (UaServer_HashTable *pTable, unsigned int index, OpcUa_Void *pData)
 Removes the given value pData from the hash table at position index.
UaServer_TableEntryUaServer_HashTable_GetAt (UaServer_HashTable *pTable, unsigned 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.

Detailed Description

Function Documentation

OpcUa_Void UaServer_HashTable_AddAt ( UaServer_HashTable pTable,
unsigned 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.

Parameters
pTablehash table object
indexindex where the value is stored.
pDatavalue to add
See Also
UaServer_HashTable_Lookup
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.

Parameters
pTablehash table object
szKeykey which identifies the value
pDatavalue to add
See Also
UaServer_HashTable_Lookup
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.

Parameters
pTablehash table object
UaServer_TableEntry * UaServer_HashTable_GetAt ( UaServer_HashTable pTable,
unsigned int  index 
)

Returns the table entry at the given position.

Use this to iterate over the list yourself.

Parameters
pTablehash table object that should be initialized.
indexindex where the value is stored.
Returns
the table entry at the given position.
OpcUa_Void UaServer_HashTable_Initialize ( UaServer_HashTable pTable,
size_t  size,
pt2GetKeyFromValue  fctPtr 
)

Initializes a hash table.

Parameters
pTablehash table object that should be initialized.
sizeSize of hash table. Use a predefined size HASH_SIZE_XXX.
fctPtrfunction 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.

  1. It generates the hash for the key to find the element by direct index access in the table.
  2. If there is only one element at this index, this gets returned. If there are more elements (hash collision), the elements in list are searched by linear probing.
Parameters
pTablehash table object
szKeykey to search for
Returns
found element or OpcUa_Null if not found
OpcUa_StatusCode UaServer_HashTable_RemoveAt ( UaServer_HashTable pTable,
unsigned int  index,
OpcUa_Void *  pData 
)

Removes the given value pData from the hash table at position index.

Parameters
pTablehash table object
indexindex where the value is stored.
pDatadata to remove
Returns
the OPC UA Status code.
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.

Parameters
pTablehash table object
szKeykey to search for
Returns
removed element or OpcUa_Null if not found
See Also
UaServer_HashTable_Lookup