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 $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 @DocsEditable() | 7 @DocsEditable() |
8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS implements
Rectangle$IMPLEMENTS { | 8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS implements
Rectangle$IMPLEMENTS { |
9 | 9 |
10 // NOTE! All code below should be common with RectangleBase. | 10 // NOTE! All code below should be common with RectangleBase. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 Point get topLeft => new Point(this.left, this.top); | 92 Point get topLeft => new Point(this.left, this.top); |
93 Point get topRight => new Point(this.left + this.width, this.top); | 93 Point get topRight => new Point(this.left + this.width, this.top); |
94 Point get bottomRight => new Point(this.left + this.width, | 94 Point get bottomRight => new Point(this.left + this.width, |
95 this.top + this.height); | 95 this.top + this.height); |
96 Point get bottomLeft => new Point(this.left, | 96 Point get bottomLeft => new Point(this.left, |
97 this.top + this.height); | 97 this.top + this.height); |
98 | 98 |
99 $!MEMBERS} | 99 $!MEMBERS} |
100 | 100 |
101 /** | |
102 * This is the [Jenkins hash function][1] but using masking to keep | |
103 * values in SMI range. | |
104 * | |
105 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function | |
106 * | |
107 * Use: | |
108 * Hash each value with the hash of the previous value, then get the final | |
109 * hash by calling finish. | |
110 * | |
111 * var hash = 0; | |
112 * for (var value in values) { | |
113 * hash = JenkinsSmiHash.combine(hash, value.hashCode); | |
114 * } | |
115 * hash = JenkinsSmiHash.finish(hash); | |
116 */ | |
117 class _JenkinsSmiHash { | |
118 // TODO(11617): This class should be optimized and standardized elsewhere. | |
119 | |
120 static int combine(int hash, int value) { | |
121 hash = 0x1fffffff & (hash + value); | |
122 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); | |
123 return hash ^ (hash >> 6); | |
124 } | |
125 | |
126 static int finish(int hash) { | |
127 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | |
128 hash = hash ^ (hash >> 11); | |
129 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | |
130 } | |
131 | |
132 static int hash2(a, b) => finish(combine(combine(0, a), b)); | |
133 | |
134 static int hash4(a, b, c, d) => | |
135 finish(combine(combine(combine(combine(0, a), b), c), d)); | |
136 } | |
OLD | NEW |