On Iteration

Philippe Sigaud philippe.sigaud at gmail.com
Tue Nov 10 13:35:27 PST 2009


On Tue, Nov 10, 2009 at 16:07, BLS <windevguy at 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091110/bd590da7/attachment.html>


More information about the Digitalmars-d mailing list