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

Side by Side Diff: tools/dom/templates/immutable_list_mixin.darttemplate

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 | « tools/dom/templates/html/impl/impl_Node.darttemplate ('k') | utils/pub/io.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 // -- start List<$E> mixins. 1 // -- start List<$E> mixins.
2 // $E is the element type. 2 // $E is the element type.
3 3
4 // From Iterable<$E>: 4 // From Iterable<$E>:
5 5
6 Iterator<$E> get iterator { 6 Iterator<$E> get iterator {
7 // Note: NodeLists are not fixed size. And most probably length shouldn't 7 // Note: NodeLists are not fixed size. And most probably length shouldn't
8 // be cached in both iterator _and_ forEach method. For now caching it 8 // be cached in both iterator _and_ forEach method. For now caching it
9 // for consistency. 9 // for consistency.
10 return new FixedSizeListIterator<$E>(this); 10 return new FixedSizeListIterator<$E>(this);
11 } 11 }
12 12
13 $if DEFINE_LENGTH_AS_NUM_ITEMS 13 $if DEFINE_LENGTH_AS_NUM_ITEMS
14 // SVG Collections expose numberOfItems rather than length. 14 // SVG Collections expose numberOfItems rather than length.
15 int get length => numberOfItems; 15 int get length => numberOfItems;
16 $endif 16 $endif
17 dynamic reduce(dynamic initialValue, dynamic combine(dynamic, $E)) { 17 dynamic reduce(dynamic initialValue, dynamic combine(dynamic, $E)) {
18 return IterableMixinWorkaround.reduce(this, initialValue, combine); 18 return IterableMixinWorkaround.reduce(this, initialValue, combine);
19 } 19 }
20 20
21 dynamic fold(dynamic initialValue, dynamic combine(dynamic, $E)) {
22 return IterableMixinWorkaround.fold(this, initialValue, combine);
23 }
24
21 $if DEFINE_CONTAINS 25 $if DEFINE_CONTAINS
22 bool contains($E element) => IterableMixinWorkaround.contains(this, element); 26 bool contains($E element) => IterableMixinWorkaround.contains(this, element);
23 $else 27 $else
24 // contains() defined by IDL. 28 // contains() defined by IDL.
25 $endif 29 $endif
26 30
27 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f); 31 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f);
28 32
29 String join([String separator]) => 33 String join([String separator]) =>
30 IterableMixinWorkaround.joinList(this, separator); 34 IterableMixinWorkaround.joinList(this, separator);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return Lists.getRange(this, start, end, <$E>[]); 193 return Lists.getRange(this, start, end, <$E>[]);
190 } 194 }
191 195
192 List<$E> getRange(int start, int rangeLength) => 196 List<$E> getRange(int start, int rangeLength) =>
193 sublist(start, start + rangeLength); 197 sublist(start, start + rangeLength);
194 198
195 Map<int, $E> asMap() => 199 Map<int, $E> asMap() =>
196 IterableMixinWorkaround.asMapList(this); 200 IterableMixinWorkaround.asMapList(this);
197 201
198 // -- end List<$E> mixins. 202 // -- end List<$E> mixins.
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Node.darttemplate ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698