as is without express or implied warranty. Export of this
software outside of the United States of America may require an
export license.
$Id: Equivalence.ig.html,v 1.2 2009-06-26 16:32:18 wagner Exp $
GENERIC INTERFACEEquivalence (Elem);
A T represents an equivalence relation on the set of all Elem.Ts.
A newly created Default has each Elem.T in its own equivalence
class.
Interface Elem is expected to have the following declaration:
PROCEDURE Equal(e1, e2: Elem.T): BOOLEAN;
which defines the a priori equality of two elements.
The Default implementation (union-find with path compression using
hash tables) also expects an ElemElemTbl.
TYPE
T = OBJECT METHODS
equal(e1, e2: Elem.T): BOOLEAN;
aree1ande2members of the same equivalence class?
identify(e1, e2: Elem.T): BOOLEAN;
join the two equivalence classes represented bye1ande2. returnTRUEiff they are already equal.
canon(e: Elem.T): Elem.T;
return the canonical representative of the class containing e.
iterate(): Iterator;
For each element which is not its own canonical representative, obtain that element asalias, and its canonical representative ascanon.
END;
Iterator = OBJECT METHODS
next(VAR alias, canon: Elem.T): BOOLEAN;
END;
Default <: T OBJECT METHODS
init(sizeHint: CARDINAL := 0;
leaderPreference: Preference := NIL): Default;
END;
Preference = OBJECT METHODS
is(thisBetter, thanThis: Elem.T): BOOLEAN;
END;
END Equivalence.