Class DisjointSets
- java.lang.Object
-
- soot.jimple.spark.ondemand.genericutil.DisjointSets
-
public final class DisjointSets extends Object
-
-
Constructor Summary
Constructors Constructor Description DisjointSets(int numElements)Construct a disjoint sets object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfind(int x)find() finds the (int) name of the set containing a given element.voidunion(int root1, int root2)union() unites two disjoint sets into a single set.
-
-
-
Method Detail
-
union
public void union(int root1, int root2)union() unites two disjoint sets into a single set. A union-by-size heuristic is used to choose the new root. This method will corrupt the data structure if root1 and root2 are not roots of their respective sets, or if they're identical.- Parameters:
root1- the root of the first set.root2- the root of the other set.
-
find
public int find(int x)
find() finds the (int) name of the set containing a given element. Performs path compression along the way.- Parameters:
x- the element sought.- Returns:
- the set containing x.
-
-