package container; /** Used to compare keys for equality, just as java.util.Comparator * compares them for order. A hash function should also be defined * so that equal keys get the same hash code. * * An EqualityTester object might expect keys of a particular type. * Then its methods should throw a ClassCastException when given keys * of the wrong type. */ public interface EqualityTester { public boolean equal(Object a, Object b) throws ClassCastException; public int hash(Object a) throws ClassCastException; } // Note that these methods are NOT called equals() and hashCode(). // That's because an EqualityTester already has methods by those // names, inherited from Object. For instance, equals() tests whether // two EqualityTesters are equal -- which is not what we want!