#ifndef HASH_H #define HASH_H #include #include "list.h" #ifdef __cplusplus extern "C" { #endif /** Struct which is hash table abstraction. You should'n use it directly as implementation can change in the future. Members: - table - pointer to table, - hash_func - hash function, - comp - pointer to comparison function, - el_size - size of single element, - size - how much elements we have allocated for table pointer, - elements - how much elements were inserted in table. */ struct hash_table{ yacl_list *table; /* pointer to list table */ unsigned long (*hash_func)(const void *, const unsigned long); /* hash function */ int (*comp)(const void *, const void *); /* comparison function */ unsigned int el_size; /* size of single element */ unsigned long size; /* numbers of table allocated */ unsigned long elements; /* numbers of elements in hash table */ }; /** Allocs memory and inits hash table structure. Parameters: - htable - pointer to structure which we want to init, - el_size - size of single element, - n - how large hash table we want, - hash_func - pointer to hash funtction, - compar - pointer to comparison function. Returned value: - SUCCESS - - BADSIZE - - ENOTMEM - - FAILED - */ int h_malloc(struct hash_table *htable, size_t el_size, size_t n, unsigned long (*hash_func)(const void *, const unsigned long), int (*compar)(const void *, const void *)); /** Adds element data to hash table. Dodaje element data do tablicy htable. Parameters: - htable - pointer to to hash table, - data - element which we add to table. Returned value: - SUCCESS - - FAILED - */ int h_addElem(struct hash_table *htable, const void *data); /** Searching function. Parameters: - htable - hash table we search, - data - pointer to searched element. Returned value: - NULL - if data isn't in htable, - pointer to list of synonims if one of synonim is in table.. */ yacl_list *h_findElem(const struct hash_table *htable, const void *data); /* Frees all memory allocated for htable... Parameters: - htable - pointer to structure we want deallocate. */ void h_free(struct hash_table *htable); #ifdef __cplusplus } #endif #endif /* HASH_H */