Advice on tree transversals

Jose jgetino at telefonica.net
Thu Mar 28 12:57:26 PDT 2013



I'd like to know if there is any chance of lambdifing tree transversals and
visitors. 

For example, a make a depth first transversal with a recursive call like
this


void  depthFirstVisit(Visitor visitor, VisitMode visitMode) {
        if (visitMode == VisitMode.PRE_ORDER) {
             visitor.visit(this);
         }
         for (Node<D> child : getChildren()) {
                 child.depthFirstVisit(visitMode);
         }
         if (visitMode == VisitMode.POST_ORDER) {
             visitor.visit(this);
         }
	   return list;
}
 
I would like to get rid off the visitor's pattern and replace it with
filters/consumers, which seems not a big deal. But the final goal would be
to replace the transversal code with an appropriate pipeline, which means
decoupling the stream creation from the stream processing. 

I feel I should be simple enough, parallelism is not a concern here, but I
don't see how to generate the tree node stream.  

Thanks 



More information about the lambda-dev mailing list