diff options
Diffstat (limited to 'src/libmdsserver/hash-table.h')
-rw-r--r-- | src/libmdsserver/hash-table.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libmdsserver/hash-table.h b/src/libmdsserver/hash-table.h index edf8d3a..2f4d03b 100644 --- a/src/libmdsserver/hash-table.h +++ b/src/libmdsserver/hash-table.h @@ -220,6 +220,17 @@ size_t hash_table_remove(hash_table_t* restrict this, size_t key); void hash_table_clear(hash_table_t* restrict this); /** + * Wrapper for `for` keyword that iterates over entry element in a hash table + * + * @param table:hash_table_t The hans table + * @param i:size_t The variable to store the buckey index in at each iteration + * @param entry:hash_entry_t* The variable to store the entry in at each iteration + */ +#define foreach_hash_table_entry(table, i, entry) \ + for (i = 0; i < (table).capacity; i++) \ + for (entry = (table).buckets[i]; entry != NULL; entry = entry->next) + +/** * Calculate the buffer size need to marshal a hash table * * @param this The hash table |