All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gnu.trove.strategy.IdentityHashingStrategy Maven / Gradle / Ivy

Go to download

The Trove library provides high speed regular and primitive collections for Java.

The newest version!
package gnu.trove.strategy;

/**
 * A {@link gnu.trove.strategy.HashingStrategy} that does identity comparisons
 * (==) and uses {@link System#identityHashCode(Object)} for hashCode generation.
 */
public class IdentityHashingStrategy implements HashingStrategy {
	static final long serialVersionUID = -5188534454583764904L;


    /**
     * A single instance that can be shared with multiple collections.
     * This instance is thread safe.
     */
    public static final IdentityHashingStrategy INSTANCE =
        new IdentityHashingStrategy();


	public int computeHashCode( K object ) {
		return System.identityHashCode( object );
	}

	public boolean equals( K o1, K o2 ) {
		return o1 == o2;
	}
}