hashtable.h

00001 #ifndef HASHTABLE_H
00002 #define HASHTABLE_H
00003 
00004 //typedef unsigned int ht_key_t;
00005 
00006 #define INVALID_KEY 0u
00007 
00008 #define HTE_OK 0
00009 #define HTE_EXIST 1
00010 #define HTE_NOTEXIST 2
00011 #define HTE_INVALID_KEY 3
00012 
00013 typedef unsigned long ht_key_t;
00014 
00015 typedef struct _HashEntry{
00016         ht_key_t key;
00017         void *data;
00018         struct _HashEntry *next;
00019 }HashEntry;
00020 
00021 typedef void (*freeObj)(void* obj);
00022 typedef struct _HashTable{
00023         int count;
00024         HashEntry ** entries;
00025     freeObj      free_obj;
00026 }HashTable;
00027 
00028 MGNCS_EXPORT int hash_insert(HashTable* ht,ht_key_t key, void *data);
00029 
00030 MGNCS_EXPORT int hash_delete(HashTable* ht,ht_key_t key);
00031 
00032 MGNCS_EXPORT void * hash_get(HashTable* ht,ht_key_t key);
00033 
00034 MGNCS_EXPORT HashTable * hash_new(int count, freeObj func);
00035 
00036 MGNCS_EXPORT void hash_free(HashTable *ht);
00037 
00038 #define HT_FOR_EACH_CONTINUE 0 
00039 #define HT_FOR_EACH_DELETE   0x1
00040 #define HT_FOR_EACH_BREAK    0x02
00041 typedef int(*eachObj)(void*, void*);
00042 MGNCS_EXPORT void hash_for_each(HashTable *ht, eachObj each, void* user);
00043 
00044 #endif
00045 
Generated on Fri Jun 10 11:18:06 2011 for New Control Set V1.0.0 API Reference by  doxygen 1.6.3