|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The TreeHead interface extends the Tree interface. The TreeHead is used as the top null node of any given Tree. This implementation makes many necessary methods easier to perform with a null head node. The head node must implement all pertinent methods defined in the interface.
Generally, the TreeHead extends from the Tree in most cases and simply includes more defined methods.
The constructor generally constructs the Tree super construction first and then proceeds to the Head
defined methods. Consequently, the TreeHead is simply an extended Tree
with null information.
Field Summary | |
static java.lang.String |
BALANCE_NODE
String representing the waiting action of balance . |
static java.lang.String |
CHANGE_DISPLAY
String representing the waiting action of changeDisplay . |
static int |
INORDER_TRAVERSAL
Traverse type inorder. |
static java.lang.String |
INSERT_NODE
String representing the waiting action of insert . |
static int |
LEVELORDER_TRAVERSAL
Traverse type levelorder. |
static java.lang.String |
PARTITION_NODE
String representing the waiting action of partition . |
static int |
POSTORDER_TRAVERSAL
Traverse type postorder. |
static int |
PREORDER_TRAVERSAL
Traverse type preorder. |
static java.lang.String |
REMOVE_NODE
String representing the waiting action of remove . |
static java.lang.String |
ROTATE_TO_TOP_NODE
String representing the waiting action of rotateToTop . |
static java.lang.String |
ROTATE_UP
String representing the waiting action of rotateUp . |
static java.lang.String |
ROTATE_UP_DOUBLE
String representing the waiting action of rotateUpDouble . |
static java.lang.String |
SEARCH
String representing the waiting action of search . |
static java.lang.String |
SELECT
String representing the waiting action of select . |
static java.lang.String |
SPLAY_NODE
String representing the waiting action of splay . |
static java.lang.String |
TRAVERSE
String representing the waiting action of traverse . |
Method Summary | |
void |
addTreeMessageListener(TreeMessageListener l)
Adds an TreeMessageListener from the tree, according to the TreeMessageListener interface and the TreeMessageEvent . |
void |
balance(Tree node)
Balances the tree, from the node downward. |
void |
balanceTree()
Balances the entire tree. |
void |
clear()
Clears the tree completely, removing all references to all nodes and all values return to the default. |
void |
fixLevel()
Fixes the lowest level of the Tree . |
Tree |
getChild()
Gets the child of the TreeHead. |
int |
getTreeLevel()
Gets the lowest level of the Tree. |
boolean |
insert(java.lang.Comparable keyInsert,
java.lang.Object valueInsert)
Adds the comaparable object keyInsert to the tree using its natural ordering . |
boolean |
isTreeEmpty()
Returns true if the |
Tree |
partition(Tree node,
int keySelect)
Partitions from the given node the keySelect value. |
boolean |
remove(java.lang.Comparable keyRemove)
Removes the comaparable object keyRemove from the BSTTree using its natural ordering . |
void |
remove(Tree node)
Removes the given node from the tree. |
void |
removeTreeMessageListener(TreeMessageListener l)
Removes an TreeMessageListener from the tree, according to the TreeMessageListener interface and the TreeMessageEvent . |
void |
resetTreeLevel()
Resets the lowest level of the Tree . |
Tree |
search(java.lang.Comparable keySearch)
Searches for the comaparable object in the Tree using its natural ordering . |
Tree |
select(Tree node,
int keySelect)
Selects the kth smallest item in the Tree using its natural ordering from the given node. |
void |
setChild(Tree child)
Sets the child of the TreeHead. |
int |
size()
Returns the number of objects in the entire tree. |
void |
waitingAction(java.lang.String action,
java.lang.Object element)
Acts according to the String action passed. |
Methods inherited from interface Tree |
getChildren, getKey, getLevel, getParentTree, getValue, isEmpty |
Field Detail |
public static final java.lang.String ROTATE_UP
rotateUp
. Requires an accompanying node.
public static final java.lang.String ROTATE_TO_TOP_NODE
rotateToTop
. Requires an accompanying node.
public static final java.lang.String ROTATE_UP_DOUBLE
rotateUpDouble
. Requires an accompanying node.
public static final java.lang.String SPLAY_NODE
splay
. Requires an accompanying node.
public static final java.lang.String REMOVE_NODE
remove
. Requires an accompanying node.
public static final java.lang.String INSERT_NODE
insert
. Requires an accompanying node.
public static final java.lang.String SEARCH
search
. Requires an accompanying node.
public static final java.lang.String SELECT
select
. Requires an accompanying node.
public static final java.lang.String PARTITION_NODE
partition
. Requires an accompanying NodeAndKey
object (Inner class of BSTTreeHead).
public static final java.lang.String BALANCE_NODE
balance
. Requires an accompanying NodeAndKey
object (Inner class of BSTTreeHead).
public static final java.lang.String TRAVERSE
traverse
. Requires an accompanying Integer
object.
public static final java.lang.String CHANGE_DISPLAY
changeDisplay
.
public static final int PREORDER_TRAVERSAL
public static final int INORDER_TRAVERSAL
public static final int POSTORDER_TRAVERSAL
public static final int LEVELORDER_TRAVERSAL
Method Detail |
public boolean isTreeEmpty()
TreeHead
is empty.public void resetTreeLevel()
Tree
.
public int getTreeLevel()
Tree
.public void fixLevel()
Tree
.
public void setChild(Tree child)
child
- Tree
, beginning the Tree
nodes.public Tree getChild()
public void addTreeMessageListener(TreeMessageListener l)
TreeMessageEvent
.
l
- the listener added recieves the TreeMessageEvents occuring.public void removeTreeMessageListener(TreeMessageListener l)
TreeMessageEvent
.
l
- the listener removed from recieving the TreeMessageEvents occuring.public boolean insert(java.lang.Comparable keyInsert, java.lang.Object valueInsert) throws java.lang.ClassCastException, java.lang.NullPointerException
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.
java.lang.NullPointerException
- key is null.public void remove(Tree node) throws java.lang.NullPointerException
node
- the Tree
node to be removed from the tree.
java.lang.NullPointerException
- node is null
public boolean remove(java.lang.Comparable keyRemove) throws java.lang.ClassCastException, java.lang.NullPointerException
BSTTree
using its natural ordering .
If the method is successful in removing the element, true is returned.
keyRemove
- comparable object which is removed from the tree.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the map.
java.lang.NullPointerException
- key is null.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, null is
returned.
keySearch
- 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.public Tree partition(Tree node, int keySelect)
node
- Tree which the partition occurs at.keySelect
- integer key selecting the count item.
public Tree select(Tree node, int keySelect)
Tree
using its natural ordering from the given node.
If the method is successful in finding the element, the item is returned. Otherwise, null is
returned if the integer is greater than the size.
node
- Tree which the partition occurs at.keySelect
- integer key selecting the count item.
public void balanceTree()
public void balance(Tree node)
node
- the Tree node from which the balance occurspublic int size()
size
in interface Tree
public void clear()
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.
action
- String action representing the next action for the TreeHead.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |