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

Unified Diff: pkg/collection_helpers/lib/equality.dart

Issue 54183010: Fix type variables for pkg/collection_helpers unordered equality. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/collection_helpers/lib/equality.dart
diff --git a/pkg/collection_helpers/lib/equality.dart b/pkg/collection_helpers/lib/equality.dart
index 433eb5b52dc02a3a338a7a9e4b0d7702054f33dc..3b5f3b4b133d3af345c805b8fb0059655aa05dee 100644
--- a/pkg/collection_helpers/lib/equality.dart
+++ b/pkg/collection_helpers/lib/equality.dart
@@ -151,7 +151,8 @@ class ListEquality<E> implements Equality<List<E>> {
bool isValidKey(Object o) => o is List<E>;
}
-abstract class _UnorderedEquality<T> implements Equality<T> {
+abstract class _UnorderedEquality<E, T extends Iterable<E>>
+ implements Equality<T> {
final Equality<E> _elementEquality;
const _UnorderedEquality(this._elementEquality);
@@ -181,7 +182,7 @@ abstract class _UnorderedEquality<T> implements Equality<T> {
int hash(T e) {
int hash = 0;
- for (var element in e) {
+ for (E element in e) {
int c = _elementEquality.hash(element);
hash = (hash + c) & _HASH_MASK;
}
@@ -199,7 +200,7 @@ abstract class _UnorderedEquality<T> implements Equality<T> {
* and the elements of one set can be paired with the elements
* of the other iterable, so that each pair are equal.
*/
-class UnorderedIterableEquality<E> extends _UnorderedEquality<Iterable<E>> {
+class UnorderedIterableEquality<E> extends _UnorderedEquality<E, Iterable<E>> {
const UnorderedIterableEquality(
[Equality<E> elementEquality = const DefaultEquality()])
: super(elementEquality);
@@ -217,7 +218,7 @@ class UnorderedIterableEquality<E> extends _UnorderedEquality<Iterable<E>> {
* This equality behaves the same as [UnorderedIterableEquality] except that
* it expects sets instead of iterables as arguments.
*/
-class SetEquality<E> extends _UnorderedEquality<Set<E>> {
+class SetEquality<E> extends _UnorderedEquality<E, Set<E>> {
const SetEquality(
[Equality<E> elementEquality = const DefaultEquality()])
: super(elementEquality);
« 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