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

Side by Side Diff: runtime/lib/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/bin/vmstats/bargraph.dart ('k') | runtime/lib/growable_array.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 5
6 // TODO(srdjan): Use shared array implementation. 6 // TODO(srdjan): Use shared array implementation.
7 class _ObjectArray<E> implements List<E> { 7 class _ObjectArray<E> implements List<E> {
8 8
9 factory _ObjectArray(length) native "ObjectArray_allocate"; 9 factory _ObjectArray(length) native "ObjectArray_allocate";
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 Iterable map(f(E element)) { 113 Iterable map(f(E element)) {
114 return IterableMixinWorkaround.mapList(this, f); 114 return IterableMixinWorkaround.mapList(this, f);
115 } 115 }
116 116
117 reduce(initialValue, combine(previousValue, E element)) { 117 reduce(initialValue, combine(previousValue, E element)) {
118 return IterableMixinWorkaround.reduce(this, initialValue, combine); 118 return IterableMixinWorkaround.reduce(this, initialValue, combine);
119 } 119 }
120 120
121 fold(initialValue, combine(previousValue, E element)) {
122 return IterableMixinWorkaround.fold(this, initialValue, combine);
123 }
124
121 Iterable<E> where(bool f(E element)) { 125 Iterable<E> where(bool f(E element)) {
122 return IterableMixinWorkaround.where(this, f); 126 return IterableMixinWorkaround.where(this, f);
123 } 127 }
124 128
125 Iterable expand(Iterable f(E element)) { 129 Iterable expand(Iterable f(E element)) {
126 return IterableMixinWorkaround.expand(this, f); 130 return IterableMixinWorkaround.expand(this, f);
127 } 131 }
128 132
129 Iterable<E> take(int n) { 133 Iterable<E> take(int n) {
130 return IterableMixinWorkaround.takeList(this, n); 134 return IterableMixinWorkaround.takeList(this, n);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 358 }
355 359
356 String join([String separator]) { 360 String join([String separator]) {
357 return IterableMixinWorkaround.joinList(this, separator); 361 return IterableMixinWorkaround.joinList(this, separator);
358 } 362 }
359 363
360 reduce(initialValue, combine(previousValue, E element)) { 364 reduce(initialValue, combine(previousValue, E element)) {
361 return IterableMixinWorkaround.reduce(this, initialValue, combine); 365 return IterableMixinWorkaround.reduce(this, initialValue, combine);
362 } 366 }
363 367
368 fold(initialValue, combine(previousValue, E element)) {
369 return IterableMixinWorkaround.fold(this, initialValue, combine);
370 }
371
364 Iterable<E> where(bool f(E element)) { 372 Iterable<E> where(bool f(E element)) {
365 return IterableMixinWorkaround.where(this, f); 373 return IterableMixinWorkaround.where(this, f);
366 } 374 }
367 375
368 Iterable expand(Iterable f(E element)) { 376 Iterable expand(Iterable f(E element)) {
369 return IterableMixinWorkaround.expand(this, f); 377 return IterableMixinWorkaround.expand(this, f);
370 } 378 }
371 379
372 Iterable<E> take(int n) { 380 Iterable<E> take(int n) {
373 return IterableMixinWorkaround.takeList(this, n); 381 return IterableMixinWorkaround.takeList(this, n);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 525 }
518 _position = _length; 526 _position = _length;
519 _current = null; 527 _current = null;
520 return false; 528 return false;
521 } 529 }
522 530
523 E get current { 531 E get current {
524 return _current; 532 return _current;
525 } 533 }
526 } 534 }
OLDNEW
« no previous file with comments | « runtime/bin/vmstats/bargraph.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698