Package gnu.trove.strategy
Class IdentityHashingStrategy<K>
- java.lang.Object
-
- gnu.trove.strategy.IdentityHashingStrategy<K>
-
- All Implemented Interfaces:
HashingStrategy<K>,java.io.Serializable
public class IdentityHashingStrategy<K> extends java.lang.Object implements HashingStrategy<K>
AHashingStrategythat does identity comparisons (==) and usesSystem.identityHashCode(Object)for hashCode generation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static IdentityHashingStrategy<java.lang.Object>INSTANCEA single instance that can be shared with multiple collections.
-
Constructor Summary
Constructors Constructor Description IdentityHashingStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcomputeHashCode(K object)Computes a hash code for the specified object.booleanequals(K o1, K o2)Compares o1 and o2 for equality.
-
-
-
Field Detail
-
INSTANCE
public static final IdentityHashingStrategy<java.lang.Object> INSTANCE
A single instance that can be shared with multiple collections. This instance is thread safe.
-
-
Method Detail
-
computeHashCode
public int computeHashCode(K object)
Description copied from interface:HashingStrategyComputes a hash code for the specified object. Implementers can use the object's own hashCode method, the Java runtime's identityHashCode, or a custom scheme.- Specified by:
computeHashCodein interfaceHashingStrategy<K>- Parameters:
object- for which the hashcode is to be computed- Returns:
- the hashCode
-
equals
public boolean equals(K o1, K o2)
Description copied from interface:HashingStrategyCompares o1 and o2 for equality. Strategy implementers may use the objects' own equals() methods, compare object references, or implement some custom scheme.- Specified by:
equalsin interfaceHashingStrategy<K>- Parameters:
o1- anObjectvalueo2- anObjectvalue- Returns:
- true if the objects are equal according to this strategy.
-
-