KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > trove > TObjectIdentityHashingStrategy


1 // Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
2

3 package gnu.trove;
4
5 /**
6  * This object hashing strategy uses the System.identityHashCode
7  * method to provide identity hash codes. These are identical to the
8  * value produced by Object.hashCode(), even when the type of the
9  * object being hashed overrides that method.
10  *
11  * Created: Sat Aug 17 11:13:15 2002
12  *
13  * @author Eric Friedman
14  * @version $Id: TObjectIdentityHashingStrategy.java,v 1.3 2006/11/10 23:27:56 robeden Exp $
15  */

16
17 public final class TObjectIdentityHashingStrategy<T> implements TObjectHashingStrategy<T> {
18     /**
19      * Delegates hash code computation to the System.identityHashCode(Object) method.
20      *
21      * @param object for which the hashcode is to be computed
22      * @return the hashCode
23      */

24     public final int computeHashCode(T object) {
25         return System.identityHashCode(object);
26     }
27
28     /**
29      * Compares object references for equality.
30      *
31      * @param o1 an <code>Object</code> value
32      * @param o2 an <code>Object</code> value
33      * @return true if o1 == o2
34      */

35     public final boolean equals(T o1, T o2) {
36         return o1 == o2;
37     }
38 } // TObjectIdentityHashingStrategy
39
Popular Tags