|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mhhe.clrs2e.DisjointSetForest
Disjoint-set forest implementation of disjoint-set union, as given on page 508 of Introduction to Algorithms, Second edition.
| Nested Class Summary | |
private static class |
DisjointSetForest.Node
Private inner class to serve as opaque handles. |
| Constructor Summary | |
DisjointSetForest()
|
|
| Method Summary | |
java.lang.Object |
findSet(java.lang.Object x)
Returns the object that serves as the representative of the set containing an object. |
private void |
link(DisjointSetForest.Node x,
DisjointSetForest.Node y)
Links together two sets, given their root nodes. |
java.lang.Object |
makeSet(java.lang.Object x)
Makes a singleton set containing an object. |
void |
union(java.lang.Object x,
java.lang.Object y)
Unites two sets, identified by handles to objects in the sets. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DisjointSetForest()
| Method Detail |
public java.lang.Object makeSet(java.lang.Object x)
makeSet in interface DisjointSetUnionx - The object in the singleton set.
public void union(java.lang.Object x,
java.lang.Object y)
union in interface DisjointSetUnionx - Handle to an object in one set.y - Handle to an object in the other set.
java.lang.ClassCastException - if either x or
y does not reference a Node object.public java.lang.Object findSet(java.lang.Object x)
findSet in interface DisjointSetUnionx - Handle to the object.
java.lang.ClassCastException - if x is not a reference
to a Node object.
private void link(DisjointSetForest.Node x,
DisjointSetForest.Node y)
x - The root node of one set.y - The root node of the other set.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||