/* * list.h * * Created on: Sep 10, 2009 * Author: bkaplan */ #ifndef LIST_H_ #define LIST_H_ //List structs typedef struct list_entry list_entry_t; struct list_entry { void *key; void *value; list_entry_t *next; }; typedef struct { list_entry_t *list; int (*cmp)(const void *, const void *); /* Comparison function */ } list_head_t; //list functions list_head_t *list_init(int (*cmp)(const void *, const void *)); void* list_search(list_head_t* list, void *key); list_entry_t *list_insert(list_head_t *head, void* key, void* value); void list_delete(list_head_t *); list_entry_t *list_get_element(list_head_t *head, void *key); list_head_t *list_merge(list_head_t*,list_head_t*); //Hashtable struct typedef struct { list_head_t **buckets; int (*cmp) (const void *,const void *); int (*hash) (const void *); } hash_head_t; //hash table functions hash_head_t* hash_init(int (*hash)(const void *),int (*cmp)(const void *, const void *)); list_entry_t *hash_insert(hash_head_t *table, void *key, void *value); void *hash_search(hash_head_t *table, void *key); void hash_delete(hash_head_t *table); int hash_remove(hash_head_t *table, void *key); list_entry_t *hash_get_element(hash_head_t *table, void *key); list_head_t * hash_to_list(hash_head_t*); int list_remove(list_head_t*,void*); int length_of_list(list_head_t*); int length_of_hash(hash_head_t*); #endif /* LIST_H_ */