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

Side by Side Diff: runtime/lib/growable_array.dart

Issue 13548002: Add Iterable.fold (and Stream.fold) which replace `reduce`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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 | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _GrowableObjectArray<T> implements List<T> { 5 class _GrowableObjectArray<T> implements List<T> {
6 factory _GrowableObjectArray._uninstantiable() { 6 factory _GrowableObjectArray._uninstantiable() {
7 throw new UnsupportedError( 7 throw new UnsupportedError(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 Iterable map(f(T element)) { 263 Iterable map(f(T element)) {
264 return IterableMixinWorkaround.mapList(this, f); 264 return IterableMixinWorkaround.mapList(this, f);
265 } 265 }
266 266
267 reduce(initialValue, combine(previousValue, T element)) { 267 reduce(initialValue, combine(previousValue, T element)) {
268 return IterableMixinWorkaround.reduce(this, initialValue, combine); 268 return IterableMixinWorkaround.reduce(this, initialValue, combine);
269 } 269 }
270 270
271 fold(initialValue, combine(previousValue, T element)) {
272 return IterableMixinWorkaround.fold(this, initialValue, combine);
273 }
274
271 Iterable<T> where(bool f(T element)) { 275 Iterable<T> where(bool f(T element)) {
272 return IterableMixinWorkaround.where(this, f); 276 return IterableMixinWorkaround.where(this, f);
273 } 277 }
274 278
275 Iterable expand(Iterable f(T element)) { 279 Iterable expand(Iterable f(T element)) {
276 return IterableMixinWorkaround.expand(this, f); 280 return IterableMixinWorkaround.expand(this, f);
277 } 281 }
278 282
279 Iterable<T> take(int n) { 283 Iterable<T> take(int n) {
280 return IterableMixinWorkaround.takeList(this, n); 284 return IterableMixinWorkaround.takeList(this, n);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 347 }
344 348
345 Set<T> toSet() { 349 Set<T> toSet() {
346 return new Set<T>.from(this); 350 return new Set<T>.from(this);
347 } 351 }
348 352
349 Map<int, T> asMap() { 353 Map<int, T> asMap() {
350 return IterableMixinWorkaround.asMapList(this); 354 return IterableMixinWorkaround.asMapList(this);
351 } 355 }
352 } 356 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698