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

Side by Side Diff: test/dart_codegen/expect/_internal/iterable.dart

Issue 963593002: Disable formatting and add new-lines to make tests faster. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 part of dart._internal; 1 part of dart._internal;
2 2 abstract class EfficientLength {int get length;
3 abstract class EfficientLength { 3 }
4 int get length; 4 abstract class ListIterable<E> extends IterableBase<E> implements EfficientLeng th {int get length;
5 } 5 E elementAt(int i);
6 abstract class ListIterable<E> extends IterableBase<E> 6 const ListIterable();
7 implements EfficientLength { 7 Iterator<E> get iterator => new ListIterator<E>(this);
8 int get length; 8 void forEach(void action(E element)) {
9 E elementAt(int i); 9 int length = this.length;
10 const ListIterable(); 10 for (int i = 0;
11 Iterator<E> get iterator => new ListIterator<E>(this); 11 i < length;
12 void forEach(void action(E element)) { 12 i++) {
13 int length = this.length; 13 action(elementAt(i));
14 for (int i = 0; i < length; i++) { 14 if (length != this.length) {
15 action(elementAt(i)); 15 throw new ConcurrentModificationError(this);
16 if (length != this.length) { 16 }
17 throw new ConcurrentModificationError(this); 17 }
18 }
19 bool get isEmpty => length == 0;
20 E get first {
21 if (length == 0) throw IterableElementError.noElement();
22 return elementAt(0);
23 }
24 E get last {
25 if (length == 0) throw IterableElementError.noElement();
26 return elementAt(length - 1);
27 }
28 E get single {
29 if (length == 0) throw IterableElementError.noElement();
30 if (length > 1) throw IterableElementError.tooMany();
31 return elementAt(0);
32 }
33 bool contains(Object element) {
34 int length = this.length;
35 for (int i = 0;
36 i < length;
37 i++) {
38 if (elementAt(i) == element) return true;
39 if (length != this.length) {
40 throw new ConcurrentModificationError(this);
41 }
42 }
43 return false;
44 }
45 bool every(bool test(E element)) {
46 int length = this.length;
47 for (int i = 0;
48 i < length;
49 i++) {
50 if (!test(elementAt(i))) return false;
51 if (length != this.length) {
52 throw new ConcurrentModificationError(this);
53 }
54 }
55 return true;
56 }
57 bool any(bool test(E element)) {
58 int length = this.length;
59 for (int i = 0;
60 i < length;
61 i++) {
62 if (test(elementAt(i))) return true;
63 if (length != this.length) {
64 throw new ConcurrentModificationError(this);
65 }
66 }
67 return false;
68 }
69 E firstWhere(bool test(E element), {
70 E orElse()}
71 ) {
72 int length = this.length;
73 for (int i = 0;
74 i < length;
75 i++) {
76 E element = elementAt(i);
77 if (test(element)) return element;
78 if (length != this.length) {
79 throw new ConcurrentModificationError(this);
80 }
81 }
82 if (orElse != null) return orElse();
83 throw IterableElementError.noElement();
84 }
85 E lastWhere(bool test(E element), {
86 E orElse()}
87 ) {
88 int length = this.length;
89 for (int i = length - 1;
90 i >= 0;
91 i--) {
92 E element = elementAt(i);
93 if (test(element)) return element;
94 if (length != this.length) {
95 throw new ConcurrentModificationError(this);
96 }
97 }
98 if (orElse != null) return orElse();
99 throw IterableElementError.noElement();
100 }
101 E singleWhere(bool test(E element)) {
102 int length = this.length;
103 E match = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", """line 125, col umn 15 of dart:_internal/iterable.dart: """, __x0 is E, false))(null);
104 bool matchFound = false;
105 for (int i = 0;
106 i < length;
107 i++) {
108 E element = elementAt(i);
109 if (test(element)) {
110 if (matchFound) {
111 throw IterableElementError.tooMany();
18 } 112 }
113 matchFound = true;
114 match = element;
19 } 115 }
20 } 116 if (length != this.length) {
21 bool get isEmpty => length == 0; 117 throw new ConcurrentModificationError(this);
22 E get first {
23 if (length == 0) throw IterableElementError.noElement();
24 return elementAt(0);
25 }
26 E get last {
27 if (length == 0) throw IterableElementError.noElement();
28 return elementAt(length - 1);
29 }
30 E get single {
31 if (length == 0) throw IterableElementError.noElement();
32 if (length > 1) throw IterableElementError.tooMany();
33 return elementAt(0);
34 }
35 bool contains(Object element) {
36 int length = this.length;
37 for (int i = 0; i < length; i++) {
38 if (elementAt(i) == element) return true;
39 if (length != this.length) {
40 throw new ConcurrentModificationError(this);
41 }
42 } 118 }
43 return false; 119 }
44 } 120 if (matchFound) return match;
45 bool every(bool test(E element)) { 121 throw IterableElementError.noElement();
46 int length = this.length; 122 }
47 for (int i = 0; i < length; i++) { 123 String join([String separator = ""]) {
48 if (!test(elementAt(i))) return false; 124 int length = this.length;
49 if (length != this.length) { 125 if (!separator.isEmpty) {
50 throw new ConcurrentModificationError(this); 126 if (length == 0) return "";
51 } 127 String first = "${elementAt(0)}
128 ";
Leaf 2015/02/26 21:42:14 This is a bad newline break.
129 if (length != this.length) {
130 throw new ConcurrentModificationError(this);
131 }
132 StringBuffer buffer = new StringBuffer(first);
133 for (int i = 1;
134 i < length;
135 i++) {
136 buffer.write(separator);
137 buffer.write(elementAt(i));
138 if (length != this.length) {
139 throw new ConcurrentModificationError(this);
52 } 140 }
53 return true; 141 }
54 } 142 return buffer.toString();
55 bool any(bool test(E element)) { 143 }
56 int length = this.length; 144 else {
57 for (int i = 0; i < length; i++) { 145 StringBuffer buffer = new StringBuffer();
58 if (test(elementAt(i))) return true; 146 for (int i = 0;
59 if (length != this.length) { 147 i < length;
60 throw new ConcurrentModificationError(this); 148 i++) {
61 } 149 buffer.write(elementAt(i));
150 if (length != this.length) {
151 throw new ConcurrentModificationError(this);
62 } 152 }
63 return false; 153 }
64 } 154 return buffer.toString();
65 E firstWhere(bool test(E element), {E orElse()}) { 155 }
66 int length = this.length; 156 }
67 for (int i = 0; i < length; i++) { 157 Iterable<E> where(bool test(E element)) => super.where(test);
68 E element = elementAt(i); 158 Iterable map(f(E element)) => new MappedListIterable(this, f);
69 if (test(element)) return element; 159 E reduce(E combine(var value, E element)) {
70 if (length != this.length) { 160 int length = this.length;
71 throw new ConcurrentModificationError(this); 161 if (length == 0) throw IterableElementError.noElement();
72 } 162 E value = elementAt(0);
73 } 163 for (int i = 1;
74 if (orElse != null) return orElse(); 164 i < length;
75 throw IterableElementError.noElement(); 165 i++) {
76 } 166 value = combine(value, elementAt(i));
77 E lastWhere(bool test(E element), {E orElse()}) { 167 if (length != this.length) {
78 int length = this.length; 168 throw new ConcurrentModificationError(this);
79 for (int i = length - 1; i >= 0; i--) { 169 }
80 E element = elementAt(i); 170 }
81 if (test(element)) return element; 171 return value;
82 if (length != this.length) { 172 }
83 throw new ConcurrentModificationError(this); 173 fold(var initialValue, combine(var previousValue, E element)) {
84 } 174 var value = initialValue;
85 } 175 int length = this.length;
86 if (orElse != null) return orElse(); 176 for (int i = 0;
87 throw IterableElementError.noElement(); 177 i < length;
88 } 178 i++) {
89 E singleWhere(bool test(E element)) { 179 value = combine(value, elementAt(i));
90 int length = this.length; 180 if (length != this.length) {
91 E match = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", 181 throw new ConcurrentModificationError(this);
92 """line 125, column 15 of dart:_internal/iterable.dart: """, __x0 is E, 182 }
93 false))(null); 183 }
94 bool matchFound = false; 184 return value;
95 for (int i = 0; i < length; i++) { 185 }
96 E element = elementAt(i); 186 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null);
97 if (test(element)) { 187 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test);
98 if (matchFound) { 188 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count);
99 throw IterableElementError.tooMany(); 189 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test);
100 } 190 List<E> toList({
101 matchFound = true; 191 bool growable : true}
102 match = element; 192 ) {
103 } 193 List<E> result;
104 if (length != this.length) { 194 if (growable) {
105 throw new ConcurrentModificationError(this); 195 result = new List<E>()..length = length;
106 } 196 }
107 } 197 else {
108 if (matchFound) return match; 198 result = new List<E>(length);
109 throw IterableElementError.noElement(); 199 }
110 } 200 for (int i = 0;
111 String join([String separator = ""]) { 201 i < length;
112 int length = this.length; 202 i++) {
113 if (!separator.isEmpty) { 203 result[i] = elementAt(i);
114 if (length == 0) return ""; 204 }
115 String first = "${elementAt(0)}"; 205 return result;
116 if (length != this.length) { 206 }
117 throw new ConcurrentModificationError(this); 207 Set<E> toSet() {
118 } 208 Set<E> result = new Set<E>();
119 StringBuffer buffer = new StringBuffer(first); 209 for (int i = 0;
120 for (int i = 1; i < length; i++) { 210 i < length;
121 buffer.write(separator); 211 i++) {
122 buffer.write(elementAt(i)); 212 result.add(elementAt(i));
123 if (length != this.length) { 213 }
124 throw new ConcurrentModificationError(this); 214 return result;
125 } 215 }
126 } 216 }
127 return buffer.toString(); 217 class SubListIterable<E> extends ListIterable<E> {final Iterable<E> _iterable;
128 } else { 218 final int _start;
129 StringBuffer buffer = new StringBuffer(); 219 final int _endOrLength;
130 for (int i = 0; i < length; i++) { 220 SubListIterable(this._iterable, this._start, this._endOrLength) {
131 buffer.write(elementAt(i)); 221 RangeError.checkNotNegative(_start, "start");
132 if (length != this.length) { 222 if (_endOrLength != null) {
133 throw new ConcurrentModificationError(this); 223 RangeError.checkNotNegative(_endOrLength, "end");
134 } 224 if (_start > _endOrLength) {
135 } 225 throw new RangeError.range(_start, 0, _endOrLength, "start");
136 return buffer.toString(); 226 }
137 } 227 }
138 } 228 }
139 Iterable<E> where(bool test(E element)) => super.where(test); 229 int get _endIndex {
140 Iterable map(f(E element)) => new MappedListIterable(this, f); 230 int length = _iterable.length;
141 E reduce(E combine(var value, E element)) { 231 if (_endOrLength == null || _endOrLength > length) return length;
142 int length = this.length; 232 return _endOrLength;
143 if (length == 0) throw IterableElementError.noElement(); 233 }
144 E value = elementAt(0); 234 int get _startIndex {
145 for (int i = 1; i < length; i++) { 235 int length = _iterable.length;
146 value = combine(value, elementAt(i)); 236 if (_start > length) return length;
147 if (length != this.length) { 237 return _start;
148 throw new ConcurrentModificationError(this); 238 }
149 } 239 int get length {
150 } 240 int length = _iterable.length;
151 return value; 241 if (_start >= length) return 0;
152 } 242 if (_endOrLength == null || _endOrLength >= length) {
153 fold(var initialValue, combine(var previousValue, E element)) { 243 return length - _start;
154 var value = initialValue; 244 }
155 int length = this.length; 245 return _endOrLength - _start;
156 for (int i = 0; i < length; i++) { 246 }
157 value = combine(value, elementAt(i)); 247 E elementAt(int index) {
158 if (length != this.length) { 248 int realIndex = _startIndex + index;
159 throw new ConcurrentModificationError(this); 249 if (index < 0 || realIndex >= _endIndex) {
160 } 250 throw new RangeError.index(index, this, "index");
161 } 251 }
162 return value; 252 return _iterable.elementAt(realIndex);
163 } 253 }
164 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); 254 Iterable<E> skip(int count) {
165 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test); 255 RangeError.checkNotNegative(count, "count");
166 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); 256 int newStart = _start + count;
167 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test); 257 if (_endOrLength != null && newStart >= _endOrLength) {
168 List<E> toList({bool growable: true}) { 258 return new EmptyIterable<E>();
169 List<E> result; 259 }
170 if (growable) { 260 return new SubListIterable<E>(_iterable, newStart, _endOrLength);
171 result = new List<E>()..length = length; 261 }
172 } else { 262 Iterable<E> take(int count) {
173 result = new List<E>(length); 263 RangeError.checkNotNegative(count, "count");
174 } 264 if (_endOrLength == null) {
175 for (int i = 0; i < length; i++) { 265 return new SubListIterable<E>(_iterable, _start, _start + count);
176 result[i] = elementAt(i); 266 }
177 } 267 else {
178 return result; 268 int newEnd = _start + count;
179 } 269 if (_endOrLength < newEnd) return this;
180 Set<E> toSet() { 270 return new SubListIterable<E>(_iterable, _start, newEnd);
181 Set<E> result = new Set<E>(); 271 }
182 for (int i = 0; i < length; i++) { 272 }
183 result.add(elementAt(i)); 273 List<E> toList({
184 } 274 bool growable : true}
185 return result; 275 ) {
186 } 276 int start = _start;
187 } 277 int end = _iterable.length;
188 class SubListIterable<E> extends ListIterable<E> { 278 if (_endOrLength != null && _endOrLength < end) end = _endOrLength;
189 final Iterable<E> _iterable; 279 int length = end - start;
190 final int _start; 280 if (length < 0) length = 0;
191 final int _endOrLength; 281 List result = growable ? (new List<E>()..length = length) : new List<E>(length) ;
192 SubListIterable(this._iterable, this._start, this._endOrLength) { 282 for (int i = 0;
193 RangeError.checkNotNegative(_start, "start"); 283 i < length;
194 if (_endOrLength != null) { 284 i++) {
195 RangeError.checkNotNegative(_endOrLength, "end"); 285 result[i] = _iterable.elementAt(start + i);
196 if (_start > _endOrLength) { 286 if (_iterable.length < end) throw new ConcurrentModificationError(this);
197 throw new RangeError.range(_start, 0, _endOrLength, "start"); 287 }
198 } 288 return DDC$RT.cast(result, DDC$RT.type((List<dynamic> _) {
199 } 289 }
200 } 290 ), DDC$RT.type((List<E> _) {
201 int get _endIndex { 291 }
202 int length = _iterable.length; 292 ), "CastDynamic", """line 310, column 12 of dart:_internal/iterable.dart: """, r esult is List<E>, false);
203 if (_endOrLength == null || _endOrLength > length) return length; 293 }
204 return _endOrLength; 294 }
205 } 295 class ListIterator<E> implements Iterator<E> {final Iterable<E> _iterable;
206 int get _startIndex { 296 final int _length;
207 int length = _iterable.length; 297 int _index;
208 if (_start > length) return length; 298 E _current;
209 return _start; 299 ListIterator(Iterable<E> iterable) : _iterable = iterable, _length = iterable.l ength, _index = 0;
210 } 300 E get current => _current;
211 int get length { 301 bool moveNext() {
212 int length = _iterable.length; 302 int length = _iterable.length;
213 if (_start >= length) return 0; 303 if (_length != length) {
214 if (_endOrLength == null || _endOrLength >= length) { 304 throw new ConcurrentModificationError(_iterable);
215 return length - _start; 305 }
216 } 306 if (_index >= length) {
217 return _endOrLength - _start; 307 _current = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", """line 338, col umn 18 of dart:_internal/iterable.dart: """, __x1 is E, false))(null);
218 } 308 return false;
219 E elementAt(int index) { 309 }
220 int realIndex = _startIndex + index; 310 _current = _iterable.elementAt(_index);
221 if (index < 0 || realIndex >= _endIndex) { 311 _index++;
222 throw new RangeError.index(index, this, "index"); 312 return true;
223 } 313 }
224 return _iterable.elementAt(realIndex); 314 }
225 } 315 typedef T _Transformation<S, T>(S value);
226 Iterable<E> skip(int count) { 316 class MappedIterable<S, T> extends IterableBase<T> {final Iterable<S> _iterable ;
227 RangeError.checkNotNegative(count, "count"); 317 final _Transformation<S, T> _f;
228 int newStart = _start + count; 318 factory MappedIterable(Iterable iterable, T function(S value)) {
229 if (_endOrLength != null && newStart >= _endOrLength) { 319 if (iterable is EfficientLength) {
230 return new EmptyIterable<E>(); 320 return new EfficientLengthMappedIterable<S, T>(iterable, function);
231 } 321 }
232 return new SubListIterable<E>(_iterable, newStart, _endOrLength); 322 return new MappedIterable<S, T>._(iterable, function);
233 } 323 }
234 Iterable<E> take(int count) { 324 MappedIterable._(this._iterable, T this._f(S element));
235 RangeError.checkNotNegative(count, "count"); 325 Iterator<T> get iterator => new MappedIterator<S, T>(_iterable.iterator, _f);
236 if (_endOrLength == null) { 326 int get length => _iterable.length;
237 return new SubListIterable<E>(_iterable, _start, _start + count); 327 bool get isEmpty => _iterable.isEmpty;
238 } else { 328 T get first => _f(_iterable.first);
239 int newEnd = _start + count; 329 T get last => _f(_iterable.last);
240 if (_endOrLength < newEnd) return this; 330 T get single => _f(_iterable.single);
241 return new SubListIterable<E>(_iterable, _start, newEnd); 331 T elementAt(int index) => _f(_iterable.elementAt(index));
242 } 332 }
243 } 333 class EfficientLengthMappedIterable<S, T> extends MappedIterable<S, T> implemen ts EfficientLength {EfficientLengthMappedIterable(Iterable iterable, T function( S value)) : super._(DDC$RT.cast(iterable, DDC$RT.type((Iterable<dynamic> _) {
244 List<E> toList({bool growable: true}) { 334 }
245 int start = _start; 335 ), DDC$RT.type((Iterable<S> _) {
246 int end = _iterable.length; 336 }
247 if (_endOrLength != null && _endOrLength < end) end = _endOrLength; 337 ), "CastDynamic", """line 378, column 17 of dart:_internal/iterable.dart: """, i terable is Iterable<S>, false), function);
248 int length = end - start; 338 }
249 if (length < 0) length = 0; 339 class MappedIterator<S, T> extends Iterator<T> {T _current;
250 List result = 340 final Iterator<S> _iterator;
251 growable ? (new List<E>()..length = length) : new List<E>(length); 341 final _Transformation<S, T> _f;
252 for (int i = 0; i < length; i++) { 342 MappedIterator(this._iterator, T this._f(S element));
253 result[i] = _iterable.elementAt(start + i); 343 bool moveNext() {
254 if (_iterable.length < end) throw new ConcurrentModificationError(this); 344 if (_iterator.moveNext()) {
255 } 345 _current = _f(_iterator.current);
256 return DDC$RT.cast(result, DDC$RT.type((List<dynamic> _) {}), 346 return true;
257 DDC$RT.type((List<E> _) {}), "CastDynamic", 347 }
258 """line 310, column 12 of dart:_internal/iterable.dart: """, 348 _current = ((__x2) => DDC$RT.cast(__x2, Null, T, "CastLiteral", """line 393, co lumn 16 of dart:_internal/iterable.dart: """, __x2 is T, false))(null);
259 result is List<E>, false); 349 return false;
260 } 350 }
261 } 351 T get current => _current;
262 class ListIterator<E> implements Iterator<E> { 352 }
263 final Iterable<E> _iterable; 353 class MappedListIterable<S, T> extends ListIterable<T> implements EfficientLeng th {final Iterable<S> _source;
264 final int _length; 354 final _Transformation<S, T> _f;
265 int _index; 355 MappedListIterable(this._source, T this._f(S value));
266 E _current; 356 int get length => _source.length;
267 ListIterator(Iterable<E> iterable) 357 T elementAt(int index) => _f(_source.elementAt(index));
268 : _iterable = iterable, 358 }
269 _length = iterable.length, 359 typedef bool _ElementPredicate<E>(E element);
270 _index = 0; 360 class WhereIterable<E> extends IterableBase<E> {final Iterable<E> _iterable;
271 E get current => _current; 361 final _ElementPredicate _f;
272 bool moveNext() { 362 WhereIterable(this._iterable, bool this._f(E element));
273 int length = _iterable.length; 363 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f);
274 if (_length != length) { 364 }
275 throw new ConcurrentModificationError(_iterable); 365 class WhereIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
276 } 366 final _ElementPredicate _f;
277 if (_index >= length) { 367 WhereIterator(this._iterator, bool this._f(E element));
278 _current = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", 368 bool moveNext() {
279 """line 338, column 18 of dart:_internal/iterable.dart: """, 369 while (_iterator.moveNext()) {
280 __x1 is E, false))(null); 370 if (_f(_iterator.current)) {
281 return false; 371 return true;
282 } 372 }
283 _current = _iterable.elementAt(_index); 373 }
284 _index++; 374 return false;
285 return true; 375 }
286 } 376 E get current => _iterator.current;
287 } 377 }
288 typedef T _Transformation<S, T>(S value); 378 typedef Iterable<T> _ExpandFunction<S, T>(S sourceElement);
289 class MappedIterable<S, T> extends IterableBase<T> { 379 class ExpandIterable<S, T> extends IterableBase<T> {final Iterable<S> _iterable ;
290 final Iterable<S> _iterable; 380 final _ExpandFunction _f;
291 final _Transformation<S, T> _f; 381 ExpandIterable(this._iterable, Iterable<T> this._f(S element));
292 factory MappedIterable(Iterable iterable, T function(S value)) { 382 Iterator<T> get iterator => new ExpandIterator<S, T>(_iterable.iterator, _f);
293 if (iterable is EfficientLength) { 383 }
294 return new EfficientLengthMappedIterable<S, T>(iterable, function); 384 class ExpandIterator<S, T> implements Iterator<T> {final Iterator<S> _iterator;
295 } 385 final _ExpandFunction _f;
296 return new MappedIterable<S, T>._(iterable, function); 386 Iterator<T> _currentExpansion = ((__x3) => DDC$RT.cast(__x3, null, DDC$RT.type( (Iterator<T> _) {
297 } 387 }
298 MappedIterable._(this._iterable, T this._f(S element)); 388 ), "CastExact", """line 463, column 35 of dart:_internal/iterable.dart: """, __x 3 is Iterator<T>, false))(const EmptyIterator());
299 Iterator<T> get iterator => new MappedIterator<S, T>(_iterable.iterator, _f); 389 T _current;
300 int get length => _iterable.length; 390 ExpandIterator(this._iterator, Iterable<T> this._f(S element));
301 bool get isEmpty => _iterable.isEmpty; 391 void _nextExpansion() {
302 T get first => _f(_iterable.first); 392 }
303 T get last => _f(_iterable.last); 393 T get current => _current;
304 T get single => _f(_iterable.single); 394 bool moveNext() {
305 T elementAt(int index) => _f(_iterable.elementAt(index)); 395 if (_currentExpansion == null) return false;
306 } 396 while (!_currentExpansion.moveNext()) {
307 class EfficientLengthMappedIterable<S, T> extends MappedIterable<S, T> 397 _current = ((__x4) => DDC$RT.cast(__x4, Null, T, "CastLiteral", """line 476, col umn 18 of dart:_internal/iterable.dart: """, __x4 is T, false))(null);
308 implements EfficientLength { 398 if (_iterator.moveNext()) {
309 EfficientLengthMappedIterable(Iterable iterable, T function(S value)) 399 _currentExpansion = null;
310 : super._(DDC$RT.cast(iterable, DDC$RT.type((Iterable<dynamic> _) {}), 400 _currentExpansion = ((__x5) => DDC$RT.cast(__x5, DDC$RT.type((Iterator<dynamic> _) {
311 DDC$RT.type((Iterable<S> _) {}), "CastDynamic", 401 }
312 """line 378, column 17 of dart:_internal/iterable.dart: """, 402 ), DDC$RT.type((Iterator<T> _) {
313 iterable is Iterable<S>, false), function); 403 }
314 } 404 ), "CastDynamic", """line 481, column 29 of dart:_internal/iterable.dart: """, _ _x5 is Iterator<T>, false))(_f(_iterator.current).iterator);
315 class MappedIterator<S, T> extends Iterator<T> { 405 }
316 T _current; 406 else {
317 final Iterator<S> _iterator; 407 return false;
318 final _Transformation<S, T> _f; 408 }
319 MappedIterator(this._iterator, T this._f(S element)); 409 }
320 bool moveNext() { 410 _current = _currentExpansion.current;
321 if (_iterator.moveNext()) { 411 return true;
322 _current = _f(_iterator.current); 412 }
323 return true; 413 }
324 } 414 class TakeIterable<E> extends IterableBase<E> {final Iterable<E> _iterable;
325 _current = ((__x2) => DDC$RT.cast(__x2, Null, T, "CastLiteral", 415 final int _takeCount;
326 """line 393, column 16 of dart:_internal/iterable.dart: """, __x2 is T, 416 factory TakeIterable(Iterable<E> iterable, int takeCount) {
327 false))(null); 417 if (takeCount is! int || takeCount < 0) {
328 return false; 418 throw new ArgumentError(takeCount);
329 } 419 }
330 T get current => _current; 420 if (iterable is EfficientLength) {
331 } 421 return new EfficientLengthTakeIterable<E>(iterable, takeCount);
332 class MappedListIterable<S, T> extends ListIterable<T> 422 }
333 implements EfficientLength { 423 return new TakeIterable<E>._(iterable, takeCount);
334 final Iterable<S> _source; 424 }
335 final _Transformation<S, T> _f; 425 TakeIterable._(this._iterable, this._takeCount);
336 MappedListIterable(this._source, T this._f(S value)); 426 Iterator<E> get iterator {
337 int get length => _source.length; 427 return new TakeIterator<E>(_iterable.iterator, _takeCount);
338 T elementAt(int index) => _f(_source.elementAt(index)); 428 }
339 } 429 }
340 typedef bool _ElementPredicate<E>(E element); 430 class EfficientLengthTakeIterable<E> extends TakeIterable<E> implements Efficie ntLength {EfficientLengthTakeIterable(Iterable<E> iterable, int takeCount) : sup er._(iterable, takeCount);
341 class WhereIterable<E> extends IterableBase<E> { 431 int get length {
342 final Iterable<E> _iterable; 432 int iterableLength = _iterable.length;
343 final _ElementPredicate _f; 433 if (iterableLength > _takeCount) return _takeCount;
344 WhereIterable(this._iterable, bool this._f(E element)); 434 return iterableLength;
345 Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f); 435 }
346 } 436 }
347 class WhereIterator<E> extends Iterator<E> { 437 class TakeIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
348 final Iterator<E> _iterator; 438 int _remaining;
349 final _ElementPredicate _f; 439 TakeIterator(this._iterator, this._remaining) {
350 WhereIterator(this._iterator, bool this._f(E element)); 440 assert (_remaining is int && _remaining >= 0);}
351 bool moveNext() { 441 bool moveNext() {
352 while (_iterator.moveNext()) { 442 _remaining--;
353 if (_f(_iterator.current)) { 443 if (_remaining >= 0) {
354 return true; 444 return _iterator.moveNext();
355 } 445 }
356 } 446 _remaining = -1;
357 return false; 447 return false;
358 } 448 }
359 E get current => _iterator.current; 449 E get current {
360 } 450 if (_remaining < 0) return ((__x6) => DDC$RT.cast(__x6, Null, E, "CastLiteral", """line 543, column 32 of dart:_internal/iterable.dart: """, __x6 is E, false))( null);
361 typedef Iterable<T> _ExpandFunction<S, T>(S sourceElement); 451 return _iterator.current;
362 class ExpandIterable<S, T> extends IterableBase<T> { 452 }
363 final Iterable<S> _iterable; 453 }
364 final _ExpandFunction _f; 454 class TakeWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ;
365 ExpandIterable(this._iterable, Iterable<T> this._f(S element)); 455 final _ElementPredicate _f;
366 Iterator<T> get iterator => new ExpandIterator<S, T>(_iterable.iterator, _f); 456 TakeWhileIterable(this._iterable, bool this._f(E element));
367 } 457 Iterator<E> get iterator {
368 class ExpandIterator<S, T> implements Iterator<T> { 458 return new TakeWhileIterator<E>(_iterable.iterator, _f);
369 final Iterator<S> _iterator; 459 }
370 final _ExpandFunction _f; 460 }
371 Iterator<T> _currentExpansion = ((__x3) => DDC$RT.cast(__x3, null, 461 class TakeWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
372 DDC$RT.type((Iterator<T> _) {}), "CastExact", 462 final _ElementPredicate _f;
373 """line 463, column 35 of dart:_internal/iterable.dart: """, 463 bool _isFinished = false;
374 __x3 is Iterator<T>, false))(const EmptyIterator()); 464 TakeWhileIterator(this._iterator, bool this._f(E element));
375 T _current; 465 bool moveNext() {
376 ExpandIterator(this._iterator, Iterable<T> this._f(S element)); 466 if (_isFinished) return false;
377 void _nextExpansion() {} 467 if (!_iterator.moveNext() || !_f(_iterator.current)) {
378 T get current => _current; 468 _isFinished = true;
379 bool moveNext() { 469 return false;
380 if (_currentExpansion == null) return false; 470 }
381 while (!_currentExpansion.moveNext()) { 471 return true;
382 _current = ((__x4) => DDC$RT.cast(__x4, Null, T, "CastLiteral", 472 }
383 """line 476, column 18 of dart:_internal/iterable.dart: """, 473 E get current {
384 __x4 is T, false))(null); 474 if (_isFinished) return ((__x7) => DDC$RT.cast(__x7, Null, E, "CastLiteral", """ line 576, column 29 of dart:_internal/iterable.dart: """, __x7 is E, false))(nul l);
385 if (_iterator.moveNext()) { 475 return _iterator.current;
386 _currentExpansion = null; 476 }
387 _currentExpansion = ((__x5) => DDC$RT.cast(__x5, 477 }
388 DDC$RT.type((Iterator<dynamic> _) {}), 478 class SkipIterable<E> extends IterableBase<E> {final Iterable<E> _iterable;
389 DDC$RT.type((Iterator<T> _) {}), "CastDynamic", 479 final int _skipCount;
390 """line 481, column 29 of dart:_internal/iterable.dart: """, 480 factory SkipIterable(Iterable<E> iterable, int count) {
391 __x5 is Iterator<T>, false))(_f(_iterator.current).iterator); 481 if (iterable is EfficientLength) {
392 } else { 482 return new EfficientLengthSkipIterable<E>(iterable, count);
393 return false; 483 }
394 } 484 return new SkipIterable<E>._(iterable, count);
395 } 485 }
396 _current = _currentExpansion.current; 486 SkipIterable._(this._iterable, this._skipCount) {
397 return true; 487 if (_skipCount is! int) {
398 } 488 throw new ArgumentError.value(_skipCount, "count is not an integer");
399 } 489 }
400 class TakeIterable<E> extends IterableBase<E> { 490 RangeError.checkNotNegative(_skipCount, "count");
401 final Iterable<E> _iterable; 491 }
402 final int _takeCount; 492 Iterable<E> skip(int count) {
403 factory TakeIterable(Iterable<E> iterable, int takeCount) { 493 if (_skipCount is! int) {
404 if (takeCount is! int || takeCount < 0) { 494 throw new ArgumentError.value(_skipCount, "count is not an integer");
405 throw new ArgumentError(takeCount); 495 }
406 } 496 RangeError.checkNotNegative(_skipCount, "count");
407 if (iterable is EfficientLength) { 497 return new SkipIterable<E>._(_iterable, _skipCount + count);
408 return new EfficientLengthTakeIterable<E>(iterable, takeCount); 498 }
409 } 499 Iterator<E> get iterator {
410 return new TakeIterable<E>._(iterable, takeCount); 500 return new SkipIterator<E>(_iterable.iterator, _skipCount);
411 } 501 }
412 TakeIterable._(this._iterable, this._takeCount); 502 }
413 Iterator<E> get iterator { 503 class EfficientLengthSkipIterable<E> extends SkipIterable<E> implements Efficie ntLength {EfficientLengthSkipIterable(Iterable<E> iterable, int skipCount) : sup er._(iterable, skipCount);
414 return new TakeIterator<E>(_iterable.iterator, _takeCount); 504 int get length {
415 } 505 int length = _iterable.length - _skipCount;
416 } 506 if (length >= 0) return length;
417 class EfficientLengthTakeIterable<E> extends TakeIterable<E> 507 return 0;
418 implements EfficientLength { 508 }
419 EfficientLengthTakeIterable(Iterable<E> iterable, int takeCount) 509 }
420 : super._(iterable, takeCount); 510 class SkipIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
421 int get length { 511 int _skipCount;
422 int iterableLength = _iterable.length; 512 SkipIterator(this._iterator, this._skipCount) {
423 if (iterableLength > _takeCount) return _takeCount; 513 assert (_skipCount is int && _skipCount >= 0);}
424 return iterableLength; 514 bool moveNext() {
425 } 515 for (int i = 0;
426 } 516 i < _skipCount;
427 class TakeIterator<E> extends Iterator<E> { 517 i++) _iterator.moveNext();
428 final Iterator<E> _iterator; 518 _skipCount = 0;
429 int _remaining; 519 return _iterator.moveNext();
430 TakeIterator(this._iterator, this._remaining) { 520 }
431 assert(_remaining is int && _remaining >= 0); 521 E get current => _iterator.current;
432 } 522 }
433 bool moveNext() { 523 class SkipWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable ;
434 _remaining--; 524 final _ElementPredicate _f;
435 if (_remaining >= 0) { 525 SkipWhileIterable(this._iterable, bool this._f(E element));
436 return _iterator.moveNext(); 526 Iterator<E> get iterator {
437 } 527 return new SkipWhileIterator<E>(_iterable.iterator, _f);
438 _remaining = -1; 528 }
439 return false; 529 }
440 } 530 class SkipWhileIterator<E> extends Iterator<E> {final Iterator<E> _iterator;
441 E get current { 531 final _ElementPredicate _f;
442 if (_remaining < 0) return ((__x6) => DDC$RT.cast(__x6, Null, E, 532 bool _hasSkipped = false;
443 "CastLiteral", 533 SkipWhileIterator(this._iterator, bool this._f(E element));
444 """line 543, column 32 of dart:_internal/iterable.dart: """, __x6 is E, 534 bool moveNext() {
445 false))(null); 535 if (!_hasSkipped) {
446 return _iterator.current; 536 _hasSkipped = true;
447 } 537 while (_iterator.moveNext()) {
448 } 538 if (!_f(_iterator.current)) return true;
449 class TakeWhileIterable<E> extends IterableBase<E> { 539 }
450 final Iterable<E> _iterable; 540 }
451 final _ElementPredicate _f; 541 return _iterator.moveNext();
452 TakeWhileIterable(this._iterable, bool this._f(E element)); 542 }
453 Iterator<E> get iterator { 543 E get current => _iterator.current;
454 return new TakeWhileIterator<E>(_iterable.iterator, _f); 544 }
455 } 545 class EmptyIterable<E> extends IterableBase<E> implements EfficientLength {cons t EmptyIterable();
456 } 546 Iterator<E> get iterator => ((__x8) => DDC$RT.cast(__x8, null, DDC$RT.type((Ite rator<E> _) {
457 class TakeWhileIterator<E> extends Iterator<E> { 547 }
458 final Iterator<E> _iterator; 548 ), "CastExact", """line 678, column 31 of dart:_internal/iterable.dart: """, __x 8 is Iterator<E>, false))(const EmptyIterator());
459 final _ElementPredicate _f; 549 void forEach(void action(E element)) {
460 bool _isFinished = false; 550 }
461 TakeWhileIterator(this._iterator, bool this._f(E element)); 551 bool get isEmpty => true;
462 bool moveNext() { 552 int get length => 0;
463 if (_isFinished) return false; 553 E get first {
464 if (!_iterator.moveNext() || !_f(_iterator.current)) { 554 throw IterableElementError.noElement();
465 _isFinished = true; 555 }
466 return false; 556 E get last {
467 } 557 throw IterableElementError.noElement();
468 return true; 558 }
469 } 559 E get single {
470 E get current { 560 throw IterableElementError.noElement();
471 if (_isFinished) return ((__x7) => DDC$RT.cast(__x7, Null, E, "CastLiteral", 561 }
472 """line 576, column 29 of dart:_internal/iterable.dart: """, __x7 is E, 562 E elementAt(int index) {
473 false))(null); 563 throw new RangeError.range(index, 0, 0, "index");
474 return _iterator.current; 564 }
475 } 565 bool contains(Object element) => false;
476 } 566 bool every(bool test(E element)) => true;
477 class SkipIterable<E> extends IterableBase<E> { 567 bool any(bool test(E element)) => false;
478 final Iterable<E> _iterable; 568 E firstWhere(bool test(E element), {
479 final int _skipCount; 569 E orElse()}
480 factory SkipIterable(Iterable<E> iterable, int count) { 570 ) {
481 if (iterable is EfficientLength) { 571 if (orElse != null) return orElse();
482 return new EfficientLengthSkipIterable<E>(iterable, count); 572 throw IterableElementError.noElement();
483 } 573 }
484 return new SkipIterable<E>._(iterable, count); 574 E lastWhere(bool test(E element), {
485 } 575 E orElse()}
486 SkipIterable._(this._iterable, this._skipCount) { 576 ) {
487 if (_skipCount is! int) { 577 if (orElse != null) return orElse();
488 throw new ArgumentError.value(_skipCount, "count is not an integer"); 578 throw IterableElementError.noElement();
489 } 579 }
490 RangeError.checkNotNegative(_skipCount, "count"); 580 E singleWhere(bool test(E element), {
491 } 581 E orElse()}
492 Iterable<E> skip(int count) { 582 ) {
493 if (_skipCount is! int) { 583 if (orElse != null) return orElse();
494 throw new ArgumentError.value(_skipCount, "count is not an integer"); 584 throw IterableElementError.noElement();
495 } 585 }
496 RangeError.checkNotNegative(_skipCount, "count"); 586 String join([String separator = ""]) => "";
497 return new SkipIterable<E>._(_iterable, _skipCount + count); 587 Iterable<E> where(bool test(E element)) => this;
498 } 588 Iterable map(f(E element)) => const EmptyIterable();
499 Iterator<E> get iterator { 589 E reduce(E combine(E value, E element)) {
500 return new SkipIterator<E>(_iterable.iterator, _skipCount); 590 throw IterableElementError.noElement();
501 } 591 }
502 } 592 fold(var initialValue, combine(var previousValue, E element)) {
503 class EfficientLengthSkipIterable<E> extends SkipIterable<E> 593 return initialValue;
504 implements EfficientLength { 594 }
505 EfficientLengthSkipIterable(Iterable<E> iterable, int skipCount) 595 Iterable<E> skip(int count) {
506 : super._(iterable, skipCount); 596 RangeError.checkNotNegative(count, "count");
507 int get length { 597 return this;
508 int length = _iterable.length - _skipCount; 598 }
509 if (length >= 0) return length; 599 Iterable<E> skipWhile(bool test(E element)) => this;
510 return 0; 600 Iterable<E> take(int count) {
511 } 601 RangeError.checkNotNegative(count, "count");
512 } 602 return this;
513 class SkipIterator<E> extends Iterator<E> { 603 }
514 final Iterator<E> _iterator; 604 Iterable<E> takeWhile(bool test(E element)) => this;
515 int _skipCount; 605 List toList({
516 SkipIterator(this._iterator, this._skipCount) { 606 bool growable : true}
517 assert(_skipCount is int && _skipCount >= 0); 607 ) => growable ? <E> [] : new List<E>(0);
518 } 608 Set toSet() => new Set<E>();
519 bool moveNext() { 609 }
520 for (int i = 0; i < _skipCount; i++) _iterator.moveNext(); 610 class EmptyIterator<E> implements Iterator<E> {const EmptyIterator();
521 _skipCount = 0; 611 bool moveNext() => false;
522 return _iterator.moveNext(); 612 E get current => ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", """line 7 52, column 20 of dart:_internal/iterable.dart: """, __x9 is E, false))(null);
523 } 613 }
524 E get current => _iterator.current; 614 abstract class BidirectionalIterator<T> implements Iterator<T> {bool movePrevio us();
525 } 615 }
526 class SkipWhileIterable<E> extends IterableBase<E> { 616 class IterableMixinWorkaround<T> {static bool contains(Iterable iterable, var e lement) {
527 final Iterable<E> _iterable; 617 for (final e in iterable) {
528 final _ElementPredicate _f; 618 if (e == element) return true;
529 SkipWhileIterable(this._iterable, bool this._f(E element)); 619 }
530 Iterator<E> get iterator { 620 return false;
531 return new SkipWhileIterator<E>(_iterable.iterator, _f); 621 }
532 } 622 static void forEach(Iterable iterable, void f(o)) {
533 } 623 for (final e in iterable) {
534 class SkipWhileIterator<E> extends Iterator<E> { 624 f(e);
535 final Iterator<E> _iterator; 625 }
536 final _ElementPredicate _f; 626 }
537 bool _hasSkipped = false; 627 static bool any(Iterable iterable, bool f(o)) {
538 SkipWhileIterator(this._iterator, bool this._f(E element)); 628 for (final e in iterable) {
539 bool moveNext() { 629 if (f(e)) return true;
540 if (!_hasSkipped) { 630 }
541 _hasSkipped = true; 631 return false;
542 while (_iterator.moveNext()) { 632 }
543 if (!_f(_iterator.current)) return true; 633 static bool every(Iterable iterable, bool f(o)) {
544 } 634 for (final e in iterable) {
545 } 635 if (!f(e)) return false;
546 return _iterator.moveNext(); 636 }
547 } 637 return true;
548 E get current => _iterator.current; 638 }
549 } 639 static dynamic reduce(Iterable iterable, dynamic combine(previousValue, element )) {
550 class EmptyIterable<E> extends IterableBase<E> implements EfficientLength { 640 Iterator iterator = iterable.iterator;
551 const EmptyIterable(); 641 if (!iterator.moveNext()) throw IterableElementError.noElement();
552 Iterator<E> get iterator => ((__x8) => DDC$RT.cast(__x8, null, 642 var value = iterator.current;
553 DDC$RT.type((Iterator<E> _) {}), "CastExact", 643 while (iterator.moveNext()) {
554 """line 678, column 31 of dart:_internal/iterable.dart: """, 644 value = combine(value, iterator.current);
555 __x8 is Iterator<E>, false))(const EmptyIterator()); 645 }
556 void forEach(void action(E element)) {} 646 return value;
557 bool get isEmpty => true; 647 }
558 int get length => 0; 648 static dynamic fold(Iterable iterable, dynamic initialValue, dynamic combine(dy namic previousValue, element)) {
559 E get first { 649 for (final element in iterable) {
560 throw IterableElementError.noElement(); 650 initialValue = combine(initialValue, element);
561 } 651 }
562 E get last { 652 return initialValue;
563 throw IterableElementError.noElement(); 653 }
564 } 654 static void removeWhereList(List list, bool test(var element)) {
565 E get single { 655 List retained = [];
566 throw IterableElementError.noElement(); 656 int length = list.length;
567 } 657 for (int i = 0;
568 E elementAt(int index) { 658 i < length;
569 throw new RangeError.range(index, 0, 0, "index"); 659 i++) {
570 } 660 var element = list[i];
571 bool contains(Object element) => false; 661 if (!test(element)) {
572 bool every(bool test(E element)) => true; 662 retained.add(element);
573 bool any(bool test(E element)) => false; 663 }
574 E firstWhere(bool test(E element), {E orElse()}) { 664 if (length != list.length) {
575 if (orElse != null) return orElse(); 665 throw new ConcurrentModificationError(list);
576 throw IterableElementError.noElement(); 666 }
577 } 667 }
578 E lastWhere(bool test(E element), {E orElse()}) { 668 if (retained.length == length) return; list.length = retained.length;
579 if (orElse != null) return orElse(); 669 for (int i = 0;
580 throw IterableElementError.noElement(); 670 i < retained.length;
581 } 671 i++) {
582 E singleWhere(bool test(E element), {E orElse()}) { 672 list[i] = retained[i];
583 if (orElse != null) return orElse(); 673 }
584 throw IterableElementError.noElement(); 674 }
585 } 675 static bool isEmpty(Iterable iterable) {
586 String join([String separator = ""]) => ""; 676 return !iterable.iterator.moveNext();
587 Iterable<E> where(bool test(E element)) => this; 677 }
588 Iterable map(f(E element)) => const EmptyIterable(); 678 static dynamic first(Iterable iterable) {
589 E reduce(E combine(E value, E element)) { 679 Iterator it = iterable.iterator;
590 throw IterableElementError.noElement(); 680 if (!it.moveNext()) {
591 } 681 throw IterableElementError.noElement();
592 fold(var initialValue, combine(var previousValue, E element)) { 682 }
593 return initialValue; 683 return it.current;
594 } 684 }
595 Iterable<E> skip(int count) { 685 static dynamic last(Iterable iterable) {
596 RangeError.checkNotNegative(count, "count"); 686 Iterator it = iterable.iterator;
597 return this; 687 if (!it.moveNext()) {
598 } 688 throw IterableElementError.noElement();
599 Iterable<E> skipWhile(bool test(E element)) => this; 689 }
600 Iterable<E> take(int count) { 690 dynamic result;
601 RangeError.checkNotNegative(count, "count"); 691 do {
602 return this; 692 result = it.current;
603 } 693 }
604 Iterable<E> takeWhile(bool test(E element)) => this; 694 while (it.moveNext()); return result;
605 List toList({bool growable: true}) => growable ? <E>[] : new List<E>(0); 695 }
606 Set toSet() => new Set<E>(); 696 static dynamic single(Iterable iterable) {
607 } 697 Iterator it = iterable.iterator;
608 class EmptyIterator<E> implements Iterator<E> { 698 if (!it.moveNext()) throw IterableElementError.noElement();
609 const EmptyIterator(); 699 dynamic result = it.current;
610 bool moveNext() => false; 700 if (it.moveNext()) throw IterableElementError.tooMany();
611 E get current => ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", 701 return result;
612 """line 752, column 20 of dart:_internal/iterable.dart: """, __x9 is E, 702 }
613 false))(null); 703 static dynamic firstWhere(Iterable iterable, bool test(dynamic value), dynamic orElse()) {
614 } 704 for (dynamic element in iterable) {
615 abstract class BidirectionalIterator<T> implements Iterator<T> { 705 if (test(element)) return element;
616 bool movePrevious(); 706 }
617 } 707 if (orElse != null) return orElse();
618 class IterableMixinWorkaround<T> { 708 throw IterableElementError.noElement();
619 static bool contains(Iterable iterable, var element) { 709 }
620 for (final e in iterable) { 710 static dynamic lastWhere(Iterable iterable, bool test(dynamic value), dynamic o rElse()) {
621 if (e == element) return true; 711 dynamic result = null;
622 } 712 bool foundMatching = false;
623 return false; 713 for (dynamic element in iterable) {
624 } 714 if (test(element)) {
625 static void forEach(Iterable iterable, void f(o)) { 715 result = element;
626 for (final e in iterable) { 716 foundMatching = true;
627 f(e); 717 }
628 } 718 }
629 } 719 if (foundMatching) return result;
630 static bool any(Iterable iterable, bool f(o)) { 720 if (orElse != null) return orElse();
631 for (final e in iterable) { 721 throw IterableElementError.noElement();
632 if (f(e)) return true; 722 }
633 } 723 static dynamic lastWhereList(List list, bool test(dynamic value), dynamic orEls e()) {
634 return false; 724 for (int i = list.length - 1;
635 } 725 i >= 0;
636 static bool every(Iterable iterable, bool f(o)) { 726 i--) {
637 for (final e in iterable) { 727 dynamic element = list[i];
638 if (!f(e)) return false; 728 if (test(element)) return element;
639 } 729 }
640 return true; 730 if (orElse != null) return orElse();
641 } 731 throw IterableElementError.noElement();
642 static dynamic reduce( 732 }
643 Iterable iterable, dynamic combine(previousValue, element)) { 733 static dynamic singleWhere(Iterable iterable, bool test(dynamic value)) {
644 Iterator iterator = iterable.iterator; 734 dynamic result = null;
645 if (!iterator.moveNext()) throw IterableElementError.noElement(); 735 bool foundMatching = false;
646 var value = iterator.current; 736 for (dynamic element in iterable) {
647 while (iterator.moveNext()) { 737 if (test(element)) {
648 value = combine(value, iterator.current); 738 if (foundMatching) {
649 } 739 throw IterableElementError.tooMany();
650 return value; 740 }
651 } 741 result = element;
652 static dynamic fold(Iterable iterable, dynamic initialValue, 742 foundMatching = true;
653 dynamic combine(dynamic previousValue, element)) { 743 }
654 for (final element in iterable) { 744 }
655 initialValue = combine(initialValue, element); 745 if (foundMatching) return result;
656 } 746 throw IterableElementError.noElement();
657 return initialValue; 747 }
658 } 748 static elementAt(Iterable iterable, int index) {
659 static void removeWhereList(List list, bool test(var element)) { 749 if (index is! int) throw new ArgumentError.notNull("index");
660 List retained = []; 750 RangeError.checkNotNegative(index, "index");
661 int length = list.length; 751 int elementIndex = 0;
662 for (int i = 0; i < length; i++) { 752 for (var element in iterable) {
663 var element = list[i]; 753 if (index == elementIndex) return element;
664 if (!test(element)) { 754 elementIndex++;
665 retained.add(element); 755 }
666 } 756 throw new RangeError.index(index, iterable, "index", null, elementIndex);
667 if (length != list.length) { 757 }
668 throw new ConcurrentModificationError(list); 758 static String join(Iterable iterable, [String separator]) {
669 } 759 StringBuffer buffer = new StringBuffer();
670 } 760 buffer.writeAll(iterable, separator);
671 if (retained.length == length) return; 761 return buffer.toString();
672 list.length = retained.length; 762 }
673 for (int i = 0; i < retained.length; i++) { 763 static String joinList(List list, [String separator]) {
674 list[i] = retained[i]; 764 if (list.isEmpty) return "";
675 } 765 if (list.length == 1) return "${list[0]}
676 } 766 ";
677 static bool isEmpty(Iterable iterable) { 767 StringBuffer buffer = new StringBuffer();
678 return !iterable.iterator.moveNext(); 768 if (separator.isEmpty) {
679 } 769 for (int i = 0;
680 static dynamic first(Iterable iterable) { 770 i < list.length;
681 Iterator it = iterable.iterator; 771 i++) {
682 if (!it.moveNext()) { 772 buffer.write(list[i]);
683 throw IterableElementError.noElement(); 773 }
684 } 774 }
685 return it.current; 775 else {
686 } 776 buffer.write(list[0]);
687 static dynamic last(Iterable iterable) { 777 for (int i = 1;
688 Iterator it = iterable.iterator; 778 i < list.length;
689 if (!it.moveNext()) { 779 i++) {
690 throw IterableElementError.noElement(); 780 buffer.write(separator);
691 } 781 buffer.write(list[i]);
692 dynamic result; 782 }
693 do { 783 }
694 result = it.current; 784 return buffer.toString();
695 } while (it.moveNext()); 785 }
696 return result; 786 Iterable<T> where(Iterable iterable, bool f(var element)) {
697 } 787 return new WhereIterable<T>(iterable, f);
698 static dynamic single(Iterable iterable) { 788 }
699 Iterator it = iterable.iterator; 789 static Iterable map(Iterable iterable, f(var element)) {
700 if (!it.moveNext()) throw IterableElementError.noElement(); 790 return new MappedIterable(iterable, f);
701 dynamic result = it.current; 791 }
702 if (it.moveNext()) throw IterableElementError.tooMany(); 792 static Iterable mapList(List list, f(var element)) {
703 return result; 793 return new MappedListIterable(list, f);
704 } 794 }
705 static dynamic firstWhere( 795 static Iterable expand(Iterable iterable, Iterable f(var element)) {
706 Iterable iterable, bool test(dynamic value), dynamic orElse()) { 796 return new ExpandIterable(iterable, f);
707 for (dynamic element in iterable) { 797 }
708 if (test(element)) return element; 798 Iterable<T> takeList(List list, int n) {
709 } 799 return new SubListIterable<T>(list, 0, n);
710 if (orElse != null) return orElse(); 800 }
711 throw IterableElementError.noElement(); 801 Iterable<T> takeWhile(Iterable iterable, bool test(var value)) {
712 } 802 return new TakeWhileIterable<T>(iterable, test);
713 static dynamic lastWhere( 803 }
714 Iterable iterable, bool test(dynamic value), dynamic orElse()) { 804 Iterable<T> skipList(List list, int n) {
715 dynamic result = null; 805 return new SubListIterable<T>(list, n, null);
716 bool foundMatching = false; 806 }
717 for (dynamic element in iterable) { 807 Iterable<T> skipWhile(Iterable iterable, bool test(var value)) {
718 if (test(element)) { 808 return new SkipWhileIterable<T>(iterable, test);
719 result = element; 809 }
720 foundMatching = true; 810 Iterable<T> reversedList(List list) {
721 } 811 return new ReversedListIterable<T>(list);
722 } 812 }
723 if (foundMatching) return result; 813 static void sortList(List list, int compare(a, b)) {
724 if (orElse != null) return orElse(); 814 if (compare == null) compare = DDC$RT.wrap((int f(Comparable<dynamic> __u10, Com parable<dynamic> __u11)) {
725 throw IterableElementError.noElement(); 815 int c(Comparable<dynamic> x0, Comparable<dynamic> x1) => f(DDC$RT.cast(x0, dynam ic, DDC$RT.type((Comparable<dynamic> _) {
726 } 816 }
727 static dynamic lastWhereList( 817 ), "CastParam", """line 1001, column 36 of dart:_internal/iterable.dart: """, x0 is Comparable<dynamic>, true), DDC$RT.cast(x1, dynamic, DDC$RT.type((Comparable <dynamic> _) {
728 List list, bool test(dynamic value), dynamic orElse()) { 818 }
729 for (int i = list.length - 1; i >= 0; i--) { 819 ), "CastParam", """line 1001, column 36 of dart:_internal/iterable.dart: """, x1 is Comparable<dynamic>, true));
730 dynamic element = list[i]; 820 return f == null ? null : c;
731 if (test(element)) return element; 821 }
732 } 822 , Comparable.compare, __t15, __t12, "Wrap", """line 1001, column 36 of dart:_int ernal/iterable.dart: """, Comparable.compare is __t12);
733 if (orElse != null) return orElse(); 823 Sort.sort(list, compare);
734 throw IterableElementError.noElement(); 824 }
735 } 825 static void shuffleList(List list, Random random) {
736 static dynamic singleWhere(Iterable iterable, bool test(dynamic value)) { 826 if (random == null) random = new Random();
737 dynamic result = null; 827 int length = list.length;
738 bool foundMatching = false; 828 while (length > 1) {
739 for (dynamic element in iterable) { 829 int pos = random.nextInt(length);
740 if (test(element)) { 830 length -= 1;
741 if (foundMatching) { 831 var tmp = list[length];
742 throw IterableElementError.tooMany(); 832 list[length] = list[pos];
743 } 833 list[pos] = tmp;
744 result = element; 834 }
745 foundMatching = true; 835 }
746 } 836 static int indexOfList(List list, var element, int start) {
747 } 837 return Lists.indexOf(list, element, start, list.length);
748 if (foundMatching) return result; 838 }
749 throw IterableElementError.noElement(); 839 static int lastIndexOfList(List list, var element, int start) {
750 } 840 if (start == null) start = list.length - 1;
751 static elementAt(Iterable iterable, int index) { 841 return Lists.lastIndexOf(list, element, start);
752 if (index is! int) throw new ArgumentError.notNull("index"); 842 }
753 RangeError.checkNotNegative(index, "index"); 843 static void _rangeCheck(List list, int start, int end) {
754 int elementIndex = 0; 844 RangeError.checkValidRange(start, end, list.length);
755 for (var element in iterable) { 845 }
756 if (index == elementIndex) return element; 846 Iterable<T> getRangeList(List list, int start, int end) {
757 elementIndex++; 847 _rangeCheck(list, start, end);
758 } 848 return new SubListIterable<T>(list, start, end);
759 throw new RangeError.index(index, iterable, "index", null, elementIndex); 849 }
760 } 850 static void setRangeList(List list, int start, int end, Iterable from, int skip Count) {
761 static String join(Iterable iterable, [String separator]) { 851 _rangeCheck(list, start, end);
762 StringBuffer buffer = new StringBuffer(); 852 int length = end - start;
763 buffer.writeAll(iterable, separator); 853 if (length == 0) return; if (skipCount < 0) throw new ArgumentError(skipCount);
764 return buffer.toString(); 854 List otherList;
765 } 855 int otherStart;
766 static String joinList(List list, [String separator]) { 856 if (from is List) {
767 if (list.isEmpty) return ""; 857 otherList = from;
768 if (list.length == 1) return "${list[0]}"; 858 otherStart = skipCount;
769 StringBuffer buffer = new StringBuffer(); 859 }
770 if (separator.isEmpty) { 860 else {
771 for (int i = 0; i < list.length; i++) { 861 otherList = from.skip(skipCount).toList(growable: false);
772 buffer.write(list[i]); 862 otherStart = 0;
773 } 863 }
774 } else { 864 if (otherStart + length > otherList.length) {
775 buffer.write(list[0]); 865 throw IterableElementError.tooFew();
776 for (int i = 1; i < list.length; i++) { 866 }
777 buffer.write(separator); 867 Lists.copy(otherList, otherStart, list, start, length);
778 buffer.write(list[i]); 868 }
779 } 869 static void replaceRangeList(List list, int start, int end, Iterable iterable) {
780 } 870 _rangeCheck(list, start, end);
781 return buffer.toString(); 871 if (iterable is! EfficientLength) {
782 } 872 iterable = iterable.toList();
783 Iterable<T> where(Iterable iterable, bool f(var element)) { 873 }
784 return new WhereIterable<T>(iterable, f); 874 int removeLength = end - start;
785 } 875 int insertLength = iterable.length;
786 static Iterable map(Iterable iterable, f(var element)) { 876 if (removeLength >= insertLength) {
787 return new MappedIterable(iterable, f); 877 int delta = removeLength - insertLength;
788 } 878 int insertEnd = start + insertLength;
789 static Iterable mapList(List list, f(var element)) { 879 int newEnd = list.length - delta;
790 return new MappedListIterable(list, f); 880 list.setRange(start, insertEnd, iterable);
791 } 881 if (delta != 0) {
792 static Iterable expand(Iterable iterable, Iterable f(var element)) { 882 list.setRange(insertEnd, newEnd, list, end);
793 return new ExpandIterable(iterable, f); 883 list.length = newEnd;
794 } 884 }
795 Iterable<T> takeList(List list, int n) { 885 }
796 return new SubListIterable<T>(list, 0, n); 886 else {
797 } 887 int delta = insertLength - removeLength;
798 Iterable<T> takeWhile(Iterable iterable, bool test(var value)) { 888 int newLength = list.length + delta;
799 return new TakeWhileIterable<T>(iterable, test); 889 int insertEnd = start + insertLength;
800 } 890 list.length = newLength;
801 Iterable<T> skipList(List list, int n) { 891 list.setRange(insertEnd, newLength, list, end);
802 return new SubListIterable<T>(list, n, null); 892 list.setRange(start, insertEnd, iterable);
803 } 893 }
804 Iterable<T> skipWhile(Iterable iterable, bool test(var value)) { 894 }
805 return new SkipWhileIterable<T>(iterable, test); 895 static void fillRangeList(List list, int start, int end, fillValue) {
806 } 896 _rangeCheck(list, start, end);
807 Iterable<T> reversedList(List list) { 897 for (int i = start;
808 return new ReversedListIterable<T>(list); 898 i < end;
809 } 899 i++) {
810 static void sortList(List list, int compare(a, b)) { 900 list[i] = fillValue;
811 if (compare == null) compare = DDC$RT.wrap( 901 }
812 (int f(Comparable<dynamic> __u10, Comparable<dynamic> __u11)) { 902 }
813 int c(Comparable<dynamic> x0, Comparable<dynamic> x1) => f(DDC$RT.cast(x0, 903 static void insertAllList(List list, int index, Iterable iterable) {
814 dynamic, DDC$RT.type((Comparable<dynamic> _) {}), "CastParam", 904 RangeError.checkValueInInterval(index, 0, list.length, "index");
815 """line 1001, column 36 of dart:_internal/iterable.dart: """, 905 if (iterable is! EfficientLength) {
816 x0 is Comparable<dynamic>, true), DDC$RT.cast(x1, dynamic, 906 iterable = iterable.toList(growable: false);
817 DDC$RT.type((Comparable<dynamic> _) {}), "CastParam", 907 }
818 """line 1001, column 36 of dart:_internal/iterable.dart: """, 908 int insertionLength = iterable.length;
819 x1 is Comparable<dynamic>, true)); 909 list.length += insertionLength;
820 return f == null ? null : c; 910 list.setRange(index + insertionLength, list.length, list, index);
821 }, Comparable.compare, __t15, __t12, "Wrap", 911 for (var element in iterable) {
822 """line 1001, column 36 of dart:_internal/iterable.dart: """, 912 list[index++] = element;
823 Comparable.compare is __t12); 913 }
824 Sort.sort(list, compare); 914 }
825 } 915 static void setAllList(List list, int index, Iterable iterable) {
826 static void shuffleList(List list, Random random) { 916 RangeError.checkValueInInterval(index, 0, list.length, "index");
827 if (random == null) random = new Random(); 917 for (var element in iterable) {
828 int length = list.length; 918 list[index++] = element;
829 while (length > 1) { 919 }
830 int pos = random.nextInt(length); 920 }
831 length -= 1; 921 Map<int, T> asMapList(List l) {
832 var tmp = list[length]; 922 return new ListMapView<T>(l);
833 list[length] = list[pos]; 923 }
834 list[pos] = tmp; 924 static bool setContainsAll(Set set, Iterable other) {
835 } 925 for (var element in other) {
836 } 926 if (!set.contains(element)) return false;
837 static int indexOfList(List list, var element, int start) { 927 }
838 return Lists.indexOf(list, element, start, list.length); 928 return true;
839 } 929 }
840 static int lastIndexOfList(List list, var element, int start) { 930 static Set setIntersection(Set set, Set other, Set result) {
841 if (start == null) start = list.length - 1; 931 Set smaller;
842 return Lists.lastIndexOf(list, element, start); 932 Set larger;
843 } 933 if (set.length < other.length) {
844 static void _rangeCheck(List list, int start, int end) { 934 smaller = set;
845 RangeError.checkValidRange(start, end, list.length); 935 larger = other;
846 } 936 }
847 Iterable<T> getRangeList(List list, int start, int end) { 937 else {
848 _rangeCheck(list, start, end); 938 smaller = other;
849 return new SubListIterable<T>(list, start, end); 939 larger = set;
850 } 940 }
851 static void setRangeList( 941 for (var element in smaller) {
852 List list, int start, int end, Iterable from, int skipCount) { 942 if (larger.contains(element)) {
853 _rangeCheck(list, start, end); 943 result.add(element);
854 int length = end - start; 944 }
855 if (length == 0) return; 945 }
856 if (skipCount < 0) throw new ArgumentError(skipCount); 946 return result;
857 List otherList; 947 }
858 int otherStart; 948 static Set setUnion(Set set, Set other, Set result) {
859 if (from is List) { 949 result.addAll(set);
860 otherList = from; 950 result.addAll(other);
861 otherStart = skipCount; 951 return result;
862 } else { 952 }
863 otherList = from.skip(skipCount).toList(growable: false); 953 static Set setDifference(Set set, Set other, Set result) {
864 otherStart = 0; 954 for (var element in set) {
865 } 955 if (!other.contains(element)) {
866 if (otherStart + length > otherList.length) { 956 result.add(element);
867 throw IterableElementError.tooFew(); 957 }
868 } 958 }
869 Lists.copy(otherList, otherStart, list, start, length); 959 return result;
870 } 960 }
871 static void replaceRangeList( 961 }
872 List list, int start, int end, Iterable iterable) { 962 abstract class IterableElementError {static StateError noElement() => new State Error("No element");
873 _rangeCheck(list, start, end); 963 static StateError tooMany() => new StateError("Too many elements");
874 if (iterable is! EfficientLength) { 964 static StateError tooFew() => new StateError("Too few elements");
875 iterable = iterable.toList(); 965 }
876 } 966 typedef int __t12(dynamic __u13, dynamic __u14);
877 int removeLength = end - start; 967 typedef int __t15(Comparable<dynamic> __u16, Comparable<dynamic> __u17);
878 int insertLength = iterable.length;
879 if (removeLength >= insertLength) {
880 int delta = removeLength - insertLength;
881 int insertEnd = start + insertLength;
882 int newEnd = list.length - delta;
883 list.setRange(start, insertEnd, iterable);
884 if (delta != 0) {
885 list.setRange(insertEnd, newEnd, list, end);
886 list.length = newEnd;
887 }
888 } else {
889 int delta = insertLength - removeLength;
890 int newLength = list.length + delta;
891 int insertEnd = start + insertLength;
892 list.length = newLength;
893 list.setRange(insertEnd, newLength, list, end);
894 list.setRange(start, insertEnd, iterable);
895 }
896 }
897 static void fillRangeList(List list, int start, int end, fillValue) {
898 _rangeCheck(list, start, end);
899 for (int i = start; i < end; i++) {
900 list[i] = fillValue;
901 }
902 }
903 static void insertAllList(List list, int index, Iterable iterable) {
904 RangeError.checkValueInInterval(index, 0, list.length, "index");
905 if (iterable is! EfficientLength) {
906 iterable = iterable.toList(growable: false);
907 }
908 int insertionLength = iterable.length;
909 list.length += insertionLength;
910 list.setRange(index + insertionLength, list.length, list, index);
911 for (var element in iterable) {
912 list[index++] = element;
913 }
914 }
915 static void setAllList(List list, int index, Iterable iterable) {
916 RangeError.checkValueInInterval(index, 0, list.length, "index");
917 for (var element in iterable) {
918 list[index++] = element;
919 }
920 }
921 Map<int, T> asMapList(List l) {
922 return new ListMapView<T>(l);
923 }
924 static bool setContainsAll(Set set, Iterable other) {
925 for (var element in other) {
926 if (!set.contains(element)) return false;
927 }
928 return true;
929 }
930 static Set setIntersection(Set set, Set other, Set result) {
931 Set smaller;
932 Set larger;
933 if (set.length < other.length) {
934 smaller = set;
935 larger = other;
936 } else {
937 smaller = other;
938 larger = set;
939 }
940 for (var element in smaller) {
941 if (larger.contains(element)) {
942 result.add(element);
943 }
944 }
945 return result;
946 }
947 static Set setUnion(Set set, Set other, Set result) {
948 result.addAll(set);
949 result.addAll(other);
950 return result;
951 }
952 static Set setDifference(Set set, Set other, Set result) {
953 for (var element in set) {
954 if (!other.contains(element)) {
955 result.add(element);
956 }
957 }
958 return result;
959 }
960 }
961 abstract class IterableElementError {
962 static StateError noElement() => new StateError("No element");
963 static StateError tooMany() => new StateError("Too many elements");
964 static StateError tooFew() => new StateError("Too few elements");
965 }
966 typedef int __t12(dynamic __u13, dynamic __u14);
967 typedef int __t15(Comparable<dynamic> __u16, Comparable<dynamic> __u17);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698