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

Side by Side Diff: pkg/collection_helpers/lib/equality.dart

Issue 37003004: Fix equality type problem. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | no next file » | 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 /** 5 /**
6 * Defines equality relations on collections. 6 * Defines equality relations on collections.
7 */ 7 */
8 library dart.collection_helper.equality; 8 library dart.collection_helper.equality;
9 9
10 import "dart:collection"; 10 import "dart:collection";
(...skipping 29 matching lines...) Expand all
40 */ 40 */
41 bool isValidKey(Object o); 41 bool isValidKey(Object o);
42 } 42 }
43 43
44 /** 44 /**
45 * Equality of objects that compares only the natural equality of the objects. 45 * Equality of objects that compares only the natural equality of the objects.
46 * 46 *
47 * This equality uses the objects' own [Object.==] and [Object.hashCode] for 47 * This equality uses the objects' own [Object.==] and [Object.hashCode] for
48 * the equality. 48 * the equality.
49 */ 49 */
50 class DefaultEquality implements Equality<Object> { 50 class DefaultEquality implements Equality {
51 const DefaultEquality(); 51 const DefaultEquality();
52 bool equals(Object e1, Object e2) => e1 == e2; 52 bool equals(Object e1, Object e2) => e1 == e2;
53 int hash(Object e) => e.hashCode; 53 int hash(Object e) => e.hashCode;
54 bool isValidKey(Object o) => true; 54 bool isValidKey(Object o) => true;
55 } 55 }
56 56
57 /** 57 /**
58 * Equality of objects that compares only the identity of the objects. 58 * Equality of objects that compares only the identity of the objects.
59 */ 59 */
60 class IdentityEquality implements Equality<Object> { 60 class IdentityEquality implements Equality {
61 const IdentityEquality(); 61 const IdentityEquality();
62 bool equals(Object e1, Object e2) => identical(e1, e2); 62 bool equals(Object e1, Object e2) => identical(e1, e2);
63 int hash(Object e) => identityHashCode(e); 63 int hash(Object e) => identityHashCode(e);
64 bool isValidKey(Object o) => true; 64 bool isValidKey(Object o) => true;
65 } 65 }
66 66
67 /** 67 /**
68 * Equality on iterables. 68 * Equality on iterables.
69 * 69 *
70 * Two iterables are equal if they have the same elements in the same order. 70 * Two iterables are equal if they have the same elements in the same order.
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (o is List) return new ListEquality(this).hash(o); 410 if (o is List) return new ListEquality(this).hash(o);
411 if (o is Iterable) return new IterableEquality(this).hash(o); 411 if (o is Iterable) return new IterableEquality(this).hash(o);
412 } else if (o is Iterable) { 412 } else if (o is Iterable) {
413 return new UnorderedIterableEquality(this).hash(o); 413 return new UnorderedIterableEquality(this).hash(o);
414 } 414 }
415 return _base.hash(o); 415 return _base.hash(o);
416 } 416 }
417 417
418 bool isValidKey(Object o) => o is Iterable || o is Map || _base.isValidKey(o); 418 bool isValidKey(Object o) => o is Iterable || o is Map || _base.isValidKey(o);
419 } 419 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698