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

Unified Diff: runtime/lib/array.dart

Issue 10827293: Reapply 'Add reduce to Collection.' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add fixes. Created 8 years, 4 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
Index: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index 9980d5da6ff4edbf18a0b52a7de3afc0ead7cf5e..15d3219910bbda047ca532167fd348aac57f197b 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -88,6 +88,11 @@ class ObjectArray<E> implements List<E> {
return Collections.map(this, new GrowableObjectArray.withCapacity(length), f);
}
+ Dynamic reduce(Dynamic initialValue,
Ivan Posva 2012/08/30 00:24:42 "Using Dynamic as type is bad style."™ Srdjan is
+ Dynamic combine(Dynamic previousValue, E element)) {
+ return Collections.reduce(this, initialValue, combine);
+ }
+
Collection<E> filter(bool f(E element)) {
return Collections.filter(this, new GrowableObjectArray<E>(), f);
}
@@ -220,6 +225,11 @@ class ImmutableArray<E> implements List<E> {
return Collections.map(this, new GrowableObjectArray.withCapacity(length), f);
}
+ Dynamic reduce(Dynamic initialValue,
+ Dynamic combine(Dynamic previousValue, E element)) {
+ return Collections.reduce(this, initialValue, combine);
+ }
+
Collection<E> filter(bool f(E element)) {
return Collections.filter(this, new GrowableObjectArray<E>(), f);
}

Powered by Google App Engine
This is Rietveld 408576698