package org.infinispan.distribution; /** * Use the objects built in hash to obtain an initial value, then * use a second four byte hash to obtain a more uniform distribution * of hash values. This uses a 4-byte (integer) * hash, which produces well distributed values even when the original * hash produces thghtly clustered values. * * It is important that the object impliment its own hashcode, * and not use the Object hashcode. * * @version $Rev: $, $Date: $ * @author akluge */ public class ReHash implements Hasher { public int hash(Object object) { int hash = object.hashCode(); hash = (hash + 0x7ED55D16) + (hash<<12); hash = (hash ^ 0xc761c23c) ^ (hash>>19); hash = (hash + 0x165667b1) + (hash<<5); hash = (hash + 0xd3a2646c) ^ (hash<<9); hash = (hash + 0xfd7046c5) + (hash<<3); hash = (hash ^ 0xb55a4f09) ^ (hash>>16); return hash; } }