|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.dillenco.datastruct.UnionFind<T>
public class UnionFind<T>
This class implements the standard union-find algorithm, with weight balancing and path compression
Constructor Summary | |
---|---|
UnionFind()
Construct an empty union-find structure with an expected capacity of 100. |
|
UnionFind(int size)
Construct an empty union-find structure with the given expected capacity. |
Method Summary | |
---|---|
void |
add(T data)
Add the given data item as a singleton set. |
T |
find(T data)
Return the label of the set containing the given data item. |
T |
merge(T data1,
T data2)
Merge the sets containing the two given data items. |
void |
reset()
Reset the structure so every element is in its own equivalent class. |
void |
setAsLabel(T data)
Set the indicated data item as the label (root) of its equivalence class. |
void |
verify()
Verify internal consistency of data structures. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnionFind()
public UnionFind(int size)
size
- the expected capacityMethod Detail |
---|
public void reset()
public void add(T data)
data
- the data item to be added.public T find(T data)
data
- the data item whose set label is to be returned.
public T merge(T data1, T data2)
IllegalArgumentException
is thrown.
data1
- the first data itemdata2
- the second data item
public void setAsLabel(T data)
data
- the data item to be made the label.public void verify()
IllegalArgumentException
is thrown.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |