Constructor and Description |
---|
QuickUnion(int num)
Creates a new QuickUnion object, for num elements; it initializes it to
num singleton sets
|
Modifier and Type | Method and Description |
---|---|
UnionFind |
create(int num)
Creates a new object of the same implementation as this, with universe of dimension size
|
int |
find(int i)
Returns the name of the leader of the set containing i
|
int |
getNumberOfSets()
Returns the number of sets so far
|
java.lang.String |
toString() |
void |
union(int rappresentanteA,
int rappresentanteB)
Merges the sets containing a and b, if they are different; does nothing if a and b belong to the same set.
|
public QuickUnion(int num)
num
- the universe sizepublic UnionFind create(int num)
UnionFind
public void union(int rappresentanteA, int rappresentanteB)
UnionFind
public int find(int i)
UnionFind
public int getNumberOfSets()
UnionFind
getNumberOfSets
in interface UnionFind
public java.lang.String toString()
toString
in class java.lang.Object