agl2.util
Class UnionFind

java.lang.Object
  |
  +--agl2.util.UnionFind
All Implemented Interfaces:
java.io.Serializable

public class UnionFind
extends java.lang.Object
implements java.io.Serializable

The UnionFind Discjoint Set code with some set interfaces

See Also:
Serialized Form

Constructor Summary
UnionFind()
          Creates a DisjointSet.
 
Method Summary
 boolean contains(java.lang.Object o)
          Determines if there is a set of more than one element containing o.
 java.lang.Object find(java.lang.Object o)
          Returns the representative of the (unique) set containing o.
 java.util.Set members(java.lang.Object o)
           
 boolean sameSet(java.lang.Object element1, java.lang.Object element2)
           
 java.lang.String toString()
           
 void union(java.lang.Object o1, java.lang.Object o2)
          Unites the dynamic sets that contain o1 and o2, say S1 and S2, into a new set that is the union of these two sets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnionFind

public UnionFind()
Creates a DisjointSet.

Method Detail

union

public void union(java.lang.Object o1,
                  java.lang.Object o2)
Unites the dynamic sets that contain o1 and o2, say S1 and S2, into a new set that is the union of these two sets. The two sets are assumed to be disjoint prior to the operation. The representative of the resulting set is the representative of either S1 or S2; if both S1 and S2 were previously singletons, the representative of S1 union S2 is the representative of S2.


find

public java.lang.Object find(java.lang.Object o)
Returns the representative of the (unique) set containing o.


contains

public boolean contains(java.lang.Object o)
Determines if there is a set of more than one element containing o.


sameSet

public boolean sameSet(java.lang.Object element1,
                       java.lang.Object element2)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

members

public java.util.Set members(java.lang.Object o)