Re: g_list_prepend() vs g_list_append()



On Sun, Sep 08, 2002 at 11:51:43AM -0400, Mark Mielke wrote:
> On Sun, Sep 08, 2002 at 01:17:13PM +0200, Soeren Sandmann wrote:
> > James Henstridge <james daa com au> writes:
> > > By the way, if you want to efficiently append to a GList, you should
> > > maintain a tail pointer.  
> > Or just use the GQueue data structure. GQueue is just a list and a
> > tail pointer.
> That must be updated by hand, which requires the caller to assume to know
> exactly how a GQueue is internally implemented. If GQueue ever changed,
> for example, if it became a circular list, any code that assumed to know
> how to update GQueue state information, would be broken. Now, it might be
> too late for this, as people may already do such things, but it doesn't
> make it 'right'. :-)

I wrote this too fast. I assumed you read my original post that started this
thread, and drew an incorrect conclusion that I previously did not draw. :-)

GQueue solves the append() issue, but it does not solve the traversal issue,
unless one assumes that the structure of a GQueue is two list pointers, and
that it will always be two list poiniters.

I'm not asking for a hack. I'm asking if you would like for me to
submit code quite similar to glist.c/glist.h, that is designed and
optimized for circular doubly-linked lists. If so, what should I call
it, and where should it go? (GCList? - although this name does not
appeal to me as I can see somebody confusing GC with "garbage collection")

mark

-- 
mark mielke cc/markm ncf ca/markm nortelnetworks com __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/




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