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); |
(...skipping 11 matching lines...) Expand all Loading... |
22 bool contains($E element) => IterableMixinWorkaround.contains(this, element); | 22 bool contains($E element) => IterableMixinWorkaround.contains(this, element); |
23 $else | 23 $else |
24 // contains() defined by IDL. | 24 // contains() defined by IDL. |
25 $endif | 25 $endif |
26 | 26 |
27 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f); | 27 void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f); |
28 | 28 |
29 String join([String separator]) => | 29 String join([String separator]) => |
30 IterableMixinWorkaround.joinList(this, separator); | 30 IterableMixinWorkaround.joinList(this, separator); |
31 | 31 |
32 Iterable map(f($E element)) => | 32 List mappedBy(f($E element)) => IterableMixinWorkaround.mappedByList(this, f); |
33 IterableMixinWorkaround.map(this, f); | |
34 | |
35 List mappedBy(f($E element)) => | |
36 IterableMixinWorkaround.mappedBy(this, f); | |
37 | 33 |
38 Iterable<$E> where(bool f($E element)) => | 34 Iterable<$E> where(bool f($E element)) => |
39 IterableMixinWorkaround.where(this, f); | 35 IterableMixinWorkaround.where(this, f); |
40 | 36 |
41 bool every(bool f($E element)) => IterableMixinWorkaround.every(this, f); | 37 bool every(bool f($E element)) => IterableMixinWorkaround.every(this, f); |
42 | 38 |
43 bool any(bool f($E element)) => IterableMixinWorkaround.any(this, f); | 39 bool any(bool f($E element)) => IterableMixinWorkaround.any(this, f); |
44 | 40 |
45 List<$E> toList() => new List<$E>.from(this); | 41 List<$E> toList() => new List<$E>.from(this); |
46 Set<$E> toSet() => new Set<$E>.from(this); | 42 Set<$E> toSet() => new Set<$E>.from(this); |
47 | 43 |
48 bool get isEmpty => this.length == 0; | 44 bool get isEmpty => this.length == 0; |
49 | 45 |
50 Iterable<$E> take(int n) => IterableMixinWorkaround.takeList(this, n); | 46 List<$E> take(int n) => IterableMixinWorkaround.takeList(this, n); |
51 | 47 |
52 Iterable<$E> takeWhile(bool test($E value)) { | 48 Iterable<$E> takeWhile(bool test($E value)) { |
53 return IterableMixinWorkaround.takeWhile(this, test); | 49 return IterableMixinWorkaround.takeWhile(this, test); |
54 } | 50 } |
55 | 51 |
56 Iterable<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); | 52 List<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); |
57 | 53 |
58 Iterable<$E> skipWhile(bool test($E value)) { | 54 Iterable<$E> skipWhile(bool test($E value)) { |
59 return IterableMixinWorkaround.skipWhile(this, test); | 55 return IterableMixinWorkaround.skipWhile(this, test); |
60 } | 56 } |
61 | 57 |
62 $E firstMatching(bool test($E value), { $E orElse() }) { | 58 $E firstMatching(bool test($E value), { $E orElse() }) { |
63 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 59 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
64 } | 60 } |
65 | 61 |
66 $E lastMatching(bool test($E value), {$E orElse()}) { | 62 $E lastMatching(bool test($E value), {$E orElse()}) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 175 } |
180 | 176 |
181 void insertRange(int start, int rangeLength, [$E initialValue]) { | 177 void insertRange(int start, int rangeLength, [$E initialValue]) { |
182 throw new UnsupportedError("Cannot insertRange on immutable List."); | 178 throw new UnsupportedError("Cannot insertRange on immutable List."); |
183 } | 179 } |
184 | 180 |
185 List<$E> getRange(int start, int rangeLength) => | 181 List<$E> getRange(int start, int rangeLength) => |
186 Lists.getRange(this, start, rangeLength, <$E>[]); | 182 Lists.getRange(this, start, rangeLength, <$E>[]); |
187 | 183 |
188 // -- end List<$E> mixins. | 184 // -- end List<$E> mixins. |
OLD | NEW |