Added hash_iter() function, for iterating all matching entries in a hashtable.
--- a/mojoshader_common.c Mon Dec 06 02:47:31 2010 -0500
+++ b/mojoshader_common.c Sun Dec 12 02:42:45 2010 -0500
@@ -59,6 +59,33 @@
return 0;
} // hash_find
+int hash_iter(const HashTable *table, const void *key,
+ const void **_value, void **iter)
+{
+ HashItem *i = *iter;
+ if (i == NULL)
+ i = table->table[calc_hash(table, key)];
+ else
+ i = i->next;
+
+ while (i != NULL)
+ {
+ if (table->keymatch(key, i->key, table->data))
+ {
+ *_value = i->value;
+ *iter = i;
+ return 1;
+ } // if
+ i = i->next;
+ } // while
+
+ // no more matches.
+ *_value = NULL;
+ *iter = NULL;
+ return 0;
+} // hash_iter
+
+
int hash_insert(HashTable *table, const void *key, const void *value)
{
HashItem *item = NULL;
--- a/mojoshader_internal.h Mon Dec 06 02:47:31 2010 -0500
+++ b/mojoshader_internal.h Sun Dec 12 02:42:45 2010 -0500
@@ -177,6 +177,7 @@
int hash_insert(HashTable *table, const void *key, const void *value);
int hash_remove(HashTable *table, const void *key);
int hash_find(const HashTable *table, const void *key, const void **_value);
+int hash_iter(const HashTable *table, const void *key, const void **_value, void **iter);
uint32 hash_hash_string(const void *sym, void *unused);
int hash_keymatch_string(const void *a, const void *b, void *unused);