|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--BSTTree | +--BSTTreeHead | +--RedBlackTreeHead
This class provides the head structure for a RedBlackTree
. It implements the
interface for TreeHead and implements all important methods necessary for maintaining a
Red-Black Binary Search Tree.
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.
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 | |
RedBlackTreeHead()
Constructs a new, null RedBlackTree, sorted according to the keys' natural order. |
|
RedBlackTreeHead(int treeType)
Constructs a new, empty RedBlackTree according to the type passed. |
Method Summary | |
double |
averageInsertion(int n)
Returns the average Insertion time, according to n, the amount of elements in the tree. |
double |
averageSearchHit(int n)
Returns the average Search hit time, according to n, the amount of elements in the tree. |
double |
averageSearchMiss(int n)
Returns the average Search miss time, according to n, the amount of elements in the tree. |
PaintSettings |
getRedLinkPaint()
Gets the red link paint for the current RedBlackTree . |
java.awt.Stroke |
getRedLinkStroke()
Gets the red link stroke for the current RedBlackTree . |
java.lang.String |
getTreeTypeString()
Gets the tree type String for the BSTTree. |
protected void |
insertAnimatingType(BSTTree node)
Insert the comaparable node to the tree using its natural ordering . |
Animation |
makeDeletionAnimation(BSTTree node)
Makes a delete Animation using the given node. |
Animation |
makeInsertAnimation(BSTTree insertNode)
Makes an insert Animation using the given node. |
protected BSTTree |
makeNodeTreeType(java.lang.Comparable keyInsert,
java.lang.Object valueInsert)
Makes and places the node into the tree. |
void |
setChild(Tree child)
Sets the child of the TreeHead and sets its red link to false. |
void |
setRedLinkPaint(PaintSettings redLinkPaint)
Sets the red link paint for the current RedBlackTree . |
void |
setRedLinkStroke(java.awt.Stroke redLinkStroke)
Gets the red link stroke for the current RedBlackTree . |
void |
setTreeSettings(NodeSettings s,
KeySettings k,
PaintSettings redLinkPaint,
java.awt.Stroke redLinkStroke)
Sets the NodeSettings for the entire tree from the head down. |
void |
waitingAction(java.lang.String action,
java.lang.Object element)
Acts according to the String action passed. |
double |
worstCaseInsertion(int n)
Returns the worst case Insertion time, according to n, the amount of elements in the tree. |
double |
worstCaseSearchHit(int n)
Returns the worst case Search hit time, according to n, the amount of elements in the tree. |
double |
worstCaseSearchMiss(int n)
Returns the worst case Search miss time, according to n, the amount of elements in the tree. |
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 RedBlackTreeHead()
Default type is BST_TREE_TYPE.
public RedBlackTreeHead(int treeType)
treeType
- type of tree that should be implemented.Method Detail |
public java.lang.String getTreeTypeString()
getTreeTypeString
in class BSTTree
public double averageSearchHit(int n)
averageSearchHit
in class BSTTreeHead
n
- the size of the tree for which the average search hit is needed.
public double averageSearchMiss(int n)
averageSearchMiss
in class BSTTreeHead
n
- the size of the tree for which the average search hit is needed.
public double worstCaseSearchHit(int n)
worstCaseSearchHit
in class BSTTreeHead
n
- the size of the tree for which the worst case search hit is needed.
public double worstCaseSearchMiss(int n)
worstCaseSearchMiss
in class BSTTreeHead
n
- the size of the tree for which the worst case search hit is needed.
public double averageInsertion(int n)
averageInsertion
in class BSTTreeHead
n
- the size of the tree for which the average search hit is needed.
public double worstCaseInsertion(int n)
worstCaseInsertion
in class BSTTreeHead
n
- the size of the tree for which the worst case search hit is needed.
public void waitingAction(java.lang.String action, java.lang.Object element)
WaitingActionList
which keeps the list of actions, and calls the method when
instructed to call the next action.
waitingAction
in interface TreeHead
waitingAction
in class BSTTreeHead
action
- 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 setChild(Tree child)
setChild
in interface TreeHead
setChild
in class BSTTreeHead
child
- Tree
, beginning the Tree
nodes.protected BSTTree makeNodeTreeType(java.lang.Comparable keyInsert, java.lang.Object valueInsert)
makeNodeTreeType
in class BSTTreeHead
keyInsert
- comparable object which is added to the tree.valueInsert
- Object that accompanies keyInsert in the node.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the map.public PaintSettings getRedLinkPaint()
RedBlackTree
.
public java.awt.Stroke getRedLinkStroke()
RedBlackTree
.
public void setRedLinkPaint(PaintSettings redLinkPaint)
RedBlackTree
.
redLinkPaint
- the paint for the red links of the drawing node.public void setRedLinkStroke(java.awt.Stroke redLinkStroke)
RedBlackTree
.
public void setTreeSettings(NodeSettings s, KeySettings k, PaintSettings redLinkPaint, java.awt.Stroke redLinkStroke)
NodeSettings
for the entire tree from the head down.
These settings are used for drawing the node and the links of each given tree.
s
- NodeSettings
for use in drawing the entire tree.k
- KeySettings
for use in drawing the keys of the entire tree.protected void insertAnimatingType(BSTTree node) throws java.lang.ClassCastException
Call to insertDrawingType
insertAnimatingType
in class BSTTreeHead
node
- BSTTree node to be inserted into the tree
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the map.public Animation makeInsertAnimation(BSTTree insertNode)
makeInsertAnimation
in class BSTTreeHead
insertNode
- BSTTree node that the insert Animation is built for.
public Animation makeDeletionAnimation(BSTTree node)
makeDeletionAnimation
in class BSTTreeHead
node
- BSTTree node that the deletion Animation is built from.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |