brs
Class ToString<T>

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

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

Computes a String representation of the binary tree host so that it can be printed vertically.


Field Summary
private  ToStringHelp<T> _toStringHelp
           
 
Constructor Summary
ToString()
           
 
Method Summary
 java.lang.String emptyCase(BiTree<T> host, java.lang.Void... nu)
          Returns "[]", a String representation of an empty binary tree.
 java.lang.String nonEmptyCase(BiTree<T> host, java.lang.Void... nu)
          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
 

Field Detail

_toStringHelp

private ToStringHelp<T> _toStringHelp
Constructor Detail

ToString

public ToString()
Method Detail

emptyCase

public java.lang.String emptyCase(BiTree<T> host,
                                  java.lang.Void... nu)
Returns "[]", a String representation of an empty binary tree.

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

nonEmptyCase

public java.lang.String nonEmptyCase(BiTree<T> host,
                                     java.lang.Void... nu)
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. Passes appropriate leftmost leading String to a helper visitor to compute the String representations of the left and right subtrees.

Specified by:
nonEmptyCase in interface IVisitor<T,java.lang.String,java.lang.Void>
Parameters:
host - a non-empty binary tree.
nu - not used.
Returns:
String