]> gitweb.fperrin.net Git - iftop.git/blob - hash.h
Import iftop-1.0pre4
[iftop.git] / hash.h
1 /*
2  * addr_hash.h:
3  *
4  */
5
6 #ifndef __HASH_H_ /* include guard */
7 #define __HASH_H_
8
9 /* implementation independent declarations */
10 typedef enum {
11     HASH_STATUS_OK,
12     HASH_STATUS_MEM_EXHAUSTED,
13     HASH_STATUS_KEY_NOT_FOUND
14 } hash_status_enum;
15
16 typedef struct node_tag {
17     struct node_tag *next;       /* next node */
18     void* key;                /* key */
19     void* rec;                /* user data */
20 } hash_node_type;
21
22 typedef struct {
23     int (*compare) (void*, void*);
24     int (*hash) (void*);
25     void* (*copy_key) (void*);
26     void (*delete_key) (void*);
27     hash_node_type** table;
28     int size;
29 } hash_type;
30
31
32 hash_status_enum hash_initialise(hash_type*);
33 hash_status_enum hash_destroy(hash_type*);
34 hash_status_enum hash_insert(hash_type*, void* key, void *rec);
35 hash_status_enum hash_delete(hash_type* hash_table, void* key);
36 hash_status_enum hash_find(hash_type* hash_table, void* key, void** rec);
37 hash_status_enum hash_next_item(hash_type* hash_table, hash_node_type** ppnode);
38 void hash_delete_all(hash_type* hash_table);
39
40 #endif /* __HASH_H_ */