Changeset 9f3864a in mainline
- Timestamp:
- 2011-01-17T15:38:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1938c6
- Parents:
- 08abd81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/hash_table.h
r08abd81 r9f3864a 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; 43 44 /** Set of operations for hash table. */ 45 typedef struct { 46 /** Hash function. 47 * 48 * @param key Array of keys needed to compute hash index. 49 * All keys must be passed. 50 * 51 * @return Index into hash table. 52 * 53 */ 54 hash_index_t (*hash)(unsigned long key[]); 55 56 /** Hash table item comparison function. 57 * 58 * @param key Array of keys that will be compared with item. It is 59 * not necessary to pass all keys. 60 * 61 * @return True if the keys match, false otherwise. 62 * 63 */ 64 int (*compare)(unsigned long key[], hash_count_t keys, link_t *item); 65 66 /** Hash table item removal callback. 67 * 68 * @param item Item that was removed from the hash table. 69 * 70 */ 71 void (*remove_callback)(link_t *item); 72 } hash_table_operations_t; 45 73 46 74 /** Hash table structure. */ 47 struct hash_table{75 typedef struct { 48 76 link_t *entry; 49 77 hash_count_t entries; 50 78 hash_count_t max_keys; 51 79 hash_table_operations_t *op; 52 }; 53 54 /** Set of operations for hash table. */ 55 struct hash_table_operations { 56 /** Hash function. 57 * 58 * @param key Array of keys needed to compute hash index. All keys 59 * must be passed. 60 * 61 * @return Index into hash table. 62 */ 63 hash_index_t (* hash)(unsigned long key[]); 64 65 /** Hash table item comparison function. 66 * 67 * @param key Array of keys that will be compared with item. It is 68 * not necessary to pass all keys. 69 * 70 * @return true if the keys match, false otherwise. 71 */ 72 int (*compare)(unsigned long key[], hash_count_t keys, link_t *item); 73 74 /** Hash table item removal callback. 75 * 76 * @param item Item that was removed from the hash table. 77 */ 78 void (*remove_callback)(link_t *item); 79 }; 80 } hash_table_t; 80 81 81 82 #define hash_table_get_instance(item, type, member) \
Note:
See TracChangeset
for help on using the changeset viewer.