mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 03:10:09 +00:00
Someone has to make SOME backwards incompatible changes sometime. I
Someone has to make SOME backwards incompatible changes sometime. I switched around the prev & next pointers in GList. not. (Would this change make any functional difference? Discuss in a five page paper. :-) Actually, added g_list_position() - inverse of g_list_nth()
This commit is contained in:
parent
5647eeecf3
commit
9556bba1ba
@ -1,3 +1,9 @@
|
||||
1998-04-27 Elliot Lee <sopwith@cuc.ml.org>
|
||||
|
||||
* glist.c (g_list_position): New function to find the position of
|
||||
a link in a list - should be the inverse of g_list_nth(), but
|
||||
haven't tested it so poof.
|
||||
|
||||
Tue Apr 7 19:36:48 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gutils.c (g_direct_compare): Removed, because that's what
|
||||
|
@ -445,6 +445,8 @@ GList* g_list_remove_link (GList *list,
|
||||
GList* g_list_reverse (GList *list);
|
||||
GList* g_list_nth (GList *list,
|
||||
guint n);
|
||||
gint g_list_position (GList *list,
|
||||
GList *link);
|
||||
GList* g_list_find (GList *list,
|
||||
gpointer data);
|
||||
GList* g_list_last (GList *list);
|
||||
|
15
glib/glist.c
15
glib/glist.c
@ -300,6 +300,21 @@ g_list_nth (GList *list,
|
||||
return list;
|
||||
}
|
||||
|
||||
gint
|
||||
g_list_position (GList *list,
|
||||
GList *link)
|
||||
{
|
||||
gint nth;
|
||||
GList *curlink;
|
||||
for(nth = 0, curlink = list; curlink; curlink = g_list_next(curlink), nth++)
|
||||
{
|
||||
if(curlink == link) return nth;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
GList*
|
||||
g_list_find (GList *list,
|
||||
gpointer data)
|
||||
|
@ -126,6 +126,10 @@ main (int argc,
|
||||
g_error ("Regular insert failed");
|
||||
}
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
if(g_list_position(list, g_list_nth (list, i)) != i)
|
||||
g_error("g_list_position does not seem to be the inverse of g_list_nth\n");
|
||||
|
||||
g_list_free (list);
|
||||
list = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user