forked from AuroraMiddleware/gtk
Added g_s?list_find_custom functions to allow user to specify a
Added g_s?list_find_custom functions to allow user to specify a GCompareFunc to determine whether a node matches or not. If you have a better idea for naming the functions, please, make it so! :)
This commit is contained in:
parent
8725269e0d
commit
a0d3a674d0
@ -531,6 +531,9 @@ GList* g_list_nth (GList *list,
|
|||||||
guint n);
|
guint n);
|
||||||
GList* g_list_find (GList *list,
|
GList* g_list_find (GList *list,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
GList *g_list_find_custom (GList *list,
|
||||||
|
gpointer data,
|
||||||
|
GCompareFunc func);
|
||||||
gint g_list_position (GList *list,
|
gint g_list_position (GList *list,
|
||||||
GList *link);
|
GList *link);
|
||||||
gint g_list_index (GList *list,
|
gint g_list_index (GList *list,
|
||||||
@ -574,6 +577,9 @@ GSList* g_slist_nth (GSList *list,
|
|||||||
guint n);
|
guint n);
|
||||||
GSList* g_slist_find (GSList *list,
|
GSList* g_slist_find (GSList *list,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
GSList *g_slist_find_custom (GSList *list,
|
||||||
|
gpointer data,
|
||||||
|
GCompareFunc func);
|
||||||
gint g_slist_position (GSList *list,
|
gint g_slist_position (GSList *list,
|
||||||
GSList *link);
|
GSList *link);
|
||||||
gint g_slist_index (GSList *list,
|
gint g_slist_index (GSList *list,
|
||||||
|
15
glib/glist.c
15
glib/glist.c
@ -324,6 +324,21 @@ g_list_find (GList *list,
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *
|
||||||
|
g_list_find_custom(GList *list, gpointer data, GCompareFunc func)
|
||||||
|
{
|
||||||
|
if(!func) return g_list_find(list, data);
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
if ( !((*func)(list->data, data)) ) break;
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gint
|
gint
|
||||||
g_list_position (GList *list,
|
g_list_position (GList *list,
|
||||||
GList *link)
|
GList *link)
|
||||||
|
@ -313,6 +313,20 @@ g_slist_find (GSList *list,
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
g_slist_find_custom(GSList *list, gpointer data, GCompareFunc func)
|
||||||
|
{
|
||||||
|
if(!func) return g_slist_find(list, data);
|
||||||
|
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
|
if ( !((*func)(list->data, data)) ) break;
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
g_slist_position (GSList *list,
|
g_slist_position (GSList *list,
|
||||||
GSList *link)
|
GSList *link)
|
||||||
|
Loading…
Reference in New Issue
Block a user