MCPcopy Create free account
hub / github.com/antlr/codebuff / hashCode

Method hashCode

output/java_guava/1.4.19/HashCode.java:405–421  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

403 */
404
405 @Override
406 public final int hashCode() {
407 // If we have at least 4 bytes (32 bits), just take the first 4 bytes. Since this is
408 // already a (presumably) high-quality hash code, any four bytes of it will do.
409 if (bits() >= 32) {
410 return asInt();
411 }
412 // If we have less than 4 bytes, use them all.
413
414
415 byte[] bytes = getBytesInternal();
416 int val = (bytes[0] & 0xFF);
417 for (int i = 1; i < bytes.length; i++) {
418 val |= ((bytes[i] & 0xFF) << (i * 8));
419 }
420 return val;
421 }
422
423 /**
424 * Returns a string containing each byte of {@link #asBytes}, in order, as a two-digit unsigned

Callers

nothing calls this directly

Calls 3

bitsMethod · 0.95
asIntMethod · 0.95
getBytesInternalMethod · 0.95

Tested by

no test coverage detected