|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--BSTTree
|
+--BSTTreeHead
|
+--RootInsertionBSTTreeHead
This class provides the head structure for a BSTTree that is root inserted. It implements the
interface for TreeHead and implements all important methods necessary for maintaining a
Root Inserted Binary Search Tree.
| Nested Class Summary |
| Nested classes inherited from class BSTTreeHead |
BSTTreeHead.NodeAndKey |
| Field Summary | |
static java.lang.String |
TREE_INFORMATION
String representing information regarding the type of tree. |
| Fields inherited from class BSTTreeHead |
BINARY_DISPLAY, SECTIONAL_DISPLAY |
| Fields inherited from class BSTTree |
ANIMATING_BST_TREE_TYPE, BST_TREE_TYPE, DRAWING_BST_TREE_TYPE |
| Fields inherited from interface TreeHead |
BALANCE_NODE, CHANGE_DISPLAY, INORDER_TRAVERSAL, INSERT_NODE, LEVELORDER_TRAVERSAL, PARTITION_NODE, POSTORDER_TRAVERSAL, PREORDER_TRAVERSAL, REMOVE_NODE, ROTATE_TO_TOP_NODE, ROTATE_UP, ROTATE_UP_DOUBLE, SEARCH, SELECT, SPLAY_NODE, TRAVERSE |
| Constructor Summary | |
RootInsertionBSTTreeHead()
Constructs a new, null RootInsertionBSTTreeHead, sorted according to the keys' natural order and insertion occurs automatically to the root. |
|
RootInsertionBSTTreeHead(int treeType)
Constructs a new, empty RootInsertionBSTTreeHead according to the type passed. |
|
| Method Summary | |
java.lang.String |
getTreeTypeString()
Gets the tree type String for the BSTTree. |
void |
insert(Tree node)
Adds the node to the tree using its natural ordering . |
protected void |
insertAnimatingType(BSTTree node)
Insert the comaparable node to the tree using its natural ordering . |
Tree |
search(java.lang.Comparable keySearch)
Searches for the comaparable object in the Tree using its natural ordering . |
void |
waitingAction(java.lang.String action,
java.lang.Object element)
Acts according to the String action passed.Overides BSTTree, to stop rapid-fire insertion. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface Tree |
getChildren, getKey, getLevel, getParentTree, getValue, isEmpty |
| Field Detail |
public static final java.lang.String TREE_INFORMATION
| Constructor Detail |
public RootInsertionBSTTreeHead()
Default type is BST_TREE_TYPE.
public RootInsertionBSTTreeHead(int treeType)
treeType - type of tree that should be implemented.| Method Detail |
public java.lang.String getTreeTypeString()
getTreeTypeString in class BSTTree
public void waitingAction(java.lang.String action,
java.lang.Object element)
waitingAction in interface TreeHeadwaitingAction in class BSTTreeHeadaction - String action representing the next action for the BSTTreeHead.element - element to which the action could be occuring, depending on the type of action.
public void insert(Tree node)
throws java.lang.ClassCastException
The new node is inserted and then rotateToToped to the root. This defines the tree as a rotateToTop BSTTree.
insert in class BSTTreeHeadnode - BSTTree which is added to the tree.
java.lang.ClassCastException - key cannot be compared with the keys
currently in the map.
public Tree search(java.lang.Comparable keySearch)
throws java.lang.ClassCastException,
java.lang.NullPointerException
Tree using its natural ordering .
If the method is successful in finding the element, the item is returned. Otherwise, the closest item is
returned.
The found node rotated to the top, to the root. If the node is not found, the nearest node is rotated to the top.
search in interface TreeHeadsearch in class BSTTreeHeadkeySearch - comparable object which is search for within the tree.
java.lang.ClassCastException - key cannot be compared with the keys
currently in the map.
java.lang.NullPointerException - key is null.
protected void insertAnimatingType(BSTTree node)
throws java.lang.ClassCastException
Makes insert a waitingAction if the tree is animating.
insertAnimatingType in class BSTTreeHeadnode - BSTTree node to be inserted into the tree
java.lang.ClassCastException - key cannot be compared with the keys
currently in the map.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||