|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.math.graph_tree.BalancedBinaryTreeNode
public class BalancedBinaryTreeNode
Title: BalancedBinaryTreeNode - models a node in a balanced binary tree.
Description: Balanced binary tree node. Note that this class makes use of Comparator.compare() so that the node object type used must implement Comparator.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software.
| Field Summary | |
|---|---|
protected PlainColour |
colour
Node colour. |
protected java.util.Comparator |
comparator
Comparator object. |
protected BalancedBinaryTreeNode |
left
Node left node. |
protected HObject |
object
Node object. |
protected BalancedBinaryTreeNode |
parent
Node parent node. |
protected BalancedBinaryTreeNode |
right
Node right node. |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
BalancedBinaryTreeNode()
Default constructor. |
|
BalancedBinaryTreeNode(HObject object)
Constructor. |
|
BalancedBinaryTreeNode(HObject object,
PlainColour colour,
BalancedBinaryTreeNode left,
BalancedBinaryTreeNode right,
BalancedBinaryTreeNode parent)
Constructor. |
|
| Method Summary | |
|---|---|
BalancedBinaryTreeNode |
associatedNode(HObject obj)
Searches a binary node for the node associated with an object and returns the associated node if the node is in the tree, else returns null. |
int |
degree()
Returns the degree of a node. |
PlainColour |
getColour()
Returns this node's colour. |
java.util.Comparator |
getComparator()
Returns the Comparator; ie object. |
BalancedBinaryTreeNode |
getLeftNode()
Returns this node's left node. |
HObject |
getNodeObject()
Returns the node object. |
BalancedBinaryTreeNode |
getParentNode()
Returns this node's parent node. |
BalancedBinaryTreeNode |
getRightNode()
Returns this node's right node. |
boolean |
isLeaf()
Returns logical-true if a node is a leaf (i.e. |
boolean |
isParent()
Returns logical-true if a node is a parent (i.e. |
BalancedBinaryTreeNode |
leftRotate(HBoolean rootNode)
Left-rotation of a node. |
BalancedBinaryTreeNode |
rightRotate(HBoolean rootNode)
Right-rotation of a node. |
boolean |
search(HObject obj)
Searches a binary node for an object and returns logical-true if the object is in the node, else logical-false. |
boolean |
setColour(PlainColour newColour)
Sets this node's colour. |
boolean |
setLeftNode(BalancedBinaryTreeNode newLeftNode)
Sets this node's left node. |
boolean |
setNodeObject(HObject newNodeObject)
Sets the node object to the specified object. |
boolean |
setParentNode(BalancedBinaryTreeNode newParentNode)
Sets this node's parent node. |
boolean |
setRightNode(BalancedBinaryTreeNode newRightNode)
Sets this node's right node. |
java.lang.String |
toString()
Returns a String representation of a BalancedBinaryTreeNode object. |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Comparator comparator
protected HObject object
protected BalancedBinaryTreeNode left
protected BalancedBinaryTreeNode right
protected BalancedBinaryTreeNode parent
protected PlainColour colour
| Constructor Detail |
|---|
public BalancedBinaryTreeNode()
public BalancedBinaryTreeNode(HObject object)
throws java.lang.IllegalArgumentException
object - Node object. Must implement Comparator.
java.lang.IllegalArgumentException - Thrown if object does not implement Comparator.
public BalancedBinaryTreeNode(HObject object,
PlainColour colour,
BalancedBinaryTreeNode left,
BalancedBinaryTreeNode right,
BalancedBinaryTreeNode parent)
throws java.lang.IllegalArgumentException
object - Node object.colour - Node colour.left - Left node.right - Right node.parent - Parent node.
java.lang.IllegalArgumentException - Thrown if object does not implement Comparator.| Method Detail |
|---|
public BalancedBinaryTreeNode associatedNode(HObject obj)
obj - Object node to search for.
public PlainColour getColour()
public boolean setColour(PlainColour newColour)
newColour - New colour.
public java.util.Comparator getComparator()
public int degree()
public boolean isLeaf()
public boolean isParent()
public BalancedBinaryTreeNode getLeftNode()
public boolean setLeftNode(BalancedBinaryTreeNode newLeftNode)
newLeftNode - New left node.
public BalancedBinaryTreeNode leftRotate(HBoolean rootNode)
rootNode - Returned, via reference, and set to logical-true if root node, else logical-false.
public HObject getNodeObject()
public boolean setNodeObject(HObject newNodeObject)
newNodeObject - New node object. Must implement Comparator.
public BalancedBinaryTreeNode getParentNode()
public boolean setParentNode(BalancedBinaryTreeNode newParentNode)
newParentNode - New parent node.
public BalancedBinaryTreeNode getRightNode()
public boolean setRightNode(BalancedBinaryTreeNode newRightNode)
newRightNode - New right node.
public BalancedBinaryTreeNode rightRotate(HBoolean rootNode)
rootNode - Returned, via reference, and set to logical-true if root node, else logical-false.
public boolean search(HObject obj)
obj - Object to search for.
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||