diff --git a/src/include/ZMap/zmapGLibUtils.h b/src/include/ZMap/zmapGLibUtils.h index 1e426167ec9cfa4eb2908a9373c175406acaceed..941dceb6517737a542f13c5ec50e9d6652ebcbc4 100755 --- a/src/include/ZMap/zmapGLibUtils.h +++ b/src/include/ZMap/zmapGLibUtils.h @@ -26,9 +26,9 @@ * glib but not included with their distribution. * * HISTORY: - * Last edited: May 19 16:51 2006 (edgrif) + * Last edited: May 25 16:12 2006 (edgrif) * Created: Thu Oct 13 15:56:54 2005 (edgrif) - * CVS info: $Id: zmapGLibUtils.h,v 1.6 2006-05-19 15:55:58 edgrif Exp $ + * CVS info: $Id: zmapGLibUtils.h,v 1.7 2006-05-25 17:04:08 edgrif Exp $ *------------------------------------------------------------------- */ #ifndef ZMAP_GLIBUTILS_H @@ -56,6 +56,10 @@ typedef enum } ZMapGListDirection; +typedef gboolean (*ZMapGFuncCond)(gpointer data, gpointer user_data) ; + + + /*! @} end of zmapGLibutils docs. */ @@ -63,10 +67,10 @@ typedef enum char *zMap_g_remove_char(char *string, char ch) ; void zMap_g_list_foreach_reverse(GList *list, GFunc func, gpointer user_data); -void zMap_g_list_foreach_directional(GList *list, - GFunc func, - gpointer user_data, +void zMap_g_list_foreach_directional(GList *list, GFunc func, gpointer user_data, ZMapGListDirection forward); +gboolean zMap_g_list_cond_foreach(GList *list, ZMapGFuncCond func, gpointer user_data) ; + gboolean zMap_g_string_replace(GString *string, char *target, char *source) ; diff --git a/src/zmapUtils/zmapGLibUtils.c b/src/zmapUtils/zmapGLibUtils.c index a983ffd1e7af87b48657cd453caaa60fff8d24de..93e27baa8a8c88f3aa9098fae34786a0dd527344 100755 --- a/src/zmapUtils/zmapGLibUtils.c +++ b/src/zmapUtils/zmapGLibUtils.c @@ -26,9 +26,9 @@ * * Exported functions: See ZMap/zmapGLibUtils.h * HISTORY: - * Last edited: May 19 16:50 2006 (edgrif) + * Last edited: May 25 16:02 2006 (edgrif) * Created: Thu Oct 13 15:22:35 2005 (edgrif) - * CVS info: $Id: zmapGLibUtils.c,v 1.6 2006-05-19 15:55:58 edgrif Exp $ + * CVS info: $Id: zmapGLibUtils.c,v 1.7 2006-05-25 17:04:08 edgrif Exp $ *------------------------------------------------------------------- */ @@ -129,7 +129,6 @@ char *zMap_g_remove_char(char *string, char ch) - /* * Additions to GList */ @@ -184,6 +183,33 @@ void zMap_g_list_foreach_directional(GList *list, } +/*! Just like g_list_foreach() except that the ZMapGFuncCond function can return + * FALSE to stop the foreach loop from executing. + * + * Returns FALSE if ZMapGFuncCond returned FALSE, TRUE otherwise. + * + * */ +gboolean zMap_g_list_cond_foreach(GList *list, ZMapGFuncCond func, gpointer user_data) +{ + gboolean status = TRUE ; + + while (list) + { + GList *next = list->next ; + + if (!((*func)(list->data, user_data))) + { + status = FALSE ; + break ; + } + + list = next ; + } + + return status ; +} + +