~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/library/scala/runtime/Statics.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package scala.runtime;
 
2
 
 
3
/** Not for public consumption.  Usage by the runtime only.
 
4
 */
 
5
 
 
6
public final class Statics {
 
7
  public static int mix(int hash, int data) {
 
8
    int h = mixLast(hash, data);
 
9
    h = Integer.rotateLeft(h, 13);
 
10
    return h * 5 + 0xe6546b64;
 
11
  }
 
12
 
 
13
  public static int mixLast(int hash, int data) {
 
14
    int k = data;
 
15
 
 
16
    k *= 0xcc9e2d51;
 
17
    k = Integer.rotateLeft(k, 15);
 
18
    k *= 0x1b873593;
 
19
 
 
20
    return hash ^ k;
 
21
  }
 
22
 
 
23
  public static int finalizeHash(int hash, int length) {
 
24
    return avalanche(hash ^ length);
 
25
  }
 
26
 
 
27
  /** Force all bits of the hash to avalanche. Used for finalizing the hash. */
 
28
  public static int avalanche(int h) {
 
29
    h ^= h >>> 16;
 
30
    h *= 0x85ebca6b;
 
31
    h ^= h >>> 13;
 
32
    h *= 0xc2b2ae35;
 
33
    h ^= h >>> 16;
 
34
 
 
35
    return h;
 
36
  }
 
37
 
 
38
  public static int longHash(long lv) {
 
39
    if ((int)lv == lv)
 
40
      return (int)lv;
 
41
    else
 
42
      return (int)(lv ^ (lv >>> 32));
 
43
  }
 
44
 
 
45
  public static int doubleHash(double dv) {
 
46
    int iv = (int)dv;
 
47
    if (iv == dv)
 
48
      return iv;
 
49
 
 
50
    float fv = (float)dv;
 
51
    if (fv == dv)
 
52
      return java.lang.Float.floatToIntBits(fv);
 
53
 
 
54
    long lv = (long)dv;
 
55
    if (lv == dv)
 
56
      return (int)lv;
 
57
 
 
58
    lv = Double.doubleToLongBits(dv);
 
59
    return (int)(lv ^ (lv >>> 32));
 
60
  }
 
61
 
 
62
  public static int floatHash(float fv) {
 
63
    int iv = (int)fv;
 
64
    if (iv == fv)
 
65
      return iv;
 
66
 
 
67
    long lv = (long)fv;
 
68
    if (lv == fv)
 
69
      return (int)(lv^(lv>>>32));
 
70
 
 
71
    return java.lang.Float.floatToIntBits(fv);
 
72
  }
 
73
 
 
74
  public static int anyHash(Object x) {
 
75
    if (x == null)
 
76
      return 0;
 
77
 
 
78
    if (x instanceof java.lang.Long)
 
79
      return longHash(((java.lang.Long)x).longValue());
 
80
 
 
81
    if (x instanceof java.lang.Double)
 
82
      return doubleHash(((java.lang.Double)x).doubleValue());
 
83
 
 
84
    if (x instanceof java.lang.Float)
 
85
      return floatHash(((java.lang.Float)x).floatValue());
 
86
 
 
87
    return x.hashCode();
 
88
  }
 
89
}