brs.visitor
Class InOrder2<T,P>
java.lang.Object
   brs.visitor.InOrder2<T,P>
brs.visitor.InOrder2<T,P>
- All Implemented Interfaces: 
- IVisitor<T,P,P>
- public class InOrder2<T,P> 
- extends java.lang.Object- implements IVisitor<T,P,P>
Traverse a binary tree in order:
 For an empty tree:
 do the appropriate processing.
 For a non-empty tree:
 Traverse the left subtree in order;
 Process the root;
 Traverse the right subtree in order;
 
 Uses two lambdas as variants.
 Let fRight, fLeft be ILambda and b be some input object.
 empty case: 
   InOrder2(empty, fRight, fLeft, b) = b;
 non-empty case: 
   InOder(tree, fRight, fLeft, b) = 
     fRight(fLeft(InOrder2(tree.left, fRight, fLeft, b), tree)), 
            InOrder2(tree.right, fRight, fLeft, b));
- Since:
- 09/22/2004
 
 
| Method Summary | 
|  P | emptyCase(BiTree<T> host,
                   P... b)Called by the host when the host is empty.
 | 
| static void | main(java.lang.String[] nu)
 | 
|  P | nonEmptyCase(BiTree<T> host,
                         P... b)Called by the host when the host is not empty.
 | 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
_fLeft
private ILambda2<P,P,BiTree<T>> _fLeft
_fRight
private ILambda2<P,P,P> _fRight
InOrder2
public InOrder2(ILambda2<P,P,P> fRight,
                ILambda2<P,P,BiTree<T>> fLeft)
emptyCase
public P emptyCase(BiTree<T> host,
                   P... b)
- Description copied from interface: IVisitor
- Called by the host when the host is empty.
 
- 
- Specified by:
- emptyCasein interface- IVisitor<T,P,P>
 
- 
- Parameters:
- host- an empty BiTree on which this IVisitor operates.
- b- the vararg input needed by this IVisitor to perform its task.
- Returns:
- Object the output of this algorithm on the host.
 
nonEmptyCase
public P nonEmptyCase(BiTree<T> host,
                      P... b)
- Description copied from interface: IVisitor
- Called by the host when the host is not empty.
 
- 
- Specified by:
- nonEmptyCasein interface- IVisitor<T,P,P>
 
- 
- Parameters:
- host- a non-empty BiTree on which this IVisitor operates.
- b- the vararg input needed by this IVisitor to perform its task.
- Returns:
- Object the output of this algorithm on the host.
 
main
public static void main(java.lang.String[] nu)
- 
 
-