Re: Tree/ListStore implementation



On Wed, 2002-07-10 at 11:16, Owen Taylor wrote:
> 
> You can do it like this:
> 
>  GtkTreeIter *location = NULL;
>  GtkTreeIter new_location;
>  
>  while ([more rows to insert])
>  { 
>    gtk_tree_store_insert_after (tree_store, &new_location, parent, location);
> 
>   [ do something with &new_location ];
> 
>    location = &new_location;
>  }
> 
> The above technique is more flexible than having TreeStore
> optimize a single case - what if you wanted to insert a bunch
> of items in the middle of a tree view level?

Ok, it's a good solution. I've missed this method :)
But anyway, why not to improve the implementation if it can be done so
easily?
GtkTreeStore doesn't have a single tail, but each branch has one and you
always add data to some branch anyway so this could be much faster even
if one forgets that it is possible to do things faster with
*_insert_after() than *_append().
If you really don't want to change data structures then perhaps
TreeStore might keep an iterator pointing to last element and wrap all
calls to _append() to _insert_after(). I know, it sounds silly, but I
still think it is more silly to use slower implementation when faster is
trivial.

> (Changing how GSList or GList work is not an option.

I suppose you have a very strong argument against improving GSList?

-- 
struct Sig {
  string name("     J a r e k   D u k a t     ");
  string mail(" madmaxer (at) poczta (dot) fm ");
};


----------------------------------------------------------------------
Szukasz wrazen? Nowych znajomosci?
Wyslij SMS-a o tresci RANDKA na numer 7181. To tylko 1 zl + VAT! 
>>> http://link.interia.pl/f1610





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