Re: [Proposal] GRing



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
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.)

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.

Havoc




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