[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: double linked glists



On Mon, 7 Jun 1999, BIRCH, JANET M wrote:

> here goes:
> 
> GList *Key_SSN_List;   <-- a global
> 
> void goto_next_record(GtkNotebook *data)
> {
>   gint page = -1;
>  
>   page = gtk_notebook_get_current_page(GTK_NOTEBOOK(data)):
>   if (page == SSN_BARRED_PG)
>     {
>        Key_SSN_List = g_list_next(Key_SSN_List);
>        if (Key_SSN_List == NULL)
>          printf("No more records in that direction\n");
>        else
>          show_record((int)(Key_SSN_List->data));
>     }
> }
> 
> the goto_prev() function is exactly the same except it uses the
> g_list_previous() call.  
But this code doesn't show, how you realized the *circular* list.

Circular lists work for me.  I use it for animation of images in
my image viewer paul in file animate.c:
  http://www.physik.uni-halle.de/~e2od5/debian/paul.html

Generally I have a doubly linked list of images.  Before I start
animation I do

  (tmplist = g_list_last(list))->next = list;
  list->prev = tmplist;

This way the ring is closed and the animation can be run forewards
or backwards ... this seems me to be an application for a circular
list.  I dosn't understand your example.  Why do you need a circular
list?  (Note:  Before you free the list you have to do

  (tmplist = g_list_last(list))->next = NULL;
  list->prev = NULL;

to open the ring again.

Hope that helps

        Andreas.

[X] Against war.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]