public interface UnionFind
Modifier and Type | Method and Description |
---|---|
UnionFind |
create(int size)
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
|
void |
union(int a,
int b)
Merges the sets containing a and b, if they are different; does nothing if a and b belong to the same set.
|
UnionFind create(int size)
size
- the size of the universevoid union(int a, int b)
a
- first itemb
- second itemint find(int i)
i
- the item to be locatedint getNumberOfSets()