Re: Continue flame about WEIRD gtk2 design.



Martyn Russell wrote:

> I have to say I 100% agree with what you said Archit, but I would add
> that I do think that GLIBs implementation of GList's (i.e. doubly
> linked lists) could be better.  Where I work we have implemented a
> similar library to GLIB and the list includes a next, previous, head
> and foot pointer for each item in the list.  When an item is removed,
> the list pointer doesnt change, however in GList changes (i.e. append
> and remove...etc) it returns a pointer to a GList which implies the
> Glist is reallocated.  If this is the case, it would be a lot easier
> and better if instead, the item was removed and the previous and next
> items in the list point to each other in their own 'next' and
> 'previous' pointers. This also makes it safer when accessing the list
> from different places in the code in an asynchronous orientated
> application.

Yep, I absolutelly agree with you! Glib-developers also think that our
CPU can move to first element of the list and to the
end element of the list at zero time. Of course in normal realization
List and Node structures are different.
For example:
struct GNode{
    gpointer data;
    GNoe *next,*prev;
};
struct GList{
    GNode *fisrt,*last;
}

in this case g_list_append and g_list_prepend takes constant time.

> Regards,
>
> Martyn
>







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