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

Method combineOrdered

output/java_guava/1.4.19/Hashing.java:613–626  ·  view source on GitHub ↗

Returns a hash code, having the same bit length as each of the input hash codes, that combines the information of these hash codes in an ordered fashion. That is, whenever two equal hash codes are produced by two calls to this method, it is as likely as possible that each was computed from th

(Iterable<HashCode> hashCodes)

Source from the content-addressed store, hash-verified

611
612
613 public static HashCode combineOrdered(Iterable<HashCode> hashCodes) {
614 Iterator<HashCode> iterator = hashCodes.iterator();
615 checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine.");
616 int bits = iterator.next().bits();
617 byte[] resultBytes = new byte[bits / 8];
618 for (HashCode hashCode : hashCodes) {
619 byte[] nextBytes = hashCode.asBytes();
620 checkArgument(nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length.");
621 for (int i = 0; i < nextBytes.length; i++) {
622 resultBytes[i] = (byte) (resultBytes[i] * 37 ^ nextBytes[i]);
623 }
624 }
625 return HashCode.fromBytesNoCopy(resultBytes);
626 }
627
628 /**
629 * Returns a hash code, having the same bit length as each of the input hash codes, that combines

Callers

nothing calls this directly

Calls 7

fromBytesNoCopyMethod · 0.95
iteratorMethod · 0.65
bitsMethod · 0.65
nextMethod · 0.65
checkArgumentMethod · 0.45
hasNextMethod · 0.45
asBytesMethod · 0.45

Tested by

no test coverage detected