Elmano Carvalho wrote: > I am writing an application that uses Singly-Linked Lists for adding and > removing elements on that list. > > I need to go through the list, identify each element and remove them on > the go... > > As the subject suggests, there's a function for getting the first > element of the list (g_list_first()), which is what I need, but is > > only available for the doubly-linked lists implementations...
the pointer to a a single linked list has to be the first item of the list. Because the list only has a forward link, it is not possible to go backwards in the list, and thus if you do not have a pointer to the first element, you can never reach that element. In a double linked list, you may have a pointer which is in the middole of the list. Because a double linked list has pointers forward and backward, the function g_list_first() makes sense: follow all pointers backwards until no more pointers are found. In reality, most double linked list functions in glib return the first element of the list as well, but this is not in the API reference, and thus not guaranteed. regards, Olivier Sessink _______________________________________________ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list