|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jdsl.RBTree
A Red Black tree. Implemented using a RestructurableNodeBinaryTree.
| Constructor Summary | |
RBTree(Comparator comparator)
The class's constructor. |
|
| Method Summary | |
Locator |
after(Locator locator)
Finds the locator after the passed in Locator. |
Locator |
before(Locator locator)
Finds the locator before the passed in Locator |
protected void |
case1(Position sibling)
take care of case 1 after deletion: sib is red |
protected void |
case2(Position child)
|
protected Position |
case3(Position sibling)
|
protected void |
case4(Position position)
|
Locator |
closestAfter(java.lang.Object key)
Finds the Locator that comes right after a Locator with the given key |
Locator |
closestBefore(java.lang.Object key)
Finds the Locator that comes right before a Locator with the given key in the tree. |
protected void |
colorPromotion(Position parent)
handy color promotion method.....promotes the red up |
Comparator |
comparator()
Retrieves the Comparator. |
java.util.Iterator |
elements()
Produces an Iterator of the elements of all the Locators in the tree |
Locator |
find(java.lang.Object key)
Finds the Locator with the given key |
java.util.Iterator |
findAll(java.lang.Object key)
Finds all of the locators in the tree with the given key |
Position |
findInSubtree(java.lang.Object key,
Position subtreeRoot)
a helper method that will return the position is key is found or the position where the key would be (i.e. |
protected RBColorInfo |
getCInfo()
|
BinaryTree |
getTree()
Returns the underlying tree. |
void |
insert(Locator locator)
Inserts a locator into the tree. |
Locator |
insert(java.lang.Object key,
java.lang.Object element)
Inserts a new key element pair into the tree. |
boolean |
isEmpty()
|
java.util.Iterator |
keys()
Returns an Iterator of all the keys within this Container. |
java.util.Iterator |
locators()
Returns an iterator of colors |
Locator |
makeLocator(java.lang.Object key,
java.lang.Object element)
Produces a Locator that is ready to be inserted. |
Container |
newContainer()
|
protected void |
recolor(Position root)
|
protected void |
recolorAfterRemove(Position child)
|
void |
remove(Locator locator)
|
java.lang.Object |
replaceElement(Locator loc,
java.lang.Object newElement)
Replaces the element of the passed in locator |
java.lang.Object |
replaceKey(Locator locator,
java.lang.Object key)
Replaces the key of the passed in locator |
protected Position |
rotation(Position grandchild)
silly method that just calls restructure on the restructurable BT |
Comparator |
setComparator(Comparator c)
Sets the Comparator to be used in this container. |
int |
size()
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public RBTree(Comparator comparator)
RBTLocator which is black.comparator - the comparator for this dictionary| Method Detail |
public Comparator comparator()
Comparator.Comparator that is used by this
PriorityQueue.
public Locator find(java.lang.Object key)
throws InvalidKeyException
key - The search key.
public java.util.Iterator findAll(java.lang.Object key)
throws InvalidKeyException
key - The search key.Iterator of the found locators
public Locator closestBefore(java.lang.Object key)
throws InvalidKeyException
key - The key to search forLocator if it exists.
public Locator closestAfter(java.lang.Object key)
throws InvalidKeyException
key - The key of the Locator to find the closestAfterLocator if it exists
public Locator after(Locator locator)
throws InvalidLocatorException
locator - Locator after locator, or BOUNDARY_VIOLATION
if it doesn't exist.
public Locator before(Locator locator)
throws InvalidLocatorException
locator - Locator before locator, or BOUNDARY_VIOLATION
if it doesn't exist.
public Position findInSubtree(java.lang.Object key,
Position subtreeRoot)
throws InvalidKeyException
key - The search key.subtreeRoot - Where the search will start.Position
public void insert(Locator locator)
throws InvalidKeyException,
InvalidLocatorException,
ContainedLocatorException
locator - The Locator to insert.
public Locator insert(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException,
ContainedLocatorException
locator - The Locator to insert.
public void remove(Locator locator)
throws InvalidLocatorException
protected void recolorAfterRemove(Position child)
protected void case1(Position sibling)
protected void case2(Position child)
protected Position case3(Position sibling)
protected void case4(Position position)
public java.lang.Object replaceKey(Locator locator,
java.lang.Object key)
throws InvalidLocatorException,
InvalidKeyException
locator - The Locator whose key will be replaced.key - The new key
public java.lang.Object replaceElement(Locator loc,
java.lang.Object newElement)
throws InvalidLocatorException
locator - The Locator whose element will be replaced.newElement - The new elementprotected void colorPromotion(Position parent)
parent - The position to promoteprotected Position rotation(Position grandchild)
grandchild - The position to rotateprotected void recolor(Position root)
public java.util.Iterator locators()
public java.util.Iterator keys()
Iterator is returned.elements,
Iterator
public Locator makeLocator(java.lang.Object key,
java.lang.Object element)
key - The new Locator's key.element - The new Locator's element.Locatorpublic java.util.Iterator elements()
Iteratorpublic Container newContainer()
public int size()
public boolean isEmpty()
public BinaryTree getTree()
protected RBColorInfo getCInfo()
public Comparator setComparator(Comparator c)
c - The comparator to use.Comparator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||