1 // Copyright (c) 2002, Eric D. Friedman All Rights Reserved. 2 3 package gnu.trove; 4 5 import java.io.Serializable; 6 7 /** 8 * Interface to support pluggable hashing strategies in maps and sets. 9 * Implementors can use this interface to make the trove hashing 10 * algorithms use object values, values provided by the java runtime, 11 * or a custom strategy when computing hashcodes. 12 * 13 * Created: Sat Aug 17 10:52:32 2002 14 * 15 * @author Eric Friedman 16 * @version $Id: TObjectHashingStrategy.java,v 1.2 2006/11/10 23:27:56 robeden Exp $ 17 */ 18 19 public interface TObjectHashingStrategy<T> extends Serializable { 20 21 /** 22 * Computes a hash code for the specified object. Implementors 23 * can use the object's own <tt>hashCode</tt> method, the Java 24 * runtime's <tt>identityHashCode</tt>, or a custom scheme. 25 * 26 * @param object for which the hashcode is to be computed 27 * @return the hashCode 28 */ 29 int computeHashCode(T object); 30 31 /** 32 * Compares o1 and o2 for equality. Strategy implementors may use 33 * the objects' own equals() methods, compare object references, 34 * or implement some custom scheme. 35 * 36 * @param o1 an <code>Object</code> value 37 * @param o2 an <code>Object</code> value 38 * @return true if the objects are equal according to this strategy. 39 */ 40 boolean equals(T o1, T o2); 41 } // TObjectHashingStrategy 42