brs
Class ToStringHelp<T>

java.lang.Object
  extended by brs.ToStringHelp<T>
All Implemented Interfaces:
IVisitor<T,java.lang.String,java.lang.String>

public class ToStringHelp<T>
extends java.lang.Object
implements IVisitor<T,java.lang.String,java.lang.String>

Computes a String representation of the binary tree host so that it can be printed vertically, given a leftmost leading string for the two subtrees. Called by ToString. Should be implemented as an anonymous inner class in the call by ToString.


Constructor Summary
ToStringHelp()
           
 
Method Summary
 java.lang.String emptyCase(BiTree<T> host, java.lang.String... nu)
          Returns "|_[]" to denote an empty tree subtree.
 java.lang.String nonEmptyCase(BiTree<T> host, java.lang.String... leftLead)
          Computes a String representation of the binary tree host so that it can be printed vertically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToStringHelp

public ToStringHelp()
Method Detail

emptyCase

public java.lang.String emptyCase(BiTree<T> host,
                                  java.lang.String... nu)
Returns "|_[]" to denote an empty tree subtree.

Specified by:
emptyCase in interface IVisitor<T,java.lang.String,java.lang.String>
Parameters:
host - an empty binary (sub)tree.
nu - not used.
Returns:
String

nonEmptyCase

public java.lang.String nonEmptyCase(BiTree<T> host,
                                     java.lang.String... leftLead)
Computes a String representation of the binary tree host so that it can be printed vertically. There is no '\n' at the end of the String.

Specified by:
nonEmptyCase in interface IVisitor<T,java.lang.String,java.lang.String>
Parameters:
host - a non-empty binary (sub)tree.
leftLead - appropriate leftmost leading String to help compute the String representations of the left and right subtrees.
Returns:
String