PULSAR  1.0.0
Parallel Ultra Light Systolic Array Runtime
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
icl_hash.h
Go to the documentation of this file.
1 
12 #ifndef ICL_HASH_H
13 #define ICL_HASH_H
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 typedef struct icl_entry_s {
20  void *key;
21  void *data;
22  struct icl_entry_s *next;
23 } icl_entry_t;
24 
25 typedef struct icl_hash_s {
26  int nbuckets;
27  int nentries;
29  unsigned int (*hash_function)(void*);
30  int (*hash_key_compare)(void*, void*);
31 } icl_hash_t;
32 
34  int nbuckets,
35  unsigned int (*hash_function)(void*),
36  int (*hash_key_compare)(void*, void*));
37 void* icl_hash_find(icl_hash_t*, void*);
38 icl_entry_t* icl_hash_insert(icl_hash_t *, void*, void *);
39 icl_entry_t* icl_hash_update_insert(icl_hash_t*, void*, void*, void**);
40 int icl_hash_destroy(icl_hash_t*, void (*)(void*), void (*)(void*));
41 int icl_hash_dump(FILE*, icl_hash_t*);
42 int icl_hash_delete(icl_hash_t*, void*, void (*)(void*), void (*)(void*));
43 
44 #define icl_hash_foreach(ht, tmpint, tmpent, kp, dp) \
45  for (tmpint=0;tmpint<ht->nbuckets; tmpint++) \
46  for (tmpent=ht->buckets[tmpint]; \
47  tmpent!=NULL&&((kp=tmpent->key)!=NULL)&&((dp=tmpent->data)!=NULL); \
48  tmpent=tmpent->next)
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* ICL_HASH_H */
int icl_hash_destroy(icl_hash_t *ht, void(*free_key)(void *), void(*free_data)(void *))
Free hash table structures. Key and data are freed using functions.
Definition: icl_hash.c:279
int icl_hash_dump(FILE *stream, icl_hash_t *ht)
Dump the hash table&#39;s contents to the given file pointer.
Definition: icl_hash.c:319
icl_entry_t ** buckets
Definition: icl_hash.h:28
struct icl_entry_s icl_entry_t
struct icl_entry_s * next
Definition: icl_hash.h:22
icl_entry_t * icl_hash_insert(icl_hash_t *ht, void *key, void *data)
Insert an item into the hash table.
Definition: icl_hash.c:134
int nbuckets
Definition: icl_hash.h:26
int nentries
Definition: icl_hash.h:27
int(* hash_key_compare)(void *, void *)
Definition: icl_hash.h:30
void * data
Definition: icl_hash.h:21
icl_entry_t * icl_hash_update_insert(icl_hash_t *ht, void *key, void *data, void **olddata)
Replace entry in hash table with the given entry.
Definition: icl_hash.c:173
void * icl_hash_find(icl_hash_t *ht, void *key)
Search for an entry in a hash table.
Definition: icl_hash.c:108
unsigned int(* hash_function)(void *)
Definition: icl_hash.h:29
icl_hash_t * icl_hash_create(int nbuckets, unsigned int(*hash_function)(void *), int(*hash_key_compare)(void *, void *))
Create a new hash table.
Definition: icl_hash.c:70
Definition: icl_hash.h:19
void * key
Definition: icl_hash.h:20
int icl_hash_delete(icl_hash_t *ht, void *key, void(*free_key)(void *), void(*free_data)(void *))
Free one hash table entry located by key. Key and data are freed using functions. ...
Definition: icl_hash.c:232
struct icl_hash_s icl_hash_t