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:
Elliot Lee 1998-04-28 00:24:34 +00:00
parent 5647eeecf3
commit 9556bba1ba
4 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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;