Re: [Proposal] GRing



On 19 Aug 2001, Havoc Pennington wrote:

> 
> Joshua N Pritikin <vishnu pobox com> writes: 
> > struct GQueue
> >  {
> >    GList *head;
> >    GList *tail;
> >    guint  length;
> >  };
> > 
> > The GQueue struct becomes unnecessary since GRing has exactly the same
> > space requirements as a GList.  i guess this space advantage is not so
> > dramatic, but the API is better -- NULL is a valid GRing of zero length.
> > 
> 
> I think the space advantage is nonexistent; for something that can be
> N nodes long, 12 bytes of constant overhead is equivalent to zero.
> 
> "NULL is a valid zero-length list" is sort of a minor API detail.  The

i don't consider this API "detail" minor, it's in fact one of the most
convenient properties of GList.

> macro-level difference in these two APIs is that GQueue is a sort of
> GList "handle" that gives you queue operations and tail caching, while
> GRing copies the GList API in its entirety and is its own native data
> structure. (Though you can call GList functions on queue->head, at
> least the functions that don't mutate the list.)

nope, functions like g_list_length() would end up looping forever
if being used on a ring.

> I'm actually finding it pretty hard to think of interesting reasons to
> prefer one over the other, that's why I was wondering if we had any
> relevant discussion on the list archives.

well, GRing openes up the full power of the g_list API to you, concatenating,
sorting, custom finds, etc...
while GQueue is pretty limited in scope by definition already.


> 
> Havoc
> 

---
ciaoTJ





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