41
41
typedef unsigned long hash_count_t;
42
42
typedef unsigned long hash_index_t;
43
typedef struct hash_table hash_table_t;
44
typedef struct hash_table_operations hash_table_operations_t;
46
/** Hash table structure. */
50
hash_count_t max_keys;
51
hash_table_operations_t *op;
54
44
/** Set of operations for hash table. */
55
struct hash_table_operations {
58
* @param key Array of keys needed to compute hash index. All keys
61
* @return Index into hash table.
48
* @param key Array of keys needed to compute hash index.
49
* All keys must be passed.
51
* @return Index into hash table.
63
hash_index_t (* hash)(unsigned long key[]);
54
hash_index_t (*hash)(unsigned long key[]);
65
56
/** Hash table item comparison function.
67
* @param key Array of keys that will be compared with item. It is
68
* not necessary to pass all keys.
70
* @return true if the keys match, false otherwise.
58
* @param key Array of keys that will be compared with item. It is
59
* not necessary to pass all keys.
61
* @return True if the keys match, false otherwise.
72
64
int (*compare)(unsigned long key[], hash_count_t keys, link_t *item);
74
66
/** Hash table item removal callback.
76
* @param item Item that was removed from the hash table.
68
* @param item Item that was removed from the hash table.
78
71
void (*remove_callback)(link_t *item);
72
} hash_table_operations_t;
74
/** Hash table structure. */
78
hash_count_t max_keys;
79
hash_table_operations_t *op;
81
82
#define hash_table_get_instance(item, type, member) \
82
83
list_get_instance((item), type, member)