本文整理了Java中com.google.common.hash.HashCode.hashCode()
方法的一些代码示例,展示了HashCode.hashCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashCode.hashCode()
方法的具体详情如下:
包路径:com.google.common.hash.HashCode
类名称:HashCode
方法名:hashCode
[英]Returns a "Java hash code" for this HashCode instance; this is well-defined (so, for example, you can safely put HashCode instances into a HashSet) but is otherwise probably not what you want to use.
[中]返回此哈希代码实例的“Java哈希代码”;这是定义良好的(例如,您可以安全地将HashCode实例放入HashSet),但在其他方面可能不是您想要使用的。
代码示例来源:origin: apache/incubator-druid
@Override
public int hashCode()
{
int result = dimension.hashCode();
result = 31 * result + (hash != null ? hash.hashCode() : 0);
result = 31 * result + (extractionFn != null ? extractionFn.hashCode() : 0);
return result;
}
}
代码示例来源:origin: google/guava
public void testObjectHashCode() {
HashCode hashCode42 = HashCode.fromInt(42);
assertEquals(42, hashCode42.hashCode());
}
代码示例来源:origin: google/guava
public void testObjectHashCodeWithSameLowOrderBytes() {
// These will have the same first 4 bytes (all 0).
byte[] bytesA = new byte[5];
byte[] bytesB = new byte[5];
// Change only the last (5th) byte
bytesA[4] = (byte) 0xbe;
bytesB[4] = (byte) 0xef;
HashCode hashCodeA = HashCode.fromBytes(bytesA);
HashCode hashCodeB = HashCode.fromBytes(bytesB);
// They aren't equal...
assertFalse(hashCodeA.equals(hashCodeB));
// But they still have the same Object#hashCode() value.
// Technically not a violation of the equals/hashCode contract, but...?
assertEquals(hashCodeA.hashCode(), hashCodeB.hashCode());
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
@Override
public boolean acceptOffset(long offset) {
int hashValue = Math.abs(strategy == DequeueStrategy.HASH ? 0 : ROUND_ROBIN_HASHER.hashLong(offset).hashCode());
return instanceId == (hashValue % groupSize);
}
};
代码示例来源:origin: org.apache.marmotta/kiwi-tripletable
@Override
public int hashCode() {
ensureHashCode();
return goodHashCode.hashCode();
}
}
代码示例来源:origin: conveyal/r5
/**
* FIXME why is this a long when crc32 returns an int?
* @return a checksum of the graph, for use in verifying whether it changed or remained the same after
* some operation.
*/
public long checksum () {
LOG.info("Calculating transport network checksum...");
try {
File tempFile = File.createTempFile("r5-network-checksum-", ".dat");
tempFile.deleteOnExit();
KryoNetworkSerializer.write(this, tempFile);
HashCode crc32 = Files.hash(tempFile, Hashing.crc32());
tempFile.delete();
LOG.info("Network CRC is {}", crc32.hashCode());
return crc32.hashCode();
} catch (IOException e) {
throw new RuntimeException();
}
}
代码示例来源:origin: com.conveyal/r5
/**
* FIXME why is this a long when crc32 returns an int?
* @return a checksum of the graph, for use in verifying whether it changed or remained the same after
* some operation.
*/
public long checksum () {
LOG.info("Calculating transport network checksum...");
try {
File tempFile = File.createTempFile("r5-network-checksum-", ".dat");
tempFile.deleteOnExit();
KryoNetworkSerializer.write(this, tempFile);
HashCode crc32 = Files.hash(tempFile, Hashing.crc32());
tempFile.delete();
LOG.info("Network CRC is {}", crc32.hashCode());
return crc32.hashCode();
} catch (IOException e) {
throw new RuntimeException();
}
}
代码示例来源:origin: theotherp/nzbhydra2
@Override
public int hashCode() {
return Hashing.md5().newHasher().putInt(a).putChar('.').putInt(b).putChar('.').putInt(c)
.putChar('.').putInt(d).hash().hashCode();
}
代码示例来源:origin: fengyouchao/sockslib
@Override
public int hashCode() {
return Hashing.md5().newHasher().putInt(a).putChar('.').putInt(b).putChar('.').putInt(c)
.putChar('.').putInt(d).hash().hashCode();
}
代码示例来源:origin: com.google.guava/guava-tests
public void testObjectHashCode() {
HashCode hashCode42 = HashCode.fromInt(42);
assertEquals(42, hashCode42.hashCode());
}
代码示例来源:origin: com.google.guava/guava-tests
public void testObjectHashCodeWithSameLowOrderBytes() {
// These will have the same first 4 bytes (all 0).
byte[] bytesA = new byte[5];
byte[] bytesB = new byte[5];
// Change only the last (5th) byte
bytesA[4] = (byte) 0xbe;
bytesB[4] = (byte) 0xef;
HashCode hashCodeA = HashCode.fromBytes(bytesA);
HashCode hashCodeB = HashCode.fromBytes(bytesB);
// They aren't equal...
assertFalse(hashCodeA.equals(hashCodeB));
// But they still have the same Object#hashCode() value.
// Technically not a violation of the equals/hashCode contract, but...?
assertEquals(hashCodeA.hashCode(), hashCodeB.hashCode());
}
内容来源于网络,如有侵权,请联系作者删除!