Hello

I've tried something like that (In fact I've began to code a turn based
game... ehm... well ok... I'll explain in the future)

It's my first attempt in vala :
https://sourceforge.net/projects/valatreeobjects/files/

Really perfectible but  it's fun.

I'll try to clean up my code and use vala's best practices later (or if
someone want to have a look ;))

Regards

Raum



> I have a tree of nodes, something like this in pseudocode:
> class Node
>   ArrayList kidnodes
>   Node parent
>
> So - each node has kids and a parent.
>
> I find myself wanting to foreach over the tree from code that is not
> within a Node.
>
> Right now, I'm doing this kind of thing:
>
> class Node
>    ...
>    public void walk( somelist)
>      foreach(kid in kidnodes)
>        somelist.add (kid) //visit.
>        walk( somelist )
>
> Then, in some other object:
> var list = somelist
> somenode.walk(l)
> //now i can foreach through "list"
>
> Is there some way I can do:
>
> somenode = rootnode; //say
> foreach( node in somenode)
>    visit(node)
>
> so that it visits the nodes like walk does?
>
>
>
> \d
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
>

_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to