public class UnionFindWithSize extends UnionFind
array, size
Constructor and Description |
---|
UnionFindWithSize() |
Modifier and Type | Method and Description |
---|---|
int |
addElement()
Adds a new element to this union find structure and returns its index.
|
protected void |
connectToRepresentative(int element,
int representative)
Connects the given element (must also be representative) to the given
representative.
|
int |
getClusterSize(int element)
Returns the size of the union cluster containing the given element.
|
addArrayElement, addArrayElements
public UnionFindWithSize()
public int addElement()
addElement
in class UnionFind
protected void connectToRepresentative(int element, int representative)
connectToRepresentative
in class UnionFind
public int getClusterSize(int element)