Re: [Vala] Recursive foreaching
- From: raum no-log org
- To: "Donn" <donn ingle gmail com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Recursive foreaching
- Date: Mon, 25 Nov 2013 15:07:25 +0100
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
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]