| OLD | NEW |
| 1 part of dart._internal; | 1 part of dart._internal; |
| 2 abstract class EfficientLength {int get length; | 2 abstract class EfficientLength {int get length; |
| 3 } | 3 } |
| 4 abstract class ListIterable<E> extends IterableBase<E> implements EfficientLeng
th {int get length; | 4 abstract class ListIterable<E> extends IterableBase<E> implements EfficientLeng
th {int get length; |
| 5 E elementAt(int i); | 5 E elementAt(int i); |
| 6 const ListIterable(); | 6 const ListIterable(); |
| 7 Iterator<E> get iterator => new ListIterator<E>(this); | 7 Iterator<E> get iterator => new ListIterator<E>(this); |
| 8 void forEach(void action(E element)) { | 8 void forEach(void action(E element)) { |
| 9 int length = this.length; | 9 int length = this.length; |
| 10 for (int i = 0; | 10 for (int i = 0; i < length; i++) { |
| 11 i < length; | |
| 12 i++) { | |
| 13 action(elementAt(i)); | 11 action(elementAt(i)); |
| 14 if (length != this.length) { | 12 if (length != this.length) { |
| 15 throw new ConcurrentModificationError(this); | 13 throw new ConcurrentModificationError(this); |
| 16 } | 14 } |
| 17 } | 15 } |
| 18 } | 16 } |
| 19 bool get isEmpty => length == 0; | 17 bool get isEmpty => length == 0; |
| 20 E get first { | 18 E get first { |
| 21 if (length == 0) throw IterableElementError.noElement(); | 19 if (length == 0) throw IterableElementError.noElement(); |
| 22 return elementAt(0); | 20 return elementAt(0); |
| 23 } | 21 } |
| 24 E get last { | 22 E get last { |
| 25 if (length == 0) throw IterableElementError.noElement(); | 23 if (length == 0) throw IterableElementError.noElement(); |
| 26 return elementAt(length - 1); | 24 return elementAt(length - 1); |
| 27 } | 25 } |
| 28 E get single { | 26 E get single { |
| 29 if (length == 0) throw IterableElementError.noElement(); | 27 if (length == 0) throw IterableElementError.noElement(); |
| 30 if (length > 1) throw IterableElementError.tooMany(); | 28 if (length > 1) throw IterableElementError.tooMany(); |
| 31 return elementAt(0); | 29 return elementAt(0); |
| 32 } | 30 } |
| 33 bool contains(Object element) { | 31 bool contains(Object element) { |
| 34 int length = this.length; | 32 int length = this.length; |
| 35 for (int i = 0; | 33 for (int i = 0; i < length; i++) { |
| 36 i < length; | |
| 37 i++) { | |
| 38 if (elementAt(i) == element) return true; | 34 if (elementAt(i) == element) return true; |
| 39 if (length != this.length) { | 35 if (length != this.length) { |
| 40 throw new ConcurrentModificationError(this); | 36 throw new ConcurrentModificationError(this); |
| 41 } | 37 } |
| 42 } | 38 } |
| 43 return false; | 39 return false; |
| 44 } | 40 } |
| 45 bool every(bool test(E element)) { | 41 bool every(bool test(E element)) { |
| 46 int length = this.length; | 42 int length = this.length; |
| 47 for (int i = 0; | 43 for (int i = 0; i < length; i++) { |
| 48 i < length; | |
| 49 i++) { | |
| 50 if (!test(elementAt(i))) return false; | 44 if (!test(elementAt(i))) return false; |
| 51 if (length != this.length) { | 45 if (length != this.length) { |
| 52 throw new ConcurrentModificationError(this); | 46 throw new ConcurrentModificationError(this); |
| 53 } | 47 } |
| 54 } | 48 } |
| 55 return true; | 49 return true; |
| 56 } | 50 } |
| 57 bool any(bool test(E element)) { | 51 bool any(bool test(E element)) { |
| 58 int length = this.length; | 52 int length = this.length; |
| 59 for (int i = 0; | 53 for (int i = 0; i < length; i++) { |
| 60 i < length; | |
| 61 i++) { | |
| 62 if (test(elementAt(i))) return true; | 54 if (test(elementAt(i))) return true; |
| 63 if (length != this.length) { | 55 if (length != this.length) { |
| 64 throw new ConcurrentModificationError(this); | 56 throw new ConcurrentModificationError(this); |
| 65 } | 57 } |
| 66 } | 58 } |
| 67 return false; | 59 return false; |
| 68 } | 60 } |
| 69 E firstWhere(bool test(E element), { | 61 E firstWhere(bool test(E element), { |
| 70 E orElse()} | 62 E orElse()} |
| 71 ) { | 63 ) { |
| 72 int length = this.length; | 64 int length = this.length; |
| 73 for (int i = 0; | 65 for (int i = 0; i < length; i++) { |
| 74 i < length; | |
| 75 i++) { | |
| 76 E element = elementAt(i); | 66 E element = elementAt(i); |
| 77 if (test(element)) return element; | 67 if (test(element)) return element; |
| 78 if (length != this.length) { | 68 if (length != this.length) { |
| 79 throw new ConcurrentModificationError(this); | 69 throw new ConcurrentModificationError(this); |
| 80 } | 70 } |
| 81 } | 71 } |
| 82 if (orElse != null) return orElse(); | 72 if (orElse != null) return orElse(); |
| 83 throw IterableElementError.noElement(); | 73 throw IterableElementError.noElement(); |
| 84 } | 74 } |
| 85 E lastWhere(bool test(E element), { | 75 E lastWhere(bool test(E element), { |
| 86 E orElse()} | 76 E orElse()} |
| 87 ) { | 77 ) { |
| 88 int length = this.length; | 78 int length = this.length; |
| 89 for (int i = length - 1; | 79 for (int i = length - 1; i >= 0; i--) { |
| 90 i >= 0; | |
| 91 i--) { | |
| 92 E element = elementAt(i); | 80 E element = elementAt(i); |
| 93 if (test(element)) return element; | 81 if (test(element)) return element; |
| 94 if (length != this.length) { | 82 if (length != this.length) { |
| 95 throw new ConcurrentModificationError(this); | 83 throw new ConcurrentModificationError(this); |
| 96 } | 84 } |
| 97 } | 85 } |
| 98 if (orElse != null) return orElse(); | 86 if (orElse != null) return orElse(); |
| 99 throw IterableElementError.noElement(); | 87 throw IterableElementError.noElement(); |
| 100 } | 88 } |
| 101 E singleWhere(bool test(E element)) { | 89 E singleWhere(bool test(E element)) { |
| 102 int length = this.length; | 90 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); | 91 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; | 92 bool matchFound = false; |
| 105 for (int i = 0; | 93 for (int i = 0; i < length; i++) { |
| 106 i < length; | |
| 107 i++) { | |
| 108 E element = elementAt(i); | 94 E element = elementAt(i); |
| 109 if (test(element)) { | 95 if (test(element)) { |
| 110 if (matchFound) { | 96 if (matchFound) { |
| 111 throw IterableElementError.tooMany(); | 97 throw IterableElementError.tooMany(); |
| 112 } | 98 } |
| 113 matchFound = true; | 99 matchFound = true; |
| 114 match = element; | 100 match = element; |
| 115 } | 101 } |
| 116 if (length != this.length) { | 102 if (length != this.length) { |
| 117 throw new ConcurrentModificationError(this); | 103 throw new ConcurrentModificationError(this); |
| 118 } | 104 } |
| 119 } | 105 } |
| 120 if (matchFound) return match; | 106 if (matchFound) return match; |
| 121 throw IterableElementError.noElement(); | 107 throw IterableElementError.noElement(); |
| 122 } | 108 } |
| 123 String join([String separator = ""]) { | 109 String join([String separator = ""]) { |
| 124 int length = this.length; | 110 int length = this.length; |
| 125 if (!separator.isEmpty) { | 111 if (!separator.isEmpty) { |
| 126 if (length == 0) return ""; | 112 if (length == 0) return ""; |
| 127 String first = "${elementAt(0)} | 113 String first = "${elementAt(0)}"; |
| 128 "; | |
| 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) { | 114 if (length != this.length) { |
| 139 throw new ConcurrentModificationError(this); | 115 throw new ConcurrentModificationError(this); |
| 140 } | 116 } |
| 117 StringBuffer buffer = new StringBuffer(first); |
| 118 for (int i = 1; i < length; i++) { |
| 119 buffer.write(separator); |
| 120 buffer.write(elementAt(i)); |
| 121 if (length != this.length) { |
| 122 throw new ConcurrentModificationError(this); |
| 123 } |
| 124 } |
| 125 return buffer.toString(); |
| 141 } | 126 } |
| 142 return buffer.toString(); | |
| 143 } | |
| 144 else { | 127 else { |
| 145 StringBuffer buffer = new StringBuffer(); | 128 StringBuffer buffer = new StringBuffer(); |
| 146 for (int i = 0; | 129 for (int i = 0; i < length; i++) { |
| 147 i < length; | 130 buffer.write(elementAt(i)); |
| 148 i++) { | 131 if (length != this.length) { |
| 149 buffer.write(elementAt(i)); | 132 throw new ConcurrentModificationError(this); |
| 150 if (length != this.length) { | 133 } |
| 151 throw new ConcurrentModificationError(this); | |
| 152 } | 134 } |
| 135 return buffer.toString(); |
| 153 } | 136 } |
| 154 return buffer.toString(); | |
| 155 } | |
| 156 } | 137 } |
| 157 Iterable<E> where(bool test(E element)) => super.where(test); | 138 Iterable<E> where(bool test(E element)) => super.where(test); |
| 158 Iterable map(f(E element)) => new MappedListIterable(this, f); | 139 Iterable map(f(E element)) => new MappedListIterable(this, f); |
| 159 E reduce(E combine(var value, E element)) { | 140 E reduce(E combine(var value, E element)) { |
| 160 int length = this.length; | 141 int length = this.length; |
| 161 if (length == 0) throw IterableElementError.noElement(); | 142 if (length == 0) throw IterableElementError.noElement(); |
| 162 E value = elementAt(0); | 143 E value = elementAt(0); |
| 163 for (int i = 1; | 144 for (int i = 1; i < length; i++) { |
| 164 i < length; | 145 value = combine(value, elementAt(i)); |
| 165 i++) { | 146 if (length != this.length) { |
| 166 value = combine(value, elementAt(i)); | 147 throw new ConcurrentModificationError(this); |
| 167 if (length != this.length) { | 148 } |
| 168 throw new ConcurrentModificationError(this); | |
| 169 } | 149 } |
| 170 } | |
| 171 return value; | 150 return value; |
| 172 } | 151 } |
| 173 fold(var initialValue, combine(var previousValue, E element)) { | 152 fold(var initialValue, combine(var previousValue, E element)) { |
| 174 var value = initialValue; | 153 var value = initialValue; |
| 175 int length = this.length; | 154 int length = this.length; |
| 176 for (int i = 0; | 155 for (int i = 0; i < length; i++) { |
| 177 i < length; | 156 value = combine(value, elementAt(i)); |
| 178 i++) { | 157 if (length != this.length) { |
| 179 value = combine(value, elementAt(i)); | 158 throw new ConcurrentModificationError(this); |
| 180 if (length != this.length) { | 159 } |
| 181 throw new ConcurrentModificationError(this); | |
| 182 } | 160 } |
| 183 } | |
| 184 return value; | 161 return value; |
| 185 } | 162 } |
| 186 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); | 163 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); |
| 187 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test); | 164 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test); |
| 188 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); | 165 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); |
| 189 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test); | 166 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test); |
| 190 List<E> toList({ | 167 List<E> toList({ |
| 191 bool growable : true} | 168 bool growable : true} |
| 192 ) { | 169 ) { |
| 193 List<E> result; | 170 List<E> result; |
| 194 if (growable) { | 171 if (growable) { |
| 195 result = new List<E>()..length = length; | 172 result = new List<E>()..length = length; |
| 196 } | 173 } |
| 197 else { | 174 else { |
| 198 result = new List<E>(length); | 175 result = new List<E>(length); |
| 199 } | 176 } |
| 200 for (int i = 0; | 177 for (int i = 0; i < length; i++) { |
| 201 i < length; | 178 result[i] = elementAt(i); |
| 202 i++) { | 179 } |
| 203 result[i] = elementAt(i); | |
| 204 } | |
| 205 return result; | 180 return result; |
| 206 } | 181 } |
| 207 Set<E> toSet() { | 182 Set<E> toSet() { |
| 208 Set<E> result = new Set<E>(); | 183 Set<E> result = new Set<E>(); |
| 209 for (int i = 0; | 184 for (int i = 0; i < length; i++) { |
| 210 i < length; | 185 result.add(elementAt(i)); |
| 211 i++) { | 186 } |
| 212 result.add(elementAt(i)); | |
| 213 } | |
| 214 return result; | 187 return result; |
| 215 } | 188 } |
| 216 } | 189 } |
| 217 class SubListIterable<E> extends ListIterable<E> {final Iterable<E> _iterable; | 190 class SubListIterable<E> extends ListIterable<E> {final Iterable<E> _iterable; |
| 218 final int _start; | 191 final int _start; |
| 219 final int _endOrLength; | 192 final int _endOrLength; |
| 220 SubListIterable(this._iterable, this._start, this._endOrLength) { | 193 SubListIterable(this._iterable, this._start, this._endOrLength) { |
| 221 RangeError.checkNotNegative(_start, "start"); | 194 RangeError.checkNotNegative(_start, "start"); |
| 222 if (_endOrLength != null) { | 195 if (_endOrLength != null) { |
| 223 RangeError.checkNotNegative(_endOrLength, "end"); | 196 RangeError.checkNotNegative(_endOrLength, "end"); |
| 224 if (_start > _endOrLength) { | 197 if (_start > _endOrLength) { |
| 225 throw new RangeError.range(_start, 0, _endOrLength, "start"); | 198 throw new RangeError.range(_start, 0, _endOrLength, "start"); |
| 226 } | 199 } |
| 227 } | 200 } |
| 228 } | 201 } |
| 229 int get _endIndex { | 202 int get _endIndex { |
| 230 int length = _iterable.length; | 203 int length = _iterable.length; |
| 231 if (_endOrLength == null || _endOrLength > length) return length; | 204 if (_endOrLength == null || _endOrLength > length) return length; |
| 232 return _endOrLength; | 205 return _endOrLength; |
| 233 } | 206 } |
| 234 int get _startIndex { | 207 int get _startIndex { |
| 235 int length = _iterable.length; | 208 int length = _iterable.length; |
| 236 if (_start > length) return length; | 209 if (_start > length) return length; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 245 } |
| 273 List<E> toList({ | 246 List<E> toList({ |
| 274 bool growable : true} | 247 bool growable : true} |
| 275 ) { | 248 ) { |
| 276 int start = _start; | 249 int start = _start; |
| 277 int end = _iterable.length; | 250 int end = _iterable.length; |
| 278 if (_endOrLength != null && _endOrLength < end) end = _endOrLength; | 251 if (_endOrLength != null && _endOrLength < end) end = _endOrLength; |
| 279 int length = end - start; | 252 int length = end - start; |
| 280 if (length < 0) length = 0; | 253 if (length < 0) length = 0; |
| 281 List result = growable ? (new List<E>()..length = length) : new List<E>(length)
; | 254 List result = growable ? (new List<E>()..length = length) : new List<E>(length)
; |
| 282 for (int i = 0; | 255 for (int i = 0; i < length; i++) { |
| 283 i < length; | |
| 284 i++) { | |
| 285 result[i] = _iterable.elementAt(start + i); | 256 result[i] = _iterable.elementAt(start + i); |
| 286 if (_iterable.length < end) throw new ConcurrentModificationError(this); | 257 if (_iterable.length < end) throw new ConcurrentModificationError(this); |
| 287 } | 258 } |
| 288 return DDC$RT.cast(result, DDC$RT.type((List<dynamic> _) { | 259 return DDC$RT.cast(result, DDC$RT.type((List<dynamic> _) { |
| 289 } | 260 } |
| 290 ), DDC$RT.type((List<E> _) { | 261 ), DDC$RT.type((List<E> _) { |
| 291 } | 262 } |
| 292 ), "CastDynamic", """line 310, column 12 of dart:_internal/iterable.dart: """, r
esult is List<E>, false); | 263 ), "CastDynamic", """line 310, column 12 of dart:_internal/iterable.dart: """, r
esult is List<E>, false); |
| 293 } | 264 } |
| 294 } | 265 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 int length = _iterable.length - _skipCount; | 476 int length = _iterable.length - _skipCount; |
| 506 if (length >= 0) return length; | 477 if (length >= 0) return length; |
| 507 return 0; | 478 return 0; |
| 508 } | 479 } |
| 509 } | 480 } |
| 510 class SkipIterator<E> extends Iterator<E> {final Iterator<E> _iterator; | 481 class SkipIterator<E> extends Iterator<E> {final Iterator<E> _iterator; |
| 511 int _skipCount; | 482 int _skipCount; |
| 512 SkipIterator(this._iterator, this._skipCount) { | 483 SkipIterator(this._iterator, this._skipCount) { |
| 513 assert (_skipCount is int && _skipCount >= 0);} | 484 assert (_skipCount is int && _skipCount >= 0);} |
| 514 bool moveNext() { | 485 bool moveNext() { |
| 515 for (int i = 0; | 486 for (int i = 0; i < _skipCount; i++) _iterator.moveNext(); |
| 516 i < _skipCount; | |
| 517 i++) _iterator.moveNext(); | |
| 518 _skipCount = 0; | 487 _skipCount = 0; |
| 519 return _iterator.moveNext(); | 488 return _iterator.moveNext(); |
| 520 } | 489 } |
| 521 E get current => _iterator.current; | 490 E get current => _iterator.current; |
| 522 } | 491 } |
| 523 class SkipWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable
; | 492 class SkipWhileIterable<E> extends IterableBase<E> {final Iterable<E> _iterable
; |
| 524 final _ElementPredicate _f; | 493 final _ElementPredicate _f; |
| 525 SkipWhileIterable(this._iterable, bool this._f(E element)); | 494 SkipWhileIterable(this._iterable, bool this._f(E element)); |
| 526 Iterator<E> get iterator { | 495 Iterator<E> get iterator { |
| 527 return new SkipWhileIterator<E>(_iterable.iterator, _f); | 496 return new SkipWhileIterator<E>(_iterable.iterator, _f); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 616 } |
| 648 static dynamic fold(Iterable iterable, dynamic initialValue, dynamic combine(dy
namic previousValue, element)) { | 617 static dynamic fold(Iterable iterable, dynamic initialValue, dynamic combine(dy
namic previousValue, element)) { |
| 649 for (final element in iterable) { | 618 for (final element in iterable) { |
| 650 initialValue = combine(initialValue, element); | 619 initialValue = combine(initialValue, element); |
| 651 } | 620 } |
| 652 return initialValue; | 621 return initialValue; |
| 653 } | 622 } |
| 654 static void removeWhereList(List list, bool test(var element)) { | 623 static void removeWhereList(List list, bool test(var element)) { |
| 655 List retained = []; | 624 List retained = []; |
| 656 int length = list.length; | 625 int length = list.length; |
| 657 for (int i = 0; | 626 for (int i = 0; i < length; i++) { |
| 658 i < length; | |
| 659 i++) { | |
| 660 var element = list[i]; | 627 var element = list[i]; |
| 661 if (!test(element)) { | 628 if (!test(element)) { |
| 662 retained.add(element); | 629 retained.add(element); |
| 663 } | 630 } |
| 664 if (length != list.length) { | 631 if (length != list.length) { |
| 665 throw new ConcurrentModificationError(list); | 632 throw new ConcurrentModificationError(list); |
| 666 } | 633 } |
| 667 } | 634 } |
| 668 if (retained.length == length) return; list.length = retained.length; | 635 if (retained.length == length) return; list.length = retained.length; |
| 669 for (int i = 0; | 636 for (int i = 0; i < retained.length; i++) { |
| 670 i < retained.length; | |
| 671 i++) { | |
| 672 list[i] = retained[i]; | 637 list[i] = retained[i]; |
| 673 } | 638 } |
| 674 } | 639 } |
| 675 static bool isEmpty(Iterable iterable) { | 640 static bool isEmpty(Iterable iterable) { |
| 676 return !iterable.iterator.moveNext(); | 641 return !iterable.iterator.moveNext(); |
| 677 } | 642 } |
| 678 static dynamic first(Iterable iterable) { | 643 static dynamic first(Iterable iterable) { |
| 679 Iterator it = iterable.iterator; | 644 Iterator it = iterable.iterator; |
| 680 if (!it.moveNext()) { | 645 if (!it.moveNext()) { |
| 681 throw IterableElementError.noElement(); | 646 throw IterableElementError.noElement(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 if (test(element)) { | 679 if (test(element)) { |
| 715 result = element; | 680 result = element; |
| 716 foundMatching = true; | 681 foundMatching = true; |
| 717 } | 682 } |
| 718 } | 683 } |
| 719 if (foundMatching) return result; | 684 if (foundMatching) return result; |
| 720 if (orElse != null) return orElse(); | 685 if (orElse != null) return orElse(); |
| 721 throw IterableElementError.noElement(); | 686 throw IterableElementError.noElement(); |
| 722 } | 687 } |
| 723 static dynamic lastWhereList(List list, bool test(dynamic value), dynamic orEls
e()) { | 688 static dynamic lastWhereList(List list, bool test(dynamic value), dynamic orEls
e()) { |
| 724 for (int i = list.length - 1; | 689 for (int i = list.length - 1; i >= 0; i--) { |
| 725 i >= 0; | |
| 726 i--) { | |
| 727 dynamic element = list[i]; | 690 dynamic element = list[i]; |
| 728 if (test(element)) return element; | 691 if (test(element)) return element; |
| 729 } | 692 } |
| 730 if (orElse != null) return orElse(); | 693 if (orElse != null) return orElse(); |
| 731 throw IterableElementError.noElement(); | 694 throw IterableElementError.noElement(); |
| 732 } | 695 } |
| 733 static dynamic singleWhere(Iterable iterable, bool test(dynamic value)) { | 696 static dynamic singleWhere(Iterable iterable, bool test(dynamic value)) { |
| 734 dynamic result = null; | 697 dynamic result = null; |
| 735 bool foundMatching = false; | 698 bool foundMatching = false; |
| 736 for (dynamic element in iterable) { | 699 for (dynamic element in iterable) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 755 } | 718 } |
| 756 throw new RangeError.index(index, iterable, "index", null, elementIndex); | 719 throw new RangeError.index(index, iterable, "index", null, elementIndex); |
| 757 } | 720 } |
| 758 static String join(Iterable iterable, [String separator]) { | 721 static String join(Iterable iterable, [String separator]) { |
| 759 StringBuffer buffer = new StringBuffer(); | 722 StringBuffer buffer = new StringBuffer(); |
| 760 buffer.writeAll(iterable, separator); | 723 buffer.writeAll(iterable, separator); |
| 761 return buffer.toString(); | 724 return buffer.toString(); |
| 762 } | 725 } |
| 763 static String joinList(List list, [String separator]) { | 726 static String joinList(List list, [String separator]) { |
| 764 if (list.isEmpty) return ""; | 727 if (list.isEmpty) return ""; |
| 765 if (list.length == 1) return "${list[0]} | 728 if (list.length == 1) return "${list[0]}"; |
| 766 "; | |
| 767 StringBuffer buffer = new StringBuffer(); | 729 StringBuffer buffer = new StringBuffer(); |
| 768 if (separator.isEmpty) { | 730 if (separator.isEmpty) { |
| 769 for (int i = 0; | 731 for (int i = 0; i < list.length; i++) { |
| 770 i < list.length; | |
| 771 i++) { | |
| 772 buffer.write(list[i]); | 732 buffer.write(list[i]); |
| 773 } | 733 } |
| 774 } | 734 } |
| 775 else { | 735 else { |
| 776 buffer.write(list[0]); | 736 buffer.write(list[0]); |
| 777 for (int i = 1; | 737 for (int i = 1; i < list.length; i++) { |
| 778 i < list.length; | |
| 779 i++) { | |
| 780 buffer.write(separator); | 738 buffer.write(separator); |
| 781 buffer.write(list[i]); | 739 buffer.write(list[i]); |
| 782 } | 740 } |
| 783 } | 741 } |
| 784 return buffer.toString(); | 742 return buffer.toString(); |
| 785 } | 743 } |
| 786 Iterable<T> where(Iterable iterable, bool f(var element)) { | 744 Iterable<T> where(Iterable iterable, bool f(var element)) { |
| 787 return new WhereIterable<T>(iterable, f); | 745 return new WhereIterable<T>(iterable, f); |
| 788 } | 746 } |
| 789 static Iterable map(Iterable iterable, f(var element)) { | 747 static Iterable map(Iterable iterable, f(var element)) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 int delta = insertLength - removeLength; | 845 int delta = insertLength - removeLength; |
| 888 int newLength = list.length + delta; | 846 int newLength = list.length + delta; |
| 889 int insertEnd = start + insertLength; | 847 int insertEnd = start + insertLength; |
| 890 list.length = newLength; | 848 list.length = newLength; |
| 891 list.setRange(insertEnd, newLength, list, end); | 849 list.setRange(insertEnd, newLength, list, end); |
| 892 list.setRange(start, insertEnd, iterable); | 850 list.setRange(start, insertEnd, iterable); |
| 893 } | 851 } |
| 894 } | 852 } |
| 895 static void fillRangeList(List list, int start, int end, fillValue) { | 853 static void fillRangeList(List list, int start, int end, fillValue) { |
| 896 _rangeCheck(list, start, end); | 854 _rangeCheck(list, start, end); |
| 897 for (int i = start; | 855 for (int i = start; i < end; i++) { |
| 898 i < end; | |
| 899 i++) { | |
| 900 list[i] = fillValue; | 856 list[i] = fillValue; |
| 901 } | 857 } |
| 902 } | 858 } |
| 903 static void insertAllList(List list, int index, Iterable iterable) { | 859 static void insertAllList(List list, int index, Iterable iterable) { |
| 904 RangeError.checkValueInInterval(index, 0, list.length, "index"); | 860 RangeError.checkValueInInterval(index, 0, list.length, "index"); |
| 905 if (iterable is! EfficientLength) { | 861 if (iterable is! EfficientLength) { |
| 906 iterable = iterable.toList(growable: false); | 862 iterable = iterable.toList(growable: false); |
| 907 } | 863 } |
| 908 int insertionLength = iterable.length; | 864 int insertionLength = iterable.length; |
| 909 list.length += insertionLength; | 865 list.length += insertionLength; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 } | 914 } |
| 959 return result; | 915 return result; |
| 960 } | 916 } |
| 961 } | 917 } |
| 962 abstract class IterableElementError {static StateError noElement() => new State
Error("No element"); | 918 abstract class IterableElementError {static StateError noElement() => new State
Error("No element"); |
| 963 static StateError tooMany() => new StateError("Too many elements"); | 919 static StateError tooMany() => new StateError("Too many elements"); |
| 964 static StateError tooFew() => new StateError("Too few elements"); | 920 static StateError tooFew() => new StateError("Too few elements"); |
| 965 } | 921 } |
| 966 typedef int __t12(dynamic __u13, dynamic __u14); | 922 typedef int __t12(dynamic __u13, dynamic __u14); |
| 967 typedef int __t15(Comparable<dynamic> __u16, Comparable<dynamic> __u17); | 923 typedef int __t15(Comparable<dynamic> __u16, Comparable<dynamic> __u17); |
| OLD | NEW |