Changes in common/include/adt/hash_table.h [ad9178bf:45226285] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/include/adt/hash_table.h
rad9178bf r45226285 60 60 61 61 /** Returns true if the key is equal to the item's lookup key. */ 62 bool (*key_equal)(const void *key, const ht_link_t *item);62 bool (*key_equal)(const void *key, size_t hash, const ht_link_t *item); 63 63 64 64 /** Hash table item removal callback. … … 85 85 member_to_inst((item), type, member) 86 86 87 /** Iterate over all entries associated with a given key. 88 * For iterating over all entries regardless of key, use hash_table_apply(). 89 * 90 * Example: 91 * struct ht_entry { 92 * ht_link_t my_link_member; 93 * void *data; 94 * int my_key; 95 * } 96 * 97 * hash_table_t *table = ...; 98 * int key = ...; 99 * 100 * hash_table_foreach(table, &key, my_link_member, struct ht_entry, item) { 101 * _print_entry_data(item->data); 102 * } 103 */ 104 #define hash_table_foreach(ht, key, member, itype, iterator) \ 105 for (itype *iterator = NULL; \ 106 iterator == NULL; iterator = (itype *) INTPTR_MAX) \ 107 for (ht_link_t *__link = hash_table_find((ht), (key)); \ 108 __link != NULL && ((iterator = member_to_inst(__link, itype, member))); \ 109 __link = hash_table_find_next((ht), __link)) 110 87 111 extern bool hash_table_create(hash_table_t *, size_t, size_t, 88 112 const hash_table_ops_t *); … … 96 120 extern bool hash_table_insert_unique(hash_table_t *, ht_link_t *); 97 121 extern ht_link_t *hash_table_find(const hash_table_t *, const void *); 98 extern ht_link_t *hash_table_find_next(const hash_table_t *, ht_link_t *, 99 ht_link_t *); 122 extern ht_link_t *hash_table_find_next(const hash_table_t *, ht_link_t *); 100 123 extern size_t hash_table_remove(hash_table_t *, const void *); 101 124 extern void hash_table_remove_item(hash_table_t *, ht_link_t *);
Note:
See TracChangeset
for help on using the changeset viewer.