diff options
author | Paul Duffin <paulduffin@google.com> | 2015-01-19 12:46:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-19 12:46:40 +0000 |
commit | aab56800fcb95e9b1a2d653588b14158080cc6b4 (patch) | |
tree | 7365392c3ea77742021cf187acfd465f9bb774ab /guava/src/com/google/common/collect/Hashing.java | |
parent | 6fa98dbaae182b511fbeb331e08f5fb827715ea8 (diff) | |
parent | 84fb43aa6a1e752487f2624055ff26b1b6b7c043 (diff) | |
download | android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.gz android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.tar.bz2 android_external_guava-aab56800fcb95e9b1a2d653588b14158080cc6b4.zip |
am 84fb43aa: Merge "Revert "Upgraded Guava to unmodified v14.0.1""
* commit '84fb43aa6a1e752487f2624055ff26b1b6b7c043':
Revert "Upgraded Guava to unmodified v14.0.1"
Diffstat (limited to 'guava/src/com/google/common/collect/Hashing.java')
-rw-r--r-- | guava/src/com/google/common/collect/Hashing.java | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/guava/src/com/google/common/collect/Hashing.java b/guava/src/com/google/common/collect/Hashing.java index b13eb7c..9c5f6bc 100644 --- a/guava/src/com/google/common/collect/Hashing.java +++ b/guava/src/com/google/common/collect/Hashing.java @@ -17,50 +17,27 @@ package com.google.common.collect; import com.google.common.annotations.GwtCompatible; -import com.google.common.primitives.Ints; /** * Static methods for implementing hash-based collections. * * @author Kevin Bourrillion * @author Jesse Wilson - * @author Austin Appleby */ @GwtCompatible final class Hashing { private Hashing() {} - private static final int C1 = 0xcc9e2d51; - private static final int C2 = 0x1b873593; - /* - * This method was rewritten in Java from an intermediate step of the Murmur hash function in - * http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp, which contained the - * following header: - * - * MurmurHash3 was written by Austin Appleby, and is placed in the public domain. The author - * hereby disclaims copyright to this source code. + * This method was written by Doug Lea with assistance from members of JCP + * JSR-166 Expert Group and released to the public domain, as explained at + * http://creativecommons.org/licenses/publicdomain + * + * As of 2010/06/11, this method is identical to the (package private) hash + * method in OpenJDK 7's java.util.HashMap class. */ static int smear(int hashCode) { - return C2 * Integer.rotateLeft(hashCode * C1, 15); - } - - static int MAX_TABLE_SIZE = Ints.MAX_POWER_OF_TWO; - - static int closedTableSize(int expectedEntries, double loadFactor) { - // Get the recommended table size. - // Round down to the nearest power of 2. - expectedEntries = Math.max(expectedEntries, 2); - int tableSize = Integer.highestOneBit(expectedEntries); - // Check to make sure that we will not exceed the maximum load factor. - if ((double) expectedEntries / tableSize > loadFactor) { - tableSize <<= 1; - return (tableSize > 0) ? tableSize : MAX_TABLE_SIZE; - } - return tableSize; - } - - static boolean needsResizing(int size, int tableSize, double loadFactor) { - return size > loadFactor * tableSize && tableSize < MAX_TABLE_SIZE; + hashCode ^= (hashCode >>> 20) ^ (hashCode >>> 12); + return hashCode ^ (hashCode >>> 7) ^ (hashCode >>> 4); } } |