OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of "math.dart"; | 5 part of "dart:math"; |
6 | 6 |
7 /** | 7 /** |
8 * This is the [Jenkins hash function][1] but using masking to keep | 8 * This is the [Jenkins hash function][1] but using masking to keep |
9 * values in SMI range. | 9 * values in SMI range. |
10 * | 10 * |
11 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function | 11 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function |
12 * | 12 * |
13 * Use: | 13 * Use: |
14 * Hash each value with the hash of the previous value, then get the final | 14 * Hash each value with the hash of the previous value, then get the final |
15 * hash by calling finish. | 15 * hash by calling finish. |
(...skipping 17 matching lines...) Expand all Loading... |
33 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 33 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
34 hash = hash ^ (hash >> 11); | 34 hash = hash ^ (hash >> 11); |
35 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 35 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
36 } | 36 } |
37 | 37 |
38 static int hash2(a, b) => finish(combine(combine(0, a), b)); | 38 static int hash2(a, b) => finish(combine(combine(0, a), b)); |
39 | 39 |
40 static int hash4(a, b, c, d) => | 40 static int hash4(a, b, c, d) => |
41 finish(combine(combine(combine(combine(0, a), b), c), d)); | 41 finish(combine(combine(combine(combine(0, a), b), c), d)); |
42 } | 42 } |
OLD | NEW |