diff --git a/include/ucore/htable.h b/include/ucore/htable.h index f202662..3ae18f6 100644 --- a/include/ucore/htable.h +++ b/include/ucore/htable.h @@ -140,16 +140,41 @@ struct UHNode *uc_htable_next(struct UHTable *table, struct UHNode *node); */ void uc_htable_swap(struct UHTable *a, struct UHTable *b); +/** + * Iterate over all nodes in a bucket. + * The table must not be changed while iterating. + * + * @param table the struct UHTable* + * @param node_iter struct UHNode* for the current node being iterated + * @param hash size_t hash for the bucket to iterate + */ #define UC_HTABLE_FOREACH_BUCKET(table, node_iter, hash)\ for ((node_iter) = uc_htable_first_bucket((table), (hash));\ (node_iter) != NULL;\ (node_iter) = uc_htable_next_bucket((node_iter))) +/** + * Iterate over all nodes that has the given hash. + * The table must not be changed while iterating. + * Normally the user would check in a user specific way + * if the node_iter is equal to the node one wants to find. + * + * @param table the struct UHTable* + * @param node_iter struct UHNode* for the current node being iterated + * @param hash size_t hash for the node(s) to iterate over + */ #define UC_HTABLE_FOREACH_HASH(table, node_iter, hash)\ for ((node_iter) = uc_htable_first_hash((table), (hash));\ (node_iter) != NULL;\ (node_iter) = uc_htable_next_hash((node_iter))) + /** + * Iterate over all nodes in a table + * The table must not be changed while iterating. + * + * @param table the struct UHTable* + * @param node_iter struct UHNode* for the current node being iterated + */ #define UC_HTABLE_FOREACH(table, node_iter)\ for ((node_iter) = uc_htable_first((table));\ (node_iter) != NULL;\