PULSAR  2.0.0
Parallel Ultra-Light Systolic Array Runtime
 All Data Structures Files Functions Typedefs Enumerations Macros Groups
icl_hash.h
Go to the documentation of this file.
1 
11 #ifndef ICL_HASH_H
12 #define ICL_HASH_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef struct icl_entry_s {
19  void *key;
20  void *data;
21  struct icl_entry_s *next;
22 } icl_entry_t;
23 
24 typedef struct icl_hash_s {
25  int nbuckets;
26  int nentries;
27  icl_entry_t **buckets;
28  unsigned int (*hash_function)(void*);
29  int (*hash_key_compare)(void*, void*);
30 } icl_hash_t;
31 
33  int nbuckets,
34  unsigned int (*hash_function)(void*),
35  int (*hash_key_compare)(void*, void*));
36 void* icl_hash_find(icl_hash_t*, void*);
37 icl_entry_t* icl_hash_insert(icl_hash_t *, void*, void *);
38 icl_entry_t* icl_hash_update_insert(icl_hash_t*, void*, void*, void**);
39 int icl_hash_destroy(icl_hash_t*, void (*)(void*), void (*)(void*));
40 int icl_hash_dump(FILE*, icl_hash_t*);
41 int icl_hash_delete(icl_hash_t*, void*, void (*)(void*), void (*)(void*));
42 
43 #define icl_hash_foreach(ht, tmpint, tmpent, kp, dp) \
44  for (tmpint=0;tmpint<ht->nbuckets; tmpint++) \
45  for (tmpent=ht->buckets[tmpint]; \
46  tmpent!=NULL&&((kp=tmpent->key)!=NULL)&&((dp=tmpent->data)!=NULL); \
47  tmpent=tmpent->next)
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 
53 #endif /* ICL_HASH_H */