|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectstructure.RedBlackTree<ELTTYPE>
public class RedBlackTree<ELTTYPE extends java.lang.Comparable<ELTTYPE>>
This class implements a single node of a red-black tree. It is a recursive structure. Relationships between nodes are doubly linked, with parent and child references. Many characteristics of trees may be detected with static methods.
structure.AVLTree,
BinaryTree,
BinarySearchTree| Field Summary | |
|---|---|
static RedBlackTree |
EMPTY
the unique empty node; used as children on leaf trees and as empty search trees. |
| Constructor Summary | |
|---|---|
RedBlackTree(ELTTYPE v)
Constructs a red-black tree with no children, value of the node is provided by the user |
|
| Method Summary | |
|---|---|
RedBlackTree<ELTTYPE> |
add(ELTTYPE c)
Add a value to the red black tree, performing neccisary rotations and adjustments. |
boolean |
consistency()
Returns true if this node is consistently structured |
boolean |
contains(ELTTYPE c)
Determines if the red black search tree contains a value |
int |
depth()
Compute the depth of a node. |
ELTTYPE |
get(ELTTYPE c)
Returns a c-equivalent value from tree, or null. |
int |
hashCode()
Computes hash code associated with values of tree. |
boolean |
isEmpty()
Returns true if tree is empty. |
boolean |
isLeftChild()
Determine if this node is a left child |
boolean |
isRightChild()
Determine if this node is a right child |
java.util.Iterator<ELTTYPE> |
iterator()
Returns an in-order iterator over the subtree rooted at this node. |
void |
print()
|
void |
redFixup()
Takes a red node and, restores the red nodes of the tree to maintain red-black properties if this node has a red parent. |
RedBlackTree<ELTTYPE> |
remove(ELTTYPE c)
Remove an value "equals to" the indicated value. |
java.lang.String |
toString()
Returns string representation of red-black tree. |
java.lang.String |
treeString()
Returns a string representing the tree rooted at this node. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final RedBlackTree EMPTY
| Constructor Detail |
|---|
public RedBlackTree(ELTTYPE v)
value - A (possibly null) value to be referenced by node| Method Detail |
|---|
public boolean isLeftChild()
public boolean isRightChild()
public boolean isEmpty()
public int depth()
public RedBlackTree<ELTTYPE> add(ELTTYPE c)
c - The value to be added to the tree.
public void redFixup()
public RedBlackTree<ELTTYPE> remove(ELTTYPE c)
val - Value sought to be removed from tree
public boolean contains(ELTTYPE c)
val - The value sought. Should be non-null
public ELTTYPE get(ELTTYPE c)
c - The c-equivalent value we are looking for in the tree.public boolean consistency()
public void print()
public java.util.Iterator<ELTTYPE> iterator()
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String treeString()
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 | |||||||