01: ///////////////////////////////////////////////////////////////////////////////
02: // Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
03: //
04: // This library is free software; you can redistribute it and/or
05: // modify it under the terms of the GNU Lesser General Public
06: // License as published by the Free Software Foundation; either
07: // version 2.1 of the License, or (at your option) any later version.
08: //
09: // This library is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU Lesser General Public
15: // License along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: ///////////////////////////////////////////////////////////////////////////////
18:
19: package gnu.trove;
20:
21: /**
22: * This object hashing strategy uses the System.identityHashCode
23: * method to provide identity hash codes. These are identical to the
24: * value produced by Object.hashCode(), even when the type of the
25: * object being hashed overrides that method.
26: *
27: * Created: Sat Aug 17 11:13:15 2002
28: *
29: * @author Eric Friedman
30: * @version $Id: TObjectIdentityHashingStrategy.java,v 1.4 2007/06/11 15:26:44 robeden Exp $
31: */
32:
33: public final class TObjectIdentityHashingStrategy<T> implements
34: TObjectHashingStrategy<T> {
35: /**
36: * Delegates hash code computation to the System.identityHashCode(Object) method.
37: *
38: * @param object for which the hashcode is to be computed
39: * @return the hashCode
40: */
41: public final int computeHashCode(T object) {
42: return System.identityHashCode(object);
43: }
44:
45: /**
46: * Compares object references for equality.
47: *
48: * @param o1 an <code>Object</code> value
49: * @param o2 an <code>Object</code> value
50: * @return true if o1 == o2
51: */
52: public final boolean equals(T o1, T o2) {
53: return o1 == o2;
54: }
55: } // TObjectIdentityHashingStrategy
|