Rev 2089 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2089 | Rev 2106 | ||
|---|---|---|---|
| Line 40... | Line 40... | ||
| 40 | 40 | ||
| 41 | /** Set of operations for hash table. */ |
41 | /** Set of operations for hash table. */ |
| 42 | typedef struct { |
42 | typedef struct { |
| 43 | /** Hash function. |
43 | /** Hash function. |
| 44 | * |
44 | * |
| 45 | * @param key Array of keys needed to compute hash index. All keys must be passed. |
45 | * @param key Array of keys needed to compute hash index. All keys must |
| - | 46 | * be passed. |
|
| 46 | * |
47 | * |
| 47 | * @return Index into hash table. |
48 | * @return Index into hash table. |
| 48 | */ |
49 | */ |
| 49 | index_t (* hash)(unative_t key[]); |
50 | index_t (* hash)(unative_t key[]); |
| 50 | 51 | ||
| 51 | /** Hash table item comparison function. |
52 | /** Hash table item comparison function. |
| 52 | * |
53 | * |
| 53 | * @param key Array of keys that will be compared with item. It is not necessary to pass all keys. |
54 | * @param key Array of keys that will be compared with item. It is not |
| - | 55 | * necessary to pass all keys. |
|
| 54 | * |
56 | * |
| 55 | * @return true if the keys match, false otherwise. |
57 | * @return true if the keys match, false otherwise. |
| 56 | */ |
58 | */ |
| 57 | bool (*compare)(unative_t key[], count_t keys, link_t *item); |
59 | bool (*compare)(unative_t key[], count_t keys, link_t *item); |
| 58 | 60 | ||
| Line 69... | Line 71... | ||
| 69 | count_t entries; |
71 | count_t entries; |
| 70 | count_t max_keys; |
72 | count_t max_keys; |
| 71 | hash_table_operations_t *op; |
73 | hash_table_operations_t *op; |
| 72 | } hash_table_t; |
74 | } hash_table_t; |
| 73 | 75 | ||
| 74 | #define hash_table_get_instance(item, type, member) list_get_instance((item), type, member) |
76 | #define hash_table_get_instance(item, type, member) \ |
| - | 77 | list_get_instance((item), type, member) |
|
| 75 | 78 | ||
| 76 | extern void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, hash_table_operations_t *op); |
79 | extern void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, |
| - | 80 | hash_table_operations_t *op); |
|
| 77 | extern void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item); |
81 | extern void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item); |
| 78 | extern link_t *hash_table_find(hash_table_t *h, unative_t key[]); |
82 | extern link_t *hash_table_find(hash_table_t *h, unative_t key[]); |
| 79 | extern void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys); |
83 | extern void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys); |
| 80 | 84 | ||
| 81 | #endif |
85 | #endif |