d3d: Add function to walk through all items in the hash table.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Tue, 18 Mar 2008 12:01:14 +0000 (12:01 +0000)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Tue, 18 Mar 2008 17:20:56 +0000 (17:20 +0000)
src/gallium/auxiliary/util/u_hash_table.c
src/gallium/auxiliary/util/u_hash_table.h

index ac2cb1b540d52344517bcf26ecdadf312187a2fe..f3f16a8d94f606f437f365927de4062a7addece8 100644 (file)
@@ -187,6 +187,28 @@ hash_table_remove(struct hash_table *ht,
 }
 
 
+enum pipe_error
+hash_table_foreach(struct hash_table *ht,
+                   enum pipe_error (*callback)(void *key, void *value, void *data),
+                   void *data)
+{
+   struct cso_hash_iter iter;
+   struct hash_table_item *item;
+   enum pipe_error result;
+   
+   iter = cso_hash_first_node(ht->cso);
+   while (!cso_hash_iter_is_null(iter)) {
+      item = (struct hash_table_item *)cso_hash_iter_data(iter);
+      result = callback(item->key, item->value, data);
+      if(result != PIPE_OK)
+        return result;
+      iter = cso_hash_iter_next(iter);
+   }
+
+   return PIPE_OK;
+}
+
+
 void
 hash_table_destroy(struct hash_table *ht)
 {
@@ -196,4 +218,3 @@ hash_table_destroy(struct hash_table *ht)
    
    FREE(ht);
 }
-
index d941f2c6b1622a3bdc81ac170136a5e6b0d4982f..1583bd7548c32b3be9d8680f5adc75a0da5fdc32 100644 (file)
@@ -75,6 +75,11 @@ hash_table_remove(struct hash_table *ht,
                   void *key);
 
 
+enum pipe_error
+hash_table_foreach(struct hash_table *ht,
+                   enum pipe_error (*callback)(void *key, void *value, void *data),
+                   void *data);
+
 void
 hash_table_destroy(struct hash_table *ht);