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)
| 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 |
nothing calls this directly
no test coverage detected