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

Side by Side Diff: tools/dom/src/WrappedList.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 | « tools/dom/src/CssClassSet.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.dom.html; 5 part of dart.dom.html;
6 6
7 /** 7 /**
8 * A list which just wraps another list, for either intercepting list calls or 8 * A list which just wraps another list, for either intercepting list calls or
9 * retyping the list (for example, from List<A> to List<B> where B extends A). 9 * retyping the list (for example, from List<A> to List<B> where B extends A).
10 */ 10 */
(...skipping 12 matching lines...) Expand all
23 23
24 Iterable expand(Iterable f(E element)) => _list.expand(f); 24 Iterable expand(Iterable f(E element)) => _list.expand(f);
25 25
26 bool contains(E element) => _list.contains(element); 26 bool contains(E element) => _list.contains(element);
27 27
28 void forEach(void f(E element)) { _list.forEach(f); } 28 void forEach(void f(E element)) { _list.forEach(f); }
29 29
30 dynamic reduce(initialValue, combine(previousValue, E element)) => 30 dynamic reduce(initialValue, combine(previousValue, E element)) =>
31 _list.reduce(initialValue, combine); 31 _list.reduce(initialValue, combine);
32 32
33 dynamic fold(initialValue, combine(previousValue, E element)) =>
34 _list.fold(initialValue, combine);
35
33 bool every(bool f(E element)) => _list.every(f); 36 bool every(bool f(E element)) => _list.every(f);
34 37
35 String join([String separator]) => _list.join(separator); 38 String join([String separator]) => _list.join(separator);
36 39
37 bool any(bool f(E element)) => _list.any(f); 40 bool any(bool f(E element)) => _list.any(f);
38 41
39 List<E> toList({ bool growable: true }) => 42 List<E> toList({ bool growable: true }) =>
40 new List.from(_list, growable: growable); 43 new List.from(_list, growable: growable);
41 44
42 Set<E> toSet() => _list.toSet(); 45 Set<E> toSet() => _list.toSet();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Iterator _iterator; 140 Iterator _iterator;
138 141
139 _WrappedIterator(this._iterator); 142 _WrappedIterator(this._iterator);
140 143
141 bool moveNext() { 144 bool moveNext() {
142 return _iterator.moveNext(); 145 return _iterator.moveNext();
143 } 146 }
144 147
145 E get current => _iterator.current; 148 E get current => _iterator.current;
146 } 149 }
OLDNEW
« no previous file with comments | « tools/dom/src/CssClassSet.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698