On Tue, Nov 10, 2009 at 16:07, BLS <windev...@hotmail.de> wrote: > On 10/11/2009 11:18, Lutger wrote: > > - how to do ranges over a tree? >> My first thought was that a tree would define preorder / inorder / >> postorder >> ranges, and then perhaps visitors for more complex algorithms. >> > > > I asked the same question quit a while ago... I think we have to imagine a > tree's branch as sub range. ( In other words, treat them like linear > structures) > > How to implement it? I dunno. >
I had a Tree (and Graph) struct some month ago. In another module, I defined depthFirst(Tree t) and breadthFirst(Tree t) functions, which just returned a lazy range (a struct, as always), iterating in a depth-first/breadth-first way on t. Except having them as methods of Tree/Graph, how would you do it?