Class BinaryTreeBasis<T>

java.lang.Object
  extended by BinaryTreeBasis<T>
Direct Known Subclasses:
BinarySearchTree, BinaryTree

public abstract class BinaryTreeBasis<T>
extends java.lang.Object


Constructor Summary
BinaryTreeBasis()
          Constructor for BinaryTreeBasis
BinaryTreeBasis(T rootItem)
          Constructor for BinaryTreeBasis
 
Method Summary
 TreeNode<T> getRoot()
          A getter for the root node of this BinaryTreeBasis
 T getRootItem()
          This method is used to obtain the data item contained in the root node.
 boolean isEmpty()
          This method is used to check if the BinaryTreeBasis is empty.
 void makeEmpty()
          This method will set the root to null, making the BinaryTreeBasis empty.
 void setRoot(TreeNode<T> root)
          A setter for the root node of this BinaryTreeBasis
abstract  void setRootItem(T newItem)
          This method is used to set the data item to be contained in the root node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTreeBasis

public BinaryTreeBasis()
Constructor for BinaryTreeBasis


BinaryTreeBasis

public BinaryTreeBasis(T rootItem)
Constructor for BinaryTreeBasis

Parameters:
rootItem - The data item that will be contained by the root of this BinaryTreeBasis
Method Detail

isEmpty

public boolean isEmpty()
This method is used to check if the BinaryTreeBasis is empty.

Returns:
Returns true if the root is null, otherwise it returns false

makeEmpty

public void makeEmpty()
This method will set the root to null, making the BinaryTreeBasis empty.


getRootItem

public T getRootItem()
              throws TreeException
This method is used to obtain the data item contained in the root node.

Returns:
Returns the data item contained in the root node.
Throws:
TreeException - This exception is thrown if the root node is null

setRootItem

public abstract void setRootItem(T newItem)
This method is used to set the data item to be contained in the root node.

Parameters:
newItem - the data item to be contained in the root node.

getRoot

public TreeNode<T> getRoot()
A getter for the root node of this BinaryTreeBasis

Returns:
Returns the root node of this BinaryTreeBasis

setRoot

public void setRoot(TreeNode<T> root)
A setter for the root node of this BinaryTreeBasis

Parameters:
root - The new root node of this BinaryTreeBasis