|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.tree.BinaryTree<T>
T
- the base type of the values stored by the BinaryTree. Must be
Comparable.public class BinaryTree<T extends java.lang.Comparable>
Standard unbalanced binary tree. Duplicates are allowed. The right child of a node in the tree is guaranteed to have its value be greater than or equal to its parent.
Constructor Summary | |
---|---|
BinaryTree()
Default BinaryTree constructor. |
Method Summary | |
---|---|
BinaryNode<T> |
getRoot()
Expose the root of the tree. |
java.util.Iterator<T> |
inorder()
Use in-order traversal over the tree. |
void |
insert(T value)
Insert the value into its proper location in the Binary tree. |
java.util.Iterator<T> |
iterator()
Provide useful in-order iteration over the values of the Binary Tree. |
boolean |
member(T value)
Determine if the given value occurs in the tree |
java.util.Iterator<T> |
postorder()
Use post-order traversal over the tree. |
java.util.Iterator<T> |
preorder()
Use pre-order traversal over the tree. |
boolean |
remove(T value)
Remove the value from the tree. |
protected void |
setRoot(BinaryNode<T> newRoot)
Helper method to properly set the root for the tree. |
java.lang.String |
toString()
Create string representation of the Tree. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BinaryTree()
Method Detail |
---|
protected void setRoot(BinaryNode<T> newRoot)
newRoot
- public BinaryNode<T> getRoot()
public boolean member(T value)
value
- non-null desired value to search for
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public boolean remove(T value)
value
- non-null value to be removed
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public void insert(T value)
value
- non-null value to be added into the tree.
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Iterator<T> inorder()
public java.util.Iterator<T> preorder()
public java.util.Iterator<T> postorder()
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T extends java.lang.Comparable>
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |