brs.visitor
Class InOrder3<T,P>
java.lang.Object
brs.visitor.InOrder3<T,P>
- All Implemented Interfaces:
- IVisitor<T,P,P>
public class InOrder3<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 3 lambdas as variants.
Let fRight, fLeft, fRoot be ILambda and b be some input object.
empty case:
InOrder3(empty, fRight, fRoot, fLeft, b) = b;
non-empty case:
InOder(tree, fRight, fRoot, fLeft, b) =
fRight(InOrder3(tree.right, fRight, fRoot, fLeft, b),
fRoot(tree,
fLeft(InOrder3(tree.left, fRight, fRoot, fLeft, b), b),
b),
b);
- Since:
- 09/22/2004
Constructor Summary |
InOrder3( fRight,
fRoot,
fLeft)
|
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 _fLeft
_fRoot
private _fRoot
_fRight
private _fRight
InOrder3
public InOrder3( fRight,
fRoot,
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:
emptyCase
in 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:
nonEmptyCase
in 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)