Re: [gtk-list] Re: g_list_append is O(n^2)



>  sorry for the confusion. STL has constant time at least for  push_back()
>  and push_front(), while glib has constant time for g_list_prepend()
>  but linear time for g_list_append(). It has to go through the whole
>  list in g_list_last().

Glib lists work pretty much like Lisp lists.

Applications which require O(1) append/prepend times use the "keep
pointers to the list start and end" method -- you can look at the
GnomeCanvas, GtkCList, etc.

  Federico



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