mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
hashtable.h
Go to the documentation of this file.
1 
41 #ifndef HASHTABLE_H
42 #define HASHTABLE_H
43 
44 //typedef unsigned int ht_key_t;
45 
46 #define INVALID_KEY 0u
47 
48 #define HTE_OK 0
49 #define HTE_EXIST 1
50 #define HTE_NOTEXIST 2
51 #define HTE_INVALID_KEY 3
52 
53 typedef unsigned long ht_key_t;
54 
55 typedef struct _HashEntry{
56  ht_key_t key;
57  void *data;
58  struct _HashEntry *next;
59 }HashEntry;
60 
61 typedef void (*freeObj)(void* obj);
62 typedef struct _HashTable{
63  int count;
64  HashEntry ** entries;
65  freeObj free_obj;
66 }HashTable;
67 
68 MGNCS_EXPORT int hash_insert(HashTable* ht,ht_key_t key, void *data);
69 
70 MGNCS_EXPORT int hash_delete(HashTable* ht,ht_key_t key);
71 
72 MGNCS_EXPORT void * hash_get(HashTable* ht,ht_key_t key);
73 
74 MGNCS_EXPORT HashTable * hash_new(int count, freeObj func);
75 
76 MGNCS_EXPORT void hash_free(HashTable *ht);
77 
78 #define HT_FOR_EACH_CONTINUE 0
79 #define HT_FOR_EACH_DELETE 0x1
80 #define HT_FOR_EACH_BREAK 0x02
81 typedef int(*eachObj)(void*, void*);
82 MGNCS_EXPORT void hash_for_each(HashTable *ht, eachObj each, void* user);
83 
84 #endif
85