|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.tree.BalancedBinaryNode<K,V>
K
- the base type of the keys stored by each node.V
- the base type of the values stored by the BinaryNode.public class BalancedBinaryNode<K,V>
Standard node for an unbalanced binary tree.
Each node has a 'key' which is used to determine location of the node within the balanced binary tree. Each node also has a 'value' which can be anything else.
Use the mutator methods CAREFULLY!
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface algs.debug.IGraphEntity |
---|
IGraphEntity.Formatter |
Field Summary | |
---|---|
static boolean |
BLACK
Value to use when node is a BLACK node. |
protected boolean |
color
Color. |
protected BalancedBinaryNode<K,V> |
left
Left son. |
protected BalancedBinaryNode<K,V> |
parent
Parent. |
static boolean |
RED
Value to use when node is a RED node. |
protected BalancedBinaryNode<K,V> |
right
Right son. |
Constructor Summary | |
---|---|
BalancedBinaryNode(K key,
V value,
BalancedBinaryNode<K,V> parent)
Make a new node with given key, value, and parent, and with null child links, and BLACK color. |
Method Summary | |
---|---|
boolean |
color()
Get node color. |
void |
color(boolean color)
Set node color. |
boolean |
equals(java.lang.Object o)
Provide standard equals method. |
K |
key()
Return the key for this node. |
BalancedBinaryNode<K,V> |
left()
Return left son. |
void |
left(BalancedBinaryNode<K,V> newLeft)
Set the left child. |
java.lang.String |
nodeLabel()
Return string label for this entity. |
BalancedBinaryNode<K,V> |
parent()
Get parent (needed for rotations and the like). |
void |
parent(BalancedBinaryNode<K,V> newParent)
Set parent. |
BalancedBinaryNode<K,V> |
right()
Return right son. |
void |
right(BalancedBinaryNode<K,V> newRight)
Set the right child. |
V |
setValue(V value)
Replaces the value currently associated with the key with the given value. |
java.lang.String |
toString()
Return string representation of this node. |
V |
value()
Return the value for this node. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BalancedBinaryNode<K,V> left
protected BalancedBinaryNode<K,V> right
protected BalancedBinaryNode<K,V> parent
public static final boolean RED
public static final boolean BLACK
protected boolean color
Constructor Detail |
---|
public BalancedBinaryNode(K key, V value, BalancedBinaryNode<K,V> parent)
key
- value
- parent
- Method Detail |
---|
public void color(boolean color)
color
- true for BLACK; false for RED.public boolean color()
public BalancedBinaryNode<K,V> left()
public BalancedBinaryNode<K,V> right()
public void right(BalancedBinaryNode<K,V> newRight)
newRight
- new node to be right child.public void left(BalancedBinaryNode<K,V> newLeft)
newLeft
- new node to be left child.public BalancedBinaryNode<K,V> parent()
public void parent(BalancedBinaryNode<K,V> newParent)
newParent
- public K key()
public V value()
public V setValue(V value)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String nodeLabel()
IGraphEntity
nodeLabel
in interface IGraphEntity
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |