OLD | NEW |
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 Loading... |
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. |
OLD | NEW |