# IBM Visualization Data Explorer Programmer's Reference

[ Bottom of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]

### DXCreateHash

Function

Creates a hash table for storing elements.

Syntax
`
#include <dx/dx.h>
`

HashTable DXCreateHash(int elementSize, PseudoKey (*hashFunc)(),
int (*cmpFunc)())

Functional Details

An element to be stored consists of a key plus whatever data is to be associated with that key. Its size, in bytes, is specified by `elementSize`. in bytes. The parameter `hashFunc` points to the optional hash function callback. Given an element, `hashFunc` should return a uniformly distributed long integer pseudokey. If `hashFunc` is not provided, then the first long integer word of each key is assumed to be the pseudokey. `cmpFunc` is the optional compare function callback. Given a search key and an element, `cmpFunc` should return 0 if the key matches the element. If no compare function is provided, any element matching the pseudokey is assumed to match the search key.

Optionally provided by the calling application:
`
PseudoKey hashFunc (Key key);
`

Called on insertion and query to convert the arbitrary-size search key into the long integer pseudokey used to store the hash table-element.
`
int cmpFunc (Key searchKey, Element element);
`

Called on insertion and query when an element from the table matches the pseudokey. Returns 0 if the search key matches the key contained in the element found in the table.

See 14.5 , "Hashing" for additional details on `hashFunc` and `cmpFunc`. The HashTable created should be deleted with DXDestroy when it is no longer needed. See 4.2 , "Memory Management".

`PseudoKey` is defined as:

    typedef long PseudoKey;
    typedef Pointer Key;

Return Value

Returns the hash table or returns `NULL` and sets an error code.

See Also

`DXDeleteHashElement, DXDestroyHash, DXGetNextHashElement, DXInitGetNextHashElement, DXInsertHashElement, DXQueryHashElement`

14.5 , "Hashing".

[ Top of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]
[Data Explorer Documentation | QuickStart Guide | User's Guide | User's Reference | Programmer's Reference | Installation and Configuration Guide ]

[Data Explorer Home Page | Contact Data Explorer | Same document on Data Explorer Home Page ]

[IBM Home Page | Order | Search | Contact IBM | Legal ]