public Collection<Set<E>> allNonTrivialEquivalenceClasses() {
	Relation<E,E> relRepr2Elems = new MapSetRelation<E,E>();
	for (E elem : elmap.keySet()) {
	    E repr = find(elem);
	    relRepr2Elems.add(repr, elem);
	}
	List<Set<E>> result = new LinkedList<Set<E>>();
	for(E repr : relRepr2Elems.keys()) {
	    Set<E> equivClass = relRepr2Elems.getValues(repr);
	    // skip the trivial, 1-element equivalence classes
	    if(equivClass.size() > 1) {
		result.add(relRepr2Elems.getValues(repr));
	    }
	}
	return Collections.unmodifiableList(result);
    }
public Collection < Set < E > > allNonTrivialEquivalenceClasses ( ) { Relation < E , E > relRepr2Elems = new MapSetRelation < E , E > ( ) ; for ( E elem : elmap . keySet ( ) ) { E repr = find ( elem ) ; relRepr2Elems . add ( repr , elem ) ; } List < Set < E > > result = new LinkedList < Set < E > > ( ) ; for ( E repr : relRepr2Elems . keys ( ) ) { Set < E > equivClass = relRepr2Elems . getValues ( repr ) ; if ( equivClass . size ( ) > 1 ) { result . add ( relRepr2Elems . getValues ( repr ) ) ; } } return Collections . unmodifiableList ( result ) ; }
Returns an unmodifiable collection containing all equivalence
classes with more than one element.  Each equivalence class is
represented as an unmodifiable set that contains all elements
from that class.  The reason we return only equivalence
classes with more than one element is that this structure does
not know about the elements of your universe of discourse that
have not been unified with anyone yet: it knows only about the
elements that have been unified already.

<p> This method is quite slow: its execution time is at least
linear in the size of the underlying forest.  Hence, it has a
long, inconvenient name!

<p><strong>Note:</strong> The returned collection is in fact a
set, but maintaining it as a (hash-)set, with the associated
.equals on sets would be too expensive.