|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--BSTTree | +--BalancedBSTTree
This class provides the head structure for a BalancedBSTTree
. Therefore,
it overides all important methods necessary for maintaining a
Balanced BST.
Note that this implementation is not synchronized. If multiple threads access this tree concurrently, and at least one of the threads modifies the tree structurally, it must be synchronized externally.
Field Summary |
Fields inherited from class BSTTree |
ANIMATING_BST_TREE_TYPE, BST_TREE_TYPE, DRAWING_BST_TREE_TYPE |
Constructor Summary | |
BalancedBSTTree()
Constructs a new, null BalancedBSTTreeHead, sorted according to the keys' natural order and insertion occurs automatically to the root. |
|
BalancedBSTTree(int treeType)
Constructs a new, empty BalancedBSTTreeHead according to the type passed. |
Method Summary | |
protected void |
insert(BSTTree newTree,
int currentLevel)
Inserts the given object into the tree, using recursive calls and is called from the Head node. |
protected Tree |
search(java.lang.Comparable keyFind)
Finds a node within a tree using the comparable keyFind. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BalancedBSTTree()
Default type is BST_TREE_TYPE.
public BalancedBSTTree(int treeType)
treeType
- type of tree that should be implemented.Method Detail |
protected void insert(BSTTree newTree, int currentLevel) throws java.lang.ClassCastException
Randomly (according to the probability set in the head) balances each node after passing in an insertion.
insert
in class BSTTree
newTree
- the tree to be inserted, with key and value already set.currentLevel
- keeps track of the recursive call, and sets the new level if it changes.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the tree.protected Tree search(java.lang.Comparable keyFind) throws java.lang.ClassCastException
search
in class BSTTree
keyFind
- the key which the method is attempting to find.
java.lang.ClassCastException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |