1090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/*
21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2008 The Guava Authors
3090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
4090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Licensed under the Apache License, Version 2.0 (the "License");
5090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * you may not use this file except in compliance with the License.
6090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * You may obtain a copy of the License at
7090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
8090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0
9090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
10090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Unless required by applicable law or agreed to in writing, software
11090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
12090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * See the License for the specific language governing permissions and
14090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * limitations under the License.
15090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
16090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
17090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonpackage com.google.common.collect;
18090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
19090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonimport com.google.common.annotations.GwtCompatible;
20090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
21090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson/**
22090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * Static methods for implementing hash-based collections.
23090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson *
24090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Kevin Bourrillion
25090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson * @author Jesse Wilson
26090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson */
27090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson@GwtCompatible
28090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilsonfinal class Hashing {
29090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  private Hashing() {}
30090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson
31090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  /*
32090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * This method was written by Doug Lea with assistance from members of JCP
33090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * JSR-166 Expert Group and released to the public domain, as explained at
34090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   * http://creativecommons.org/licenses/publicdomain
351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   *
361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * As of 2010/06/11, this method is identical to the (package private) hash
371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * method in OpenJDK 7's java.util.HashMap class.
38090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson   */
39090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  static int smear(int hashCode) {
40090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    hashCode ^= (hashCode >>> 20) ^ (hashCode >>> 12);
41090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson    return hashCode ^ (hashCode >>> 7) ^ (hashCode >>> 4);
42090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson  }
43090f9b4c879985bc747c214f82c62471e60c7742Jesse Wilson}
44