org.deri.iris.utils.equivalence
Class TermEquivalence

java.lang.Object
  extended by org.deri.iris.utils.equivalence.TermEquivalence
All Implemented Interfaces:
IEquivalentTerms

public class TermEquivalence
extends Object
implements IEquivalentTerms

An utility class to define equivalence between terms. Uses the disjoint-set data structure.

Author:
Adrian Marte
See Also:
DisjointSets

Constructor Summary
TermEquivalence()
          Creates a new term equivalence relation.
 
Method Summary
 boolean areEquivalent(ITerm x, ITerm y)
          Checks if the specified terms are equivalent.
 boolean equals(Object obj)
           
 ITerm findRepresentative(ITerm term)
          Returns a representative term for the specified terms.
 Set<ITerm> getEquivalent(ITerm term)
          Returns the set of terms which are equivalent to the specified term.
 int hashCode()
           
 void setEquivalent(ITerm x, ITerm y)
          Defines the specified terms as equivalent.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TermEquivalence

public TermEquivalence()
Creates a new term equivalence relation.

Method Detail

areEquivalent

public boolean areEquivalent(ITerm x,
                             ITerm y)
Description copied from interface: IEquivalentTerms
Checks if the specified terms are equivalent.

Specified by:
areEquivalent in interface IEquivalentTerms
Parameters:
x - The first term.
y - The second term.
Returns:
true if the two given terms are equivalent, false otherwise.

setEquivalent

public void setEquivalent(ITerm x,
                          ITerm y)
Description copied from interface: IEquivalentTerms
Defines the specified terms as equivalent.

Specified by:
setEquivalent in interface IEquivalentTerms
Parameters:
x - The first term.
y - The second term.

findRepresentative

public ITerm findRepresentative(ITerm term)
Description copied from interface: IEquivalentTerms
Returns a representative term for the specified terms. If two terms are equivalent, they have the same representative term.

Specified by:
findRepresentative in interface IEquivalentTerms
Parameters:
term - The term.
Returns:
The representative term for the specified term.

getEquivalent

public Set<ITerm> getEquivalent(ITerm term)
Description copied from interface: IEquivalentTerms
Returns the set of terms which are equivalent to the specified term. The set also contains the term itself.

Specified by:
getEquivalent in interface IEquivalentTerms
Parameters:
term - The term.
Returns:
The set of terms which are equivalent to the specified term. The set also contains the term itself.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object