Re: Going through a TreeStore



Hi Quentin,

thanks for your responses.

On Wed, 19 May 2004 16:31:34 +0200, Quentin Sculo said:

This time it should be right :) :

Hmpf, before I can comment on that, I suppose, I have to understand your
code. ;-) OK, let's see what I make out of this and please tell me if I'm
wrong somewhere.

my $iter=$store->get_iter_first;      # or starting point

Easy, let's start with the first iterator.

while ($iter)

Do the stuff only if the last $iter is not undef.

{     # do something

This would be my check for i.e. a special property.

      $iter=( $store->iter_children($iter)||$store->iter_next($iter) );

My next $iter is either the cild or, if there is no child, just the next
one.

      unless ($iter)

Do the next thing, only if $iter is undefined, that is, if the next $iter
got us nowhere.

      {       $iter=$store->iter_next($_) while

Here things start to get unclear. Who sets $_ to what here?

                      $_=$store->iter_parent($iter);

Oh, ok, I see, I really have to get used that you can write the reactio
before the actio in Perl. ;-)

Then this has to mean: Set $_ to the iter_parent as often as possible and
afterward $iter will hold the iter of the "toplevel parent".

      }
}

Wow, if my understanding is correct, I can go through a tree starting
somewhere handling the problems when starting at a child level and not
using a single recursion. Sounds good. :-)

Ciao
Florian

Attachment: pgpJ61HMOw5Lx.pgp
Description: PGP signature



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