本文整理了Java中com.google.protobuf.Internal.partialHash()
方法的一些代码示例,展示了Internal.partialHash()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Internal.partialHash()
方法的具体详情如下:
包路径:com.google.protobuf.Internal
类名称:Internal
方法名:partialHash
[英]Helper method for continuously hashing bytes.
[中]用于连续散列字节的助手方法。
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* Helper method for implementing {@link LiteralByteString#hashCode()}.
*/
static int hashCode(byte[] bytes, int offset, int length) {
// The hash code for a byte array should be the same as the hash code for a
// ByteString with the same content. This is to ensure that the generated
// hashCode() method will return the same value as the pure reflection
// based hashCode() method.
int h = Internal.partialHash(length, bytes, offset, length);
return h == 0 ? 1 : h;
}
代码示例来源:origin: com.google.protobuf/protobuf-java
@Override
protected final int partialHash(int h, int offset, int length) {
return Internal.partialHash(h, bytes, getOffsetIntoBytes() + offset, length);
}
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* Helper method for implementing {@link Message#hashCode()} for bytes
* field.
*/
public static int hashCodeByteBuffer(ByteBuffer bytes) {
if (bytes.hasArray()) {
// Fast path.
int h = partialHash(bytes.capacity(), bytes.array(), bytes.arrayOffset(), bytes.capacity());
return h == 0 ? 1 : h;
} else {
// Read the data into a temporary byte array before calculating the
// hash value.
final int bufferSize = bytes.capacity() > DEFAULT_BUFFER_SIZE
? DEFAULT_BUFFER_SIZE : bytes.capacity();
final byte[] buffer = new byte[bufferSize];
final ByteBuffer duplicated = bytes.duplicate();
duplicated.clear();
int h = bytes.capacity();
while (duplicated.remaining() > 0) {
final int length = duplicated.remaining() <= bufferSize ?
duplicated.remaining() : bufferSize;
duplicated.get(buffer, 0, length);
h = partialHash(h, buffer, 0, length);
}
return h == 0 ? 1 : h;
}
}
代码示例来源:origin: com.google.protobuf/protobuf-lite
/**
* Helper method for implementing {@link LiteralByteString#hashCode()}.
*/
static int hashCode(byte[] bytes, int offset, int length) {
// The hash code for a byte array should be the same as the hash code for a
// ByteString with the same content. This is to ensure that the generated
// hashCode() method will return the same value as the pure reflection
// based hashCode() method.
int h = Internal.partialHash(length, bytes, offset, length);
return h == 0 ? 1 : h;
}
代码示例来源:origin: yeriomin/play-store-api
/**
* Helper method for implementing {@link LiteralByteString#hashCode()}.
*/
static int hashCode(byte[] bytes, int offset, int length) {
// The hash code for a byte array should be the same as the hash code for a
// ByteString with the same content. This is to ensure that the generated
// hashCode() method will return the same value as the pure reflection
// based hashCode() method.
int h = Internal.partialHash(length, bytes, offset, length);
return h == 0 ? 1 : h;
}
代码示例来源:origin: yeriomin/play-store-api
@Override
protected final int partialHash(int h, int offset, int length) {
return Internal.partialHash(h, bytes, getOffsetIntoBytes() + offset, length);
}
代码示例来源:origin: com.google.protobuf/protobuf-lite
@Override
protected final int partialHash(int h, int offset, int length) {
return Internal.partialHash(h, bytes, getOffsetIntoBytes() + offset, length);
}
代码示例来源:origin: com.google.protobuf/protobuf-lite
/**
* Helper method for implementing {@link Message#hashCode()} for bytes
* field.
*/
public static int hashCodeByteBuffer(ByteBuffer bytes) {
if (bytes.hasArray()) {
// Fast path.
int h = partialHash(bytes.capacity(), bytes.array(), bytes.arrayOffset(), bytes.capacity());
return h == 0 ? 1 : h;
} else {
// Read the data into a temporary byte array before calculating the
// hash value.
final int bufferSize = bytes.capacity() > DEFAULT_BUFFER_SIZE
? DEFAULT_BUFFER_SIZE : bytes.capacity();
final byte[] buffer = new byte[bufferSize];
final ByteBuffer duplicated = bytes.duplicate();
duplicated.clear();
int h = bytes.capacity();
while (duplicated.remaining() > 0) {
final int length = duplicated.remaining() <= bufferSize ?
duplicated.remaining() : bufferSize;
duplicated.get(buffer, 0, length);
h = partialHash(h, buffer, 0, length);
}
return h == 0 ? 1 : h;
}
}
代码示例来源:origin: yeriomin/play-store-api
/**
* Helper method for implementing {@link Message#hashCode()} for bytes
* field.
*/
public static int hashCodeByteBuffer(ByteBuffer bytes) {
if (bytes.hasArray()) {
// Fast path.
int h = partialHash(bytes.capacity(), bytes.array(), bytes.arrayOffset(), bytes.capacity());
return h == 0 ? 1 : h;
} else {
// Read the data into a temporary byte array before calculating the
// hash value.
final int bufferSize = bytes.capacity() > DEFAULT_BUFFER_SIZE
? DEFAULT_BUFFER_SIZE : bytes.capacity();
final byte[] buffer = new byte[bufferSize];
final ByteBuffer duplicated = bytes.duplicate();
duplicated.clear();
int h = bytes.capacity();
while (duplicated.remaining() > 0) {
final int length = duplicated.remaining() <= bufferSize ?
duplicated.remaining() : bufferSize;
duplicated.get(buffer, 0, length);
h = partialHash(h, buffer, 0, length);
}
return h == 0 ? 1 : h;
}
}
内容来源于网络,如有侵权,请联系作者删除!