Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewd

Dir     : e17/libs/ewd/src


Modified Files:
        ewd_hash.c ewd_hash.h 


Log Message:
Added a foreach function for the hash.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewd/src/ewd_hash.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- ewd_hash.c  4 Feb 2004 17:13:12 -0000       1.12
+++ ewd_hash.c  12 Feb 2004 20:54:56 -0000      1.13
@@ -176,6 +176,35 @@
 }
 
 /**
+ * ewd_hash_for_each - iterate over the entries in the hash table
+ */
+int ewd_hash_for_each_node(Ewd_Hash *hash, Ewd_For_Each for_each_func)
+{
+       int i = 0;
+
+       CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
+       CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
+
+       EWD_READ_LOCK(hash);
+
+       while (i < ewd_prime_table[hash->size]) {
+               if (hash->buckets[i]) {
+                       Ewd_Hash_Node *node;
+
+                       ewd_list_goto_first(hash->buckets[i]);
+                       while ((node = ewd_list_next(hash->buckets[i]))) {
+                               for_each_func(node);
+                       }
+               }
+               i++;
+       }
+
+       EWD_READ_UNLOCK(hash);
+
+       return TRUE;
+}
+
+/**
  * ewd_hash_dump_graph - print the distribution of the hash table for graphing
  * @hash: the hash table to print
  *
@@ -254,7 +283,7 @@
  */
 void *ewd_hash_get(Ewd_Hash *hash, void *key)
 {
-       void *data = NULL;
+       void *data;
        Ewd_Hash_Node *node;
 
        CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewd/src/ewd_hash.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewd_hash.h  8 Nov 2001 05:07:14 -0000       1.7
+++ ewd_hash.h  12 Feb 2004 20:54:56 -0000      1.8
@@ -16,7 +16,7 @@
        void *key;      /* The key for the data node */
        void *value;    /* The value associated with this node */
 
-       EWD_DECLARE_LOCKS;
+       EWD_DECLARE_LOCKS
 };
 
 typedef struct _ewd_hash Ewd_Hash;
@@ -34,7 +34,7 @@
        Ewd_Free_Cb free_key;   /* The callback function to free key */
        Ewd_Free_Cb free_value; /* The callback function to determine hash */
 
-       EWD_DECLARE_LOCKS;
+       EWD_DECLARE_LOCKS
 };
 
 /* Create and initialize a hash */
@@ -45,6 +45,7 @@
 int ewd_hash_set_free_key(Ewd_Hash *hash, Ewd_Free_Cb function);
 int ewd_hash_set_free_value(Ewd_Hash *hash, Ewd_Free_Cb function);
 void ewd_hash_destroy(Ewd_Hash *hash);
+int ewd_hash_for_each_node(Ewd_Hash *hash, Ewd_For_Each for_each_func);
 
 /* Retrieve and store data into the hash */
 void *ewd_hash_get(Ewd_Hash *hash, void *key);




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to