public class UnionFind<T> extends Object
Constructor and Description |
---|
UnionFind(Set<T> elements)
Creates a UnionFind instance with all of the elements of elements in
seperate sets.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(T element)
Adds a new element to the data structure in its own set.
|
T |
find(T element)
Returns the representative element of the set that element is in.
|
protected Map<T,T> |
getParentMap() |
protected Map<T,Integer> |
getRankMap() |
void |
union(T element1,
T element2)
Merges the sets which contain element1 and element2.
|
public void addElement(T element)
element
- The element to add.public T find(T element)
element
- The element to find.Copyright © 2016. All rights reserved.