- All Superinterfaces:
- All Known Implementing Classes:
- IntegerHashComparator, ObjectHashComparator
- public interface HashComparator
- extends EqualityComparator
This interface provides a way of mapping any object in a set
to an integer, for purposes of implementing hash tables. It is up
to individual implementations to define the set over which they are
valid and to reject those objects which they cannot convert by
throwing ClassCastExceptions. This interface can be trivially
implemented with a call to Object.hashCode(), but it also allows
separation of the hashing criterion from the object itself,
when that is necessary.
- $Id: HashComparator.java,v 1.3 2000/01/12 03:21:29 mdh Exp $
- Luca Vismara
Returns the hash code value to be used for the object in this
public int hashValue(java.lang.Object obj)
- Returns the hash code value to be used for the object in this
It is expected that hashValue will return a non-negative integer
as the hashcode of the Object, as is the custom for hashcodes.
However, there are no unsigned types to force this.
obj - an object acting as a key in a hash table
- the hash code value of obj
java.lang.ClassCastException - if the obj is not a member of the
set over which the comparator is defined.