Re: g_list_prepend() vs g_list_append()
- From: Chema Celorio <chema ximian com>
- To: Mark Mielke <mark mark mielke cc>
- Cc: Jonathan Blandford <jrb redhat com>, gtk-devel-list gnome org
- Subject: Re: g_list_prepend() vs g_list_append()
- Date: 07 Sep 2002 19:20:01 -0500
> For my other point, I still wished to see a method of efficiently
> appending to a list that does not require g_list_last() to be used for
> each append() operation. The cost is linear with the size of the
> list. I did not consider using the "list_head" and "list_tail" fields
> in GQueue, as any write operations would need to properly update GQueue
> in a manner that does not encourage the 'blackbox' approach. Also, GQueue
> still looks like a hack at improving GList that might better be implemented
> using a circular list...
>
> Just some ideas. I like GLIB, but every time I get around to using it,
> I find it to be *so close* to being complete, intuitive, and reliable
> (i.e. better than a majority of other attempts made), but with a few
> inconsistencies and partial implementations that leave me hanging... :-)
>
> Yes, I know I come across as a perfectionist.
GList is a very good linked list implementation. You are just having a
problem with the names, don't let the names fool you. If you want to do
efficient append then do:
<code>
GList *l;
for (i = 0; i < 100; i++)
l = g_list_prepend (l, i);
l = g_list_reverse (l);
</code>
That is what everybody does. With the very heavy use of glist out there
don't expect the implementation to change.
regards,
Chema
>
> Cheers,
> 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/
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list
--
Chema Celorio <chema ximian com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]