|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgoldman.partition.UnionFindNode<T>
public class UnionFindNode<T>
The UnionFindNode class provides an implementation of the PartitionElement ADT using the union-find data structure.
Constructor Summary | |
---|---|
UnionFindNode(T data)
It creates a new component holding a single union-find node associated with the given application data. |
Method Summary | |
---|---|
UnionFindNode<T> |
findRepresentative()
Returns the representative element for the component that includes this partition element. |
T |
get()
Returns the data associated with this partition element. |
boolean |
sameComponent(PartitionElement<T> x)
Returns true if and only if this partition element and x are in the same component. |
void |
set(T data)
Resets the application data to the given value. |
String |
toString()
|
PartitionElement<T> |
union(PartitionElement<T> x)
Combines the components of x and
this partition element into one component
If x and the node on which this method is called are in
the same component then no change is made, and the root of their component is returned. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnionFindNode(T data)
data
- the application data,Method Detail |
---|
public String toString()
toString
in interface PartitionElement<T>
toString
in class Object
public T get()
PartitionElement
get
in interface PartitionElement<T>
public void set(T data)
set
in interface PartitionElement<T>
data
- the new value for the
application datapublic UnionFindNode<T> findRepresentative()
PartitionElement
findRepresentative
in interface PartitionElement<T>
public boolean sameComponent(PartitionElement<T> x)
PartitionElement
x
are in the same component.
sameComponent
in interface PartitionElement<T>
x
- a union-find node,
x
and the node on which this method is called are in the same
component.public PartitionElement<T> union(PartitionElement<T> x)
x
and
this partition element into one component
If x
and the node on which this method is called are in
the same component then no change is made, and the root of their component is returned.
union
in interface PartitionElement<T>
x
- a node whose component is to be
combined with the component of this partition element.
IllegalArgumentException
- x
is not a union-find node
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |