Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: tools/dom/src/Point.dart

Issue 18034021: Fixing analyzer warnings on overloading == but not get hashCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/rect_test.dart ('k') | tools/dom/src/Rectangle.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 html; 5 part of html;
6 6
7 /** 7 /**
8 * A utility class for representing two-dimensional positions. 8 * A utility class for representing two-dimensional positions.
9 */ 9 */
10 class Point { 10 class Point {
11 final num x; 11 final num x;
12 final num y; 12 final num y;
13 13
14 const Point([num x = 0, num y = 0]): x = x, y = y; 14 const Point([num x = 0, num y = 0]): x = x, y = y;
15 15
16 String toString() => '($x, $y)'; 16 String toString() => '($x, $y)';
17 17
18 bool operator ==(other) { 18 bool operator ==(other) {
19 if (other is !Point) return false; 19 if (other is !Point) return false;
20 return x == other.x && y == other.y; 20 return x == other.x && y == other.y;
21 } 21 }
22 22
23 int get hashCode => JenkinsSmiHash.hash2(x.hashCode, y.hashCode);
24
23 Point operator +(Point other) { 25 Point operator +(Point other) {
24 return new Point(x + other.x, y + other.y); 26 return new Point(x + other.x, y + other.y);
25 } 27 }
26 28
27 Point operator -(Point other) { 29 Point operator -(Point other) {
28 return new Point(x - other.x, y - other.y); 30 return new Point(x - other.x, y - other.y);
29 } 31 }
30 32
31 Point operator *(num factor) { 33 Point operator *(num factor) {
32 return new Point(x * factor, y * factor); 34 return new Point(x * factor, y * factor);
(...skipping 22 matching lines...) Expand all
55 57
56 Point ceil() => new Point(x.ceil(), y.ceil()); 58 Point ceil() => new Point(x.ceil(), y.ceil());
57 Point floor() => new Point(x.floor(), y.floor()); 59 Point floor() => new Point(x.floor(), y.floor());
58 Point round() => new Point(x.round(), y.round()); 60 Point round() => new Point(x.round(), y.round());
59 61
60 /** 62 /**
61 * Truncates x and y to integers and returns the result as a new point. 63 * Truncates x and y to integers and returns the result as a new point.
62 */ 64 */
63 Point toInt() => new Point(x.toInt(), y.toInt()); 65 Point toInt() => new Point(x.toInt(), y.toInt());
64 } 66 }
OLDNEW
« no previous file with comments | « tests/html/rect_test.dart ('k') | tools/dom/src/Rectangle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698