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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 Iterable<$E> takeWhile(bool test($E value)) { | 54 Iterable<$E> takeWhile(bool test($E value)) { |
55 return IterableMixinWorkaround.takeWhile(this, test); | 55 return IterableMixinWorkaround.takeWhile(this, test); |
56 } | 56 } |
57 | 57 |
58 Iterable<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); | 58 Iterable<$E> skip(int n) => IterableMixinWorkaround.skipList(this, n); |
59 | 59 |
60 Iterable<$E> skipWhile(bool test($E value)) { | 60 Iterable<$E> skipWhile(bool test($E value)) { |
61 return IterableMixinWorkaround.skipWhile(this, test); | 61 return IterableMixinWorkaround.skipWhile(this, test); |
62 } | 62 } |
63 | 63 |
64 $E firstMatching(bool test($E value), { $E orElse() }) { | 64 $E firstWhere(bool test($E value), { $E orElse() }) { |
65 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 65 return IterableMixinWorkaround.firstWhere(this, test, orElse); |
66 } | 66 } |
67 | 67 |
68 $E lastMatching(bool test($E value), {$E orElse()}) { | 68 $E lastWhere(bool test($E value), {$E orElse()}) { |
69 return IterableMixinWorkaround.lastMatchingInList(this, test, orElse); | 69 return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
70 } | 70 } |
71 | 71 |
72 $E singleMatching(bool test($E value)) { | 72 $E singleWhere(bool test($E value)) { |
73 return IterableMixinWorkaround.singleMatching(this, test); | 73 return IterableMixinWorkaround.singleWhere(this, test); |
74 } | 74 } |
75 | 75 |
76 $E elementAt(int index) { | 76 $E elementAt(int index) { |
77 return this[index]; | 77 return this[index]; |
78 } | 78 } |
79 | 79 |
80 // From Collection<$E>: | 80 // From Collection<$E>: |
81 | 81 |
82 void add($E value) { | 82 void add($E value) { |
83 throw new UnsupportedError("Cannot add to immutable List."); | 83 throw new UnsupportedError("Cannot add to immutable List."); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 void removeAll(Iterable elements) { | 159 void removeAll(Iterable elements) { |
160 throw new UnsupportedError("Cannot remove from immutable List."); | 160 throw new UnsupportedError("Cannot remove from immutable List."); |
161 } | 161 } |
162 | 162 |
163 void retainAll(Iterable elements) { | 163 void retainAll(Iterable elements) { |
164 throw new UnsupportedError("Cannot remove from immutable List."); | 164 throw new UnsupportedError("Cannot remove from immutable List."); |
165 } | 165 } |
166 | 166 |
167 void removeMatching(bool test($E element)) { | 167 void removeWhere(bool test($E element)) { |
168 throw new UnsupportedError("Cannot remove from immutable List."); | 168 throw new UnsupportedError("Cannot remove from immutable List."); |
169 } | 169 } |
170 | 170 |
171 void retainMatching(bool test($E element)) { | 171 void retainWhere(bool test($E element)) { |
172 throw new UnsupportedError("Cannot remove from immutable List."); | 172 throw new UnsupportedError("Cannot remove from immutable List."); |
173 } | 173 } |
174 | 174 |
175 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { | 175 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { |
176 throw new UnsupportedError("Cannot setRange on immutable List."); | 176 throw new UnsupportedError("Cannot setRange on immutable List."); |
177 } | 177 } |
178 | 178 |
179 void removeRange(int start, int rangeLength) { | 179 void removeRange(int start, int rangeLength) { |
180 throw new UnsupportedError("Cannot removeRange on immutable List."); | 180 throw new UnsupportedError("Cannot removeRange on immutable List."); |
181 } | 181 } |
182 | 182 |
183 void insertRange(int start, int rangeLength, [$E initialValue]) { | 183 void insertRange(int start, int rangeLength, [$E initialValue]) { |
184 throw new UnsupportedError("Cannot insertRange on immutable List."); | 184 throw new UnsupportedError("Cannot insertRange on immutable List."); |
185 } | 185 } |
186 | 186 |
187 List<$E> getRange(int start, int rangeLength) => | 187 List<$E> getRange(int start, int rangeLength) => |
188 Lists.getRange(this, start, rangeLength, <$E>[]); | 188 Lists.getRange(this, start, rangeLength, <$E>[]); |
189 | 189 |
190 Map<int, $E> asMap() => | 190 Map<int, $E> asMap() => |
191 IterableMixinWorkaround.asMapList(this); | 191 IterableMixinWorkaround.asMapList(this); |
192 | 192 |
193 // -- end List<$E> mixins. | 193 // -- end List<$E> mixins. |
OLD | NEW |