Table of Contents


qt_dictionary_create - allocate a concurrent dictionary


#include <qthread/dictionary.h>

qt_dictionary *
qt_dictionary_create (qt_dict_key_equals_f eq,
qt_dict_hash_f hash,
qt_dict_tag_cleanup_f cleanup);


This function creates a dictionary data structure. The dictionary uses the eq function to compare keys, the hash function to convert a key into an integer, and the cleanup function to deallocate tags when the dictionary is destroyed.

The prototype of the key comparison function is:

int eq(void *key1, void *key2);

The eq function should return one if the keys are equal and zero otherwise. The prototype of the key conversion function is:

int hash(void *key);

The hash function may return any value. The following property MUST be maintained:

if (eq(A, B) == 1) then hash(A) == hash(B)

The prototype of the cleanup function is:

void cleanup(void *key);

The cleanup function is intended to provide a hook to deallocate keys as necessary. The function pointer may be NULL.

Return Values

Returns an initialized qt_dictionary object.

See Also

qt_dictionary_delete(3) , qt_dictionary_destroy(3) , qt_dictionary_end(3) , qt_dictionary_get(3) , qt_dictionary_iterator_copy(3) , qt_dictionary_iterator_create(3) , qt_dictionary_iterator_destroy(3) , qt_dictionary_iterator_equals(3) , qt_dictionary_iterator_get(3) , qt_dictionary_iterator_next(3) , qt_dictionary_put(3) , qt_dictionary_put_if_absent(3)

Table of Contents