|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectweiss.nonstandard.DisjointSetsFast
public class DisjointSetsFast
Disjoint set class, using union by rank and path compression. Elements in the set are numbered starting at 0.
| Constructor Summary | |
|---|---|
DisjointSetsFast(int numElements)
Construct the disjoint sets object. |
|
| Method Summary | |
|---|---|
int |
find(int x)
Perform a find with path compression. |
static void |
main(java.lang.String[] args)
|
void |
union(int root1,
int root2)
Union two disjoint sets using the height heuristic. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DisjointSetsFast(int numElements)
numElements - the initial number of disjoint sets.| Method Detail |
|---|
public void union(int root1,
int root2)
root1 - the root of set 1.root2 - the root of set 2.
java.lang.IllegalArgumentException - if root1 or root2
are not distinct roots.public int find(int x)
x - the element being searched for.
java.lang.IllegalArgumentException - if x is not valid.public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||