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()
+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
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);
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)
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;