Class brs.ToStringHelp


public class ToStringHelp
extends Object
implements brs.IVisitor
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.

Author:
Dung X. Nguyen - Copyright 2001 - All rights reserved.

Variable Index

 o Singleton

Constructor Index

 o ToStringHelp ()

Method Index

 o emptyCase (BiTree, Object[])
Returns "|_[]" to denote an empty tree subtree
 o nonEmptyCase (BiTree, Object[])
Computes a String representation of the binary tree host so that it

Variables

 o Singleton
public static final ToStringHelp Singleton = new ToStringHelp ()

Constructors

 o ToStringHelp
private  ToStringHelp()

Methods

 o emptyCase
public Object emptyCase(BiTree host, Object[] nu)
Returns "|_[]" to denote an empty tree subtree.

Parameters:
host - an empty binary (sub)tree.
nu - not used.
Returns:
String
 o nonEmptyCase
public Object nonEmptyCase(BiTree host, Object[] 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.

Parameters:
host - a non-empty binary (sub)tree.
leftLead[0] - appropriate leftmost leading String to help compute the String representations of the left and right subtrees.
Returns:
String