The ObjectTree class describes immutable binary trees of objects. An object binary tree is either the empty tree (a leaf) or a (non-empty) tree node with a value component that is an object and left and right components that are object binary trees. The trees are immutable in the sense that the value, left, and right components of a tree node cannot be changed after the tree node has been created (via the node() method).
There are no public constructor or instance methods for object binary trees; they are created and manipulated by the following class methods:
Class Methods
public static ObjectTree
leaf()
Returns an empty object binary tree.
public static ObjectTree
node (Object x, ObjectTree L, ObjectTree R)
Returns a new object binary tree node whose value is
x, whose left subtree is
L, and whose right subtree is
R.
public static
boolean isLeaf
(ObjectTree T)
Returns true if
T is a leaf and false if T is an object binary tree node.
public static Object value
(ObjectTree T)
Returns the object that is the value component of the integer
binary tree node T. Signals an
exception if T is a leaf.
public static ObjectTree
left (ObjectTree T)
Returns the object binary tree that is the left component of
the object binary tree node T.
Signals an exception if T is a
leaf.
public static ObjectTree
right (ObjectTree T)
Returns the object binary tree that is the right component of
the object binary tree node T.
Signals an exception if T is a
leaf.