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 unordered 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
(Iterable<HashCode> hashCodes)
| 637 | |
| 638 | |
| 639 | public static HashCode combineUnordered(Iterable<HashCode> hashCodes) { |
| 640 | Iterator<HashCode> iterator = hashCodes.iterator(); |
| 641 | checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine."); |
| 642 | |
| 643 | byte[] resultBytes = new byte[iterator.next().bits() / 8]; |
| 644 | for (HashCode hashCode : hashCodes) { |
| 645 | byte[] nextBytes = hashCode.asBytes(); |
| 646 | checkArgument(nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length."); |
| 647 | for (int i = 0; i < nextBytes.length; i++) { |
| 648 | resultBytes[i] += nextBytes[i]; |
| 649 | } |
| 650 | } |
| 651 | return HashCode.fromBytesNoCopy(resultBytes); |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Checks that the passed argument is positive, and ceils it to a multiple of 32. |
nothing calls this directly
no test coverage detected