|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCITS2200.BinaryTree<E>
public abstract class BinaryTree<E>
A class to represent binary tree where each node contains an item E The class is immutable, so after a tree is created, it cannot be changed.
Constructor Summary | |
---|---|
BinaryTree()
Constructs an empty Binary Tree |
|
BinaryTree(E item,
BinaryTree<E> left,
BinaryTree<E> right)
Constructs a binary tree containing the specified item at the root, and a left and right binary tree as children. |
Method Summary | |
---|---|
abstract boolean |
equals(Object o)
Tests whether the tree is equal to an Object, where two trees are equal if either both trees are empty, or both trees contain equal items at the root (tested using the equals method of E), and have equal left subtrees and equal right subtrees (recursively calling the equals method of BinaryTree. |
E |
getItem()
Returns the item stored at the root |
BinaryTree<E> |
getLeft()
Returns the left subtree |
BinaryTree<E> |
getRight()
Returns the right subtree |
boolean |
isEmpty()
|
abstract Iterator<E> |
iterator()
Returns an iterator that will traverse through every element in the tree, exactly once. |
String |
toString()
Returns a string representation of the tree, calling the toString method of E. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BinaryTree()
public BinaryTree(E item, BinaryTree<E> left, BinaryTree<E> right)
item
- the item to be stored in the root.left
- the left subtree.right
- the right subtree.Method Detail |
---|
public boolean isEmpty()
public E getItem()
Underflow
- if the tree is emptypublic BinaryTree<E> getLeft()
Underflow
- if the tree is emptypublic BinaryTree<E> getRight()
Underflow
- if the tree is emptypublic abstract Iterator<E> iterator()
public String toString()
toString
in class Object
public abstract boolean equals(Object o)
equals
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |