本文整理了Java中com.google.common.hash.HashCode.fromLong()
方法的一些代码示例,展示了HashCode.fromLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashCode.fromLong()
方法的具体详情如下:
包路径:com.google.common.hash.HashCode
类名称:HashCode
方法名:fromLong
[英]Creates a 64-bit HashCode representation of the given long value. The underlying bytes are interpreted in little endian order.
[中]创建给定长值的64位哈希代码表示形式。底层字节以小的尾数顺序进行解释。
代码示例来源:origin: google/guava
@Override
public HashCode hash() {
long value = checksum.getValue();
if (bits == 32) {
/*
* The long returned from a 32-bit Checksum will have all 0s for its second word, so the
* cast won't lose any information and is necessary to return a HashCode of the correct
* size.
*/
return HashCode.fromInt((int) value);
} else {
return HashCode.fromLong(value);
}
}
}
代码示例来源:origin: google/guava
@Override
public HashCode makeHash() {
// End with a byte encoding the positive integer b mod 256.
finalM ^= b << 56;
processM(finalM);
// Finalization
v2 ^= 0xFFL;
sipRound(d);
return HashCode.fromLong(v0 ^ v1 ^ v2 ^ v3);
}
代码示例来源:origin: google/guava
@Override
public HashCode hashBytes(byte[] input, int off, int len) {
checkPositionIndexes(off, off + len, input.length);
return HashCode.fromLong(fingerprint(input, off, len));
}
代码示例来源:origin: google/j2objc
@Override
public HashCode hash() {
long value = checksum.getValue();
if (bits == 32) {
/*
* The long returned from a 32-bit Checksum will have all 0s for its second word, so the
* cast won't lose any information and is necessary to return a HashCode of the correct
* size.
*/
return HashCode.fromInt((int) value);
} else {
return HashCode.fromLong(value);
}
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public HashCode hash() {
long value = checksum.getValue();
if (bits == 32) {
/*
* The long returned from a 32-bit Checksum will have all 0s for its second word, so the
* cast won't lose any information and is necessary to return a HashCode of the correct
* size.
*/
return HashCode.fromInt((int) value);
} else {
return HashCode.fromLong(value);
}
}
}
代码示例来源:origin: google/guava
public void testFromLong() {
for (ExpectedHashCode expected : expectedHashCodes) {
if (expected.bytes.length == 8) {
HashCode fromLong = HashCode.fromLong(expected.asLong);
assertExpectedHashCode(expected, fromLong);
}
}
}
代码示例来源:origin: google/guava
public void testLongWriteBytesTo() {
byte[] dest = new byte[8];
HashCode.fromLong(42).writeBytesTo(dest, 0, 8);
assertTrue(Arrays.equals(HashCode.fromLong(42).asBytes(), dest));
}
代码示例来源:origin: google/j2objc
@Override
public HashCode makeHash() {
// End with a byte encoding the positive integer b mod 256.
finalM ^= b << 56;
processM(finalM);
// Finalization
v2 ^= 0xFFL;
sipRound(d);
return HashCode.fromLong(v0 ^ v1 ^ v2 ^ v3);
}
代码示例来源:origin: google/j2objc
@Override
public HashCode hashBytes(byte[] input, int off, int len) {
checkPositionIndexes(off, off + len, input.length);
return HashCode.fromLong(fingerprint(input, off, len));
}
代码示例来源:origin: wildfly/wildfly
@Override
public HashCode makeHash() {
// End with a byte encoding the positive integer b mod 256.
finalM ^= b << 56;
processM(finalM);
// Finalization
v2 ^= 0xFFL;
sipRound(d);
return HashCode.fromLong(v0 ^ v1 ^ v2 ^ v3);
}
代码示例来源:origin: wildfly/wildfly
@Override
public HashCode hashBytes(byte[] input, int off, int len) {
checkPositionIndexes(off, off + len, input.length);
return HashCode.fromLong(fingerprint(input, off, len));
}
代码示例来源:origin: google/guava
public void testCombineUnordered_randomHashCodes() {
Random random = new Random(RANDOM_SEED);
List<HashCode> hashCodes = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
hashCodes.add(HashCode.fromLong(random.nextLong()));
}
HashCode hashCode1 = Hashing.combineUnordered(hashCodes);
Collections.shuffle(hashCodes);
HashCode hashCode2 = Hashing.combineUnordered(hashCodes);
assertEquals(hashCode1, hashCode2);
}
代码示例来源:origin: google/guava
public void testCombineOrdered_randomHashCodes() {
Random random = new Random(7);
List<HashCode> hashCodes = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
hashCodes.add(HashCode.fromLong(random.nextLong()));
}
HashCode hashCode1 = Hashing.combineOrdered(hashCodes);
Collections.shuffle(hashCodes, random);
HashCode hashCode2 = Hashing.combineOrdered(hashCodes);
assertFalse(hashCode1.equals(hashCode2));
}
代码示例来源:origin: google/guava
public void testConsistentHash_ofHashCode() {
checkSameResult(HashCode.fromLong(1), 1);
checkSameResult(HashCode.fromLong(0x9999999999999999L), 0x9999999999999999L);
checkSameResult(HashCode.fromInt(0x99999999), 0x0000000099999999L);
}
代码示例来源:origin: google/guava
public void testCombineUnordered_differentBitLengths() {
try {
HashCode unused =
Hashing.combineUnordered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
fail();
} catch (IllegalArgumentException expected) {
}
}
代码示例来源:origin: google/guava
public void testCombineOrdered_differentBitLengths() {
try {
HashCode unused =
Hashing.combineOrdered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
fail();
} catch (IllegalArgumentException expected) {
}
}
代码示例来源:origin: google/guava
public void testNullPointers() {
NullPointerTester tester =
new NullPointerTester()
.setDefault(byte[].class, "secret key".getBytes(UTF_8))
.setDefault(HashCode.class, HashCode.fromLong(0));
tester.testAllPublicStaticMethods(Hashing.class);
}
代码示例来源:origin: google/guava
public void testPadToLong() {
assertEquals(0x1111111111111111L, HashCode.fromLong(0x1111111111111111L).padToLong());
assertEquals(0x9999999999999999L, HashCode.fromLong(0x9999999999999999L).padToLong());
assertEquals(0x0000000011111111L, HashCode.fromInt(0x11111111).padToLong());
assertEquals(0x0000000099999999L, HashCode.fromInt(0x99999999).padToLong());
}
代码示例来源:origin: omero/common
@Override
public byte[] checksumAsBytes() {
isChecksumCalculated = true;
/* use Guava hash code to match the other algorithms */
return HashCode.fromLong(size).asBytes();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override public HashCode makeHash() {
// End with a byte encoding the positive integer b mod 256.
finalM ^= b << 56;
processM(finalM);
// Finalization
v2 ^= 0xFFL;
sipRound(d);
return HashCode.fromLong(v0 ^ v1 ^ v2 ^ v3);
}
内容来源于网络,如有侵权,请联系作者删除!