| OLD | NEW |
| 1 part of dart.collection; | 1 part of dart.collection; |
| 2 | 2 abstract class ListBase<E> extends Object with ListMixin<E> {static String list
ToString(List list) => IterableBase.iterableToFullString(list, '[', ']'); |
| 3 abstract class ListBase<E> extends Object with ListMixin<E> { | 3 } |
| 4 static String listToString(List list) => | 4 abstract class ListMixin<E> implements List<E> {Iterator<E> get iterator => new
ListIterator<E>(this); |
| 5 IterableBase.iterableToFullString(list, '[', ']'); | 5 E elementAt(int index) => this[index]; |
| 6 } | 6 void forEach(void action(E element)) { |
| 7 abstract class ListMixin<E> implements List<E> { | 7 int length = this.length; |
| 8 Iterator<E> get iterator => new ListIterator<E>(this); | 8 for (int i = 0; |
| 9 E elementAt(int index) => this[index]; | 9 i < length; |
| 10 void forEach(void action(E element)) { | 10 i++) { |
| 11 int length = this.length; | 11 action(this[i]); |
| 12 for (int i = 0; i < length; i++) { | 12 if (length != this.length) { |
| 13 action(this[i]); | 13 throw new ConcurrentModificationError(this); |
| 14 if (length != this.length) { | 14 } |
| 15 throw new ConcurrentModificationError(this); | 15 } |
| 16 } |
| 17 bool get isEmpty => length == 0; |
| 18 bool get isNotEmpty => !isEmpty; |
| 19 E get first { |
| 20 if (length == 0) throw IterableElementError.noElement(); |
| 21 return this[0]; |
| 22 } |
| 23 E get last { |
| 24 if (length == 0) throw IterableElementError.noElement(); |
| 25 return this[length - 1]; |
| 26 } |
| 27 E get single { |
| 28 if (length == 0) throw IterableElementError.noElement(); |
| 29 if (length > 1) throw IterableElementError.tooMany(); |
| 30 return this[0]; |
| 31 } |
| 32 bool contains(Object element) { |
| 33 int length = this.length; |
| 34 for (int i = 0; |
| 35 i < this.length; |
| 36 i++) { |
| 37 if (this[i] == element) return true; |
| 38 if (length != this.length) { |
| 39 throw new ConcurrentModificationError(this); |
| 40 } |
| 41 } |
| 42 return false; |
| 43 } |
| 44 bool every(bool test(E element)) { |
| 45 int length = this.length; |
| 46 for (int i = 0; |
| 47 i < length; |
| 48 i++) { |
| 49 if (!test(this[i])) return false; |
| 50 if (length != this.length) { |
| 51 throw new ConcurrentModificationError(this); |
| 52 } |
| 53 } |
| 54 return true; |
| 55 } |
| 56 bool any(bool test(E element)) { |
| 57 int length = this.length; |
| 58 for (int i = 0; |
| 59 i < length; |
| 60 i++) { |
| 61 if (test(this[i])) return true; |
| 62 if (length != this.length) { |
| 63 throw new ConcurrentModificationError(this); |
| 64 } |
| 65 } |
| 66 return false; |
| 67 } |
| 68 E firstWhere(bool test(E element), { |
| 69 E orElse()} |
| 70 ) { |
| 71 int length = this.length; |
| 72 for (int i = 0; |
| 73 i < length; |
| 74 i++) { |
| 75 E element = this[i]; |
| 76 if (test(element)) return element; |
| 77 if (length != this.length) { |
| 78 throw new ConcurrentModificationError(this); |
| 79 } |
| 80 } |
| 81 if (orElse != null) return orElse(); |
| 82 throw IterableElementError.noElement(); |
| 83 } |
| 84 E lastWhere(bool test(E element), { |
| 85 E orElse()} |
| 86 ) { |
| 87 int length = this.length; |
| 88 for (int i = length - 1; |
| 89 i >= 0; |
| 90 i--) { |
| 91 E element = this[i]; |
| 92 if (test(element)) return element; |
| 93 if (length != this.length) { |
| 94 throw new ConcurrentModificationError(this); |
| 95 } |
| 96 } |
| 97 if (orElse != null) return orElse(); |
| 98 throw IterableElementError.noElement(); |
| 99 } |
| 100 E singleWhere(bool test(E element)) { |
| 101 int length = this.length; |
| 102 E match = ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", """line 151, col
umn 15 of dart:collection/list.dart: """, __x9 is E, false))(null); |
| 103 bool matchFound = false; |
| 104 for (int i = 0; |
| 105 i < length; |
| 106 i++) { |
| 107 E element = this[i]; |
| 108 if (test(element)) { |
| 109 if (matchFound) { |
| 110 throw IterableElementError.tooMany(); |
| 16 } | 111 } |
| 17 } | 112 matchFound = true; |
| 18 } | 113 match = element; |
| 19 bool get isEmpty => length == 0; | 114 } |
| 20 bool get isNotEmpty => !isEmpty; | 115 if (length != this.length) { |
| 21 E get first { | 116 throw new ConcurrentModificationError(this); |
| 22 if (length == 0) throw IterableElementError.noElement(); | 117 } |
| 23 return this[0]; | 118 } |
| 24 } | 119 if (matchFound) return match; |
| 25 E get last { | 120 throw IterableElementError.noElement(); |
| 26 if (length == 0) throw IterableElementError.noElement(); | 121 } |
| 27 return this[length - 1]; | 122 String join([String separator = ""]) { |
| 28 } | 123 if (length == 0) return ""; |
| 29 E get single { | 124 StringBuffer buffer = new StringBuffer()..writeAll(this, separator); |
| 30 if (length == 0) throw IterableElementError.noElement(); | 125 return buffer.toString(); |
| 31 if (length > 1) throw IterableElementError.tooMany(); | 126 } |
| 32 return this[0]; | 127 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); |
| 33 } | 128 Iterable map(f(E element)) => new MappedListIterable(this, f); |
| 34 bool contains(Object element) { | 129 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this,
f); |
| 35 int length = this.length; | 130 E reduce(E combine(E previousValue, E element)) { |
| 36 for (int i = 0; i < this.length; i++) { | 131 int length = this.length; |
| 37 if (this[i] == element) return true; | 132 if (length == 0) throw IterableElementError.noElement(); |
| 38 if (length != this.length) { | 133 E value = this[0]; |
| 39 throw new ConcurrentModificationError(this); | 134 for (int i = 1; |
| 40 } | 135 i < length; |
| 41 } | 136 i++) { |
| 42 return false; | 137 value = combine(value, this[i]); |
| 43 } | 138 if (length != this.length) { |
| 44 bool every(bool test(E element)) { | 139 throw new ConcurrentModificationError(this); |
| 45 int length = this.length; | 140 } |
| 46 for (int i = 0; i < length; i++) { | 141 } |
| 47 if (!test(this[i])) return false; | 142 return value; |
| 48 if (length != this.length) { | 143 } |
| 49 throw new ConcurrentModificationError(this); | 144 fold(var initialValue, combine(var previousValue, E element)) { |
| 50 } | 145 var value = initialValue; |
| 51 } | 146 int length = this.length; |
| 52 return true; | 147 for (int i = 0; |
| 53 } | 148 i < length; |
| 54 bool any(bool test(E element)) { | 149 i++) { |
| 55 int length = this.length; | 150 value = combine(value, this[i]); |
| 56 for (int i = 0; i < length; i++) { | 151 if (length != this.length) { |
| 57 if (test(this[i])) return true; | 152 throw new ConcurrentModificationError(this); |
| 58 if (length != this.length) { | 153 } |
| 59 throw new ConcurrentModificationError(this); | 154 } |
| 60 } | 155 return value; |
| 61 } | 156 } |
| 62 return false; | 157 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); |
| 63 } | 158 Iterable<E> skipWhile(bool test(E element)) { |
| 64 E firstWhere(bool test(E element), {E orElse()}) { | 159 return new SkipWhileIterable<E>(this, test); |
| 65 int length = this.length; | 160 } |
| 66 for (int i = 0; i < length; i++) { | 161 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); |
| 67 E element = this[i]; | 162 Iterable<E> takeWhile(bool test(E element)) { |
| 68 if (test(element)) return element; | 163 return new TakeWhileIterable<E>(this, test); |
| 69 if (length != this.length) { | 164 } |
| 70 throw new ConcurrentModificationError(this); | 165 List<E> toList({ |
| 71 } | 166 bool growable : true} |
| 72 } | 167 ) { |
| 73 if (orElse != null) return orElse(); | 168 List<E> result; |
| 74 throw IterableElementError.noElement(); | 169 if (growable) { |
| 75 } | 170 result = new List<E>()..length = length; |
| 76 E lastWhere(bool test(E element), {E orElse()}) { | 171 } |
| 77 int length = this.length; | 172 else { |
| 78 for (int i = length - 1; i >= 0; i--) { | 173 result = new List<E>(length); |
| 79 E element = this[i]; | 174 } |
| 80 if (test(element)) return element; | 175 for (int i = 0; |
| 81 if (length != this.length) { | 176 i < length; |
| 82 throw new ConcurrentModificationError(this); | 177 i++) { |
| 83 } | 178 result[i] = this[i]; |
| 84 } | 179 } |
| 85 if (orElse != null) return orElse(); | 180 return result; |
| 86 throw IterableElementError.noElement(); | 181 } |
| 87 } | 182 Set<E> toSet() { |
| 88 E singleWhere(bool test(E element)) { | 183 Set<E> result = new Set<E>(); |
| 89 int length = this.length; | 184 for (int i = 0; |
| 90 E match = ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", | 185 i < length; |
| 91 """line 151, column 15 of dart:collection/list.dart: """, __x9 is E, | 186 i++) { |
| 92 false))(null); | 187 result.add(this[i]); |
| 93 bool matchFound = false; | 188 } |
| 94 for (int i = 0; i < length; i++) { | 189 return result; |
| 95 E element = this[i]; | 190 } |
| 96 if (test(element)) { | 191 void add(E element) { |
| 97 if (matchFound) { | 192 this[this.length++] = element; |
| 98 throw IterableElementError.tooMany(); | 193 } |
| 99 } | 194 void addAll(Iterable<E> iterable) { |
| 100 matchFound = true; | 195 for (E element in iterable) { |
| 101 match = element; | 196 this[this.length++] = element; |
| 102 } | 197 } |
| 103 if (length != this.length) { | 198 } |
| 104 throw new ConcurrentModificationError(this); | 199 bool remove(Object element) { |
| 105 } | 200 for (int i = 0; |
| 106 } | 201 i < this.length; |
| 107 if (matchFound) return match; | 202 i++) { |
| 108 throw IterableElementError.noElement(); | 203 if (this[i] == element) { |
| 109 } | 204 this.setRange(i, this.length - 1, this, i + 1); |
| 110 String join([String separator = ""]) { | 205 this.length -= 1; |
| 111 if (length == 0) return ""; | 206 return true; |
| 112 StringBuffer buffer = new StringBuffer()..writeAll(this, separator); | 207 } |
| 113 return buffer.toString(); | 208 } |
| 114 } | 209 return false; |
| 115 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); | 210 } |
| 116 Iterable map(f(E element)) => new MappedListIterable(this, f); | 211 void removeWhere(bool test(E element)) { |
| 117 Iterable expand(Iterable f(E element)) => | 212 _filter(this, DDC$RT.wrap((bool f(E __u10)) { |
| 118 new ExpandIterable<E, dynamic>(this, f); | 213 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 264, column
19 of dart:collection/list.dart: """, x0 is E, false)); |
| 119 E reduce(E combine(E previousValue, E element)) { | 214 return f == null ? null : c; |
| 120 int length = this.length; | 215 } |
| 121 if (length == 0) throw IterableElementError.noElement(); | 216 , test, DDC$RT.type((__t13<E> _) { |
| 122 E value = this[0]; | 217 } |
| 123 for (int i = 1; i < length; i++) { | 218 ), __t11, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test
is __t11), false); |
| 124 value = combine(value, this[i]); | 219 } |
| 125 if (length != this.length) { | 220 void retainWhere(bool test(E element)) { |
| 126 throw new ConcurrentModificationError(this); | 221 _filter(this, DDC$RT.wrap((bool f(E __u15)) { |
| 127 } | 222 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 268, column
19 of dart:collection/list.dart: """, x0 is E, false)); |
| 128 } | 223 return f == null ? null : c; |
| 129 return value; | 224 } |
| 130 } | 225 , test, DDC$RT.type((__t13<E> _) { |
| 131 fold(var initialValue, combine(var previousValue, E element)) { | 226 } |
| 132 var value = initialValue; | 227 ), __t11, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test
is __t11), true); |
| 133 int length = this.length; | 228 } |
| 134 for (int i = 0; i < length; i++) { | 229 static void _filter(List source, bool test(var element), bool retainMatching) { |
| 135 value = combine(value, this[i]); | 230 List retained = []; |
| 136 if (length != this.length) { | 231 int length = source.length; |
| 137 throw new ConcurrentModificationError(this); | 232 for (int i = 0; |
| 138 } | 233 i < length; |
| 139 } | 234 i++) { |
| 140 return value; | 235 var element = source[i]; |
| 141 } | 236 if (test(element) == retainMatching) { |
| 142 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); | 237 retained.add(element); |
| 143 Iterable<E> skipWhile(bool test(E element)) { | 238 } |
| 144 return new SkipWhileIterable<E>(this, test); | 239 if (length != source.length) { |
| 145 } | 240 throw new ConcurrentModificationError(source); |
| 146 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); | 241 } |
| 147 Iterable<E> takeWhile(bool test(E element)) { | 242 } |
| 148 return new TakeWhileIterable<E>(this, test); | 243 if (retained.length != source.length) { |
| 149 } | 244 source.setRange(0, retained.length, retained); |
| 150 List<E> toList({bool growable: true}) { | 245 source.length = retained.length; |
| 151 List<E> result; | 246 } |
| 152 if (growable) { | 247 } |
| 153 result = new List<E>()..length = length; | 248 void clear() { |
| 154 } else { | 249 this.length = 0; |
| 155 result = new List<E>(length); | 250 } |
| 156 } | 251 E removeLast() { |
| 157 for (int i = 0; i < length; i++) { | 252 if (length == 0) { |
| 158 result[i] = this[i]; | 253 throw IterableElementError.noElement(); |
| 159 } | 254 } |
| 160 return result; | 255 E result = this[length - 1]; |
| 161 } | 256 length--; |
| 162 Set<E> toSet() { | 257 return result; |
| 163 Set<E> result = new Set<E>(); | 258 } |
| 164 for (int i = 0; i < length; i++) { | 259 void sort([int compare(E a, E b)]) { |
| 165 result.add(this[i]); | 260 if (compare == null) { |
| 166 } | 261 var defaultCompare = Comparable.compare; |
| 167 return result; | 262 compare = defaultCompare; |
| 168 } | 263 } |
| 169 void add(E element) { | 264 Sort.sort(this, DDC$RT.wrap((int f(E __u16, E __u17)) { |
| 170 this[this.length++] = element; | 265 int c(E x0, E x1) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 309, c
olumn 21 of dart:collection/list.dart: """, x0 is E, false), DDC$RT.cast(x1, dyn
amic, E, "CastParam", """line 309, column 21 of dart:collection/list.dart: """,
x1 is E, false)); |
| 171 } | 266 return f == null ? null : c; |
| 172 void addAll(Iterable<E> iterable) { | 267 } |
| 173 for (E element in iterable) { | 268 , compare, DDC$RT.type((__t21<E> _) { |
| 174 this[this.length++] = element; | 269 } |
| 175 } | 270 ), __t18, "Wrap", """line 309, column 21 of dart:collection/list.dart: """, comp
are is __t18)); |
| 176 } | 271 } |
| 177 bool remove(Object element) { | 272 void shuffle([Random random]) { |
| 178 for (int i = 0; i < this.length; i++) { | 273 if (random == null) random = new Random(); |
| 179 if (this[i] == element) { | 274 int length = this.length; |
| 180 this.setRange(i, this.length - 1, this, i + 1); | 275 while (length > 1) { |
| 181 this.length -= 1; | 276 int pos = random.nextInt(length); |
| 182 return true; | 277 length -= 1; |
| 183 } | 278 var tmp = this[length]; |
| 184 } | 279 this[length] = this[pos]; |
| 185 return false; | 280 this[pos] = tmp; |
| 186 } | 281 } |
| 187 void removeWhere(bool test(E element)) { | 282 } |
| 188 _filter(this, DDC$RT.wrap((bool f(E __u10)) { | 283 Map<int, E> asMap() { |
| 189 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", | 284 return new ListMapView<E>(this); |
| 190 """line 264, column 19 of dart:collection/list.dart: """, x0 is E, | 285 } |
| 191 false)); | 286 List<E> sublist(int start, [int end]) { |
| 192 return f == null ? null : c; | 287 int listLength = this.length; |
| 193 }, test, DDC$RT.type((__t13<E> _) {}), __t11, "Wrap", | 288 if (end == null) end = listLength; |
| 194 """line 264, column 19 of dart:collection/list.dart: """, | 289 RangeError.checkValidRange(start, end, listLength); |
| 195 test is __t11), false); | 290 int length = end - start; |
| 196 } | 291 List<E> result = new List<E>()..length = length; |
| 197 void retainWhere(bool test(E element)) { | 292 for (int i = 0; |
| 198 _filter(this, DDC$RT.wrap((bool f(E __u15)) { | 293 i < length; |
| 199 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", | 294 i++) { |
| 200 """line 268, column 19 of dart:collection/list.dart: """, x0 is E, | 295 result[i] = this[start + i]; |
| 201 false)); | 296 } |
| 202 return f == null ? null : c; | 297 return result; |
| 203 }, test, DDC$RT.type((__t13<E> _) {}), __t11, "Wrap", | 298 } |
| 204 """line 268, column 19 of dart:collection/list.dart: """, | 299 Iterable<E> getRange(int start, int end) { |
| 205 test is __t11), true); | 300 RangeError.checkValidRange(start, end, this.length); |
| 206 } | 301 return new SubListIterable<E>(this, start, end); |
| 207 static void _filter( | 302 } |
| 208 List source, bool test(var element), bool retainMatching) { | 303 void removeRange(int start, int end) { |
| 209 List retained = []; | 304 RangeError.checkValidRange(start, end, this.length); |
| 210 int length = source.length; | 305 int length = end - start; |
| 211 for (int i = 0; i < length; i++) { | 306 setRange(start, this.length - length, this, end); |
| 212 var element = source[i]; | 307 this.length -= length; |
| 213 if (test(element) == retainMatching) { | 308 } |
| 214 retained.add(element); | 309 void fillRange(int start, int end, [E fill]) { |
| 215 } | 310 RangeError.checkValidRange(start, end, this.length); |
| 216 if (length != source.length) { | 311 for (int i = start; |
| 217 throw new ConcurrentModificationError(source); | 312 i < end; |
| 218 } | 313 i++) { |
| 219 } | 314 this[i] = fill; |
| 220 if (retained.length != source.length) { | 315 } |
| 221 source.setRange(0, retained.length, retained); | 316 } |
| 222 source.length = retained.length; | 317 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
| 223 } | 318 RangeError.checkValidRange(start, end, this.length); |
| 224 } | 319 int length = end - start; |
| 225 void clear() { | 320 if (length == 0) return; RangeError.checkNotNegative(skipCount, "skipCount"); |
| 226 this.length = 0; | 321 List otherList; |
| 227 } | 322 int otherStart; |
| 228 E removeLast() { | 323 if (iterable is List) { |
| 229 if (length == 0) { | 324 otherList = DDC$RT.cast(iterable, DDC$RT.type((Iterable<E> _) { |
| 230 throw IterableElementError.noElement(); | 325 } |
| 231 } | 326 ), DDC$RT.type((List<dynamic> _) { |
| 232 E result = this[length - 1]; | 327 } |
| 233 length--; | 328 ), "CastGeneral", """line 369, column 19 of dart:collection/list.dart: """, it
erable is List<dynamic>, true); |
| 234 return result; | 329 otherStart = skipCount; |
| 235 } | 330 } |
| 236 void sort([int compare(E a, E b)]) { | 331 else { |
| 237 if (compare == null) { | 332 otherList = iterable.skip(skipCount).toList(growable: false); |
| 238 var defaultCompare = Comparable.compare; | 333 otherStart = 0; |
| 239 compare = defaultCompare; | 334 } |
| 240 } | 335 if (otherStart + length > otherList.length) { |
| 241 Sort.sort(this, DDC$RT.wrap((int f(E __u16, E __u17)) { | 336 throw IterableElementError.tooFew(); |
| 242 int c(E x0, E x1) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", | 337 } |
| 243 """line 309, column 21 of dart:collection/list.dart: """, x0 is E, | 338 if (otherStart < start) { |
| 244 false), DDC$RT.cast(x1, dynamic, E, "CastParam", | 339 for (int i = length - 1; |
| 245 """line 309, column 21 of dart:collection/list.dart: """, x1 is E, | 340 i >= 0; |
| 246 false)); | 341 i--) { |
| 247 return f == null ? null : c; | 342 this[start + i] = ((__x24) => DDC$RT.cast(__x24, dynamic, E, "CastGeneral",
"""line 381, column 27 of dart:collection/list.dart: """, __x24 is E, false))(ot
herList[otherStart + i]); |
| 248 }, compare, DDC$RT.type((__t21<E> _) {}), __t18, "Wrap", | 343 } |
| 249 """line 309, column 21 of dart:collection/list.dart: """, | 344 } |
| 250 compare is __t18)); | 345 else { |
| 251 } | 346 for (int i = 0; |
| 252 void shuffle([Random random]) { | 347 i < length; |
| 253 if (random == null) random = new Random(); | 348 i++) { |
| 254 int length = this.length; | 349 this[start + i] = ((__x25) => DDC$RT.cast(__x25, dynamic, E, "CastGeneral",
"""line 385, column 27 of dart:collection/list.dart: """, __x25 is E, false))(ot
herList[otherStart + i]); |
| 255 while (length > 1) { | 350 } |
| 256 int pos = random.nextInt(length); | 351 } |
| 257 length -= 1; | 352 } |
| 258 var tmp = this[length]; | 353 void replaceRange(int start, int end, Iterable<E> newContents) { |
| 259 this[length] = this[pos]; | 354 RangeError.checkValidRange(start, end, this.length); |
| 260 this[pos] = tmp; | 355 if (newContents is! EfficientLength) { |
| 261 } | 356 newContents = newContents.toList(); |
| 262 } | 357 } |
| 263 Map<int, E> asMap() { | 358 int removeLength = end - start; |
| 264 return new ListMapView<E>(this); | 359 int insertLength = newContents.length; |
| 265 } | 360 if (removeLength >= insertLength) { |
| 266 List<E> sublist(int start, [int end]) { | 361 int delta = removeLength - insertLength; |
| 267 int listLength = this.length; | 362 int insertEnd = start + insertLength; |
| 268 if (end == null) end = listLength; | 363 int newLength = this.length - delta; |
| 269 RangeError.checkValidRange(start, end, listLength); | 364 this.setRange(start, insertEnd, newContents); |
| 270 int length = end - start; | 365 if (delta != 0) { |
| 271 List<E> result = new List<E>()..length = length; | 366 this.setRange(insertEnd, newLength, this, end); |
| 272 for (int i = 0; i < length; i++) { | 367 this.length = newLength; |
| 273 result[i] = this[start + i]; | 368 } |
| 274 } | 369 } |
| 275 return result; | 370 else { |
| 276 } | 371 int delta = insertLength - removeLength; |
| 277 Iterable<E> getRange(int start, int end) { | 372 int newLength = this.length + delta; |
| 278 RangeError.checkValidRange(start, end, this.length); | 373 int insertEnd = start + insertLength; |
| 279 return new SubListIterable<E>(this, start, end); | 374 this.length = newLength; |
| 280 } | 375 this.setRange(insertEnd, newLength, this, end); |
| 281 void removeRange(int start, int end) { | 376 this.setRange(start, insertEnd, newContents); |
| 282 RangeError.checkValidRange(start, end, this.length); | 377 } |
| 283 int length = end - start; | 378 } |
| 284 setRange(start, this.length - length, this, end); | 379 int indexOf(Object element, [int startIndex = 0]) { |
| 285 this.length -= length; | 380 if (startIndex >= this.length) { |
| 286 } | 381 return -1; |
| 287 void fillRange(int start, int end, [E fill]) { | 382 } |
| 288 RangeError.checkValidRange(start, end, this.length); | 383 if (startIndex < 0) { |
| 289 for (int i = start; i < end; i++) { | 384 startIndex = 0; |
| 290 this[i] = fill; | 385 } |
| 291 } | 386 for (int i = startIndex; |
| 292 } | 387 i < this.length; |
| 293 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 388 i++) { |
| 294 RangeError.checkValidRange(start, end, this.length); | 389 if (this[i] == element) { |
| 295 int length = end - start; | 390 return i; |
| 296 if (length == 0) return; | 391 } |
| 297 RangeError.checkNotNegative(skipCount, "skipCount"); | 392 } |
| 298 List otherList; | 393 return -1; |
| 299 int otherStart; | 394 } |
| 300 if (iterable is List) { | 395 int lastIndexOf(Object element, [int startIndex]) { |
| 301 otherList = DDC$RT.cast(iterable, DDC$RT.type((Iterable<E> _) {}), | 396 if (startIndex == null) { |
| 302 DDC$RT.type((List<dynamic> _) {}), "CastGeneral", | 397 startIndex = this.length - 1; |
| 303 """line 369, column 19 of dart:collection/list.dart: """, | 398 } |
| 304 iterable is List<dynamic>, true); | 399 else { |
| 305 otherStart = skipCount; | 400 if (startIndex < 0) { |
| 306 } else { | |
| 307 otherList = iterable.skip(skipCount).toList(growable: false); | |
| 308 otherStart = 0; | |
| 309 } | |
| 310 if (otherStart + length > otherList.length) { | |
| 311 throw IterableElementError.tooFew(); | |
| 312 } | |
| 313 if (otherStart < start) { | |
| 314 for (int i = length - 1; i >= 0; i--) { | |
| 315 this[start + i] = ((__x24) => DDC$RT.cast(__x24, dynamic, E, | |
| 316 "CastGeneral", | |
| 317 """line 381, column 27 of dart:collection/list.dart: """, | |
| 318 __x24 is E, false))(otherList[otherStart + i]); | |
| 319 } | |
| 320 } else { | |
| 321 for (int i = 0; i < length; i++) { | |
| 322 this[start + i] = ((__x25) => DDC$RT.cast(__x25, dynamic, E, | |
| 323 "CastGeneral", | |
| 324 """line 385, column 27 of dart:collection/list.dart: """, | |
| 325 __x25 is E, false))(otherList[otherStart + i]); | |
| 326 } | |
| 327 } | |
| 328 } | |
| 329 void replaceRange(int start, int end, Iterable<E> newContents) { | |
| 330 RangeError.checkValidRange(start, end, this.length); | |
| 331 if (newContents is! EfficientLength) { | |
| 332 newContents = newContents.toList(); | |
| 333 } | |
| 334 int removeLength = end - start; | |
| 335 int insertLength = newContents.length; | |
| 336 if (removeLength >= insertLength) { | |
| 337 int delta = removeLength - insertLength; | |
| 338 int insertEnd = start + insertLength; | |
| 339 int newLength = this.length - delta; | |
| 340 this.setRange(start, insertEnd, newContents); | |
| 341 if (delta != 0) { | |
| 342 this.setRange(insertEnd, newLength, this, end); | |
| 343 this.length = newLength; | |
| 344 } | |
| 345 } else { | |
| 346 int delta = insertLength - removeLength; | |
| 347 int newLength = this.length + delta; | |
| 348 int insertEnd = start + insertLength; | |
| 349 this.length = newLength; | |
| 350 this.setRange(insertEnd, newLength, this, end); | |
| 351 this.setRange(start, insertEnd, newContents); | |
| 352 } | |
| 353 } | |
| 354 int indexOf(Object element, [int startIndex = 0]) { | |
| 355 if (startIndex >= this.length) { | |
| 356 return -1; | |
| 357 } | |
| 358 if (startIndex < 0) { | |
| 359 startIndex = 0; | |
| 360 } | |
| 361 for (int i = startIndex; i < this.length; i++) { | |
| 362 if (this[i] == element) { | |
| 363 return i; | |
| 364 } | |
| 365 } | |
| 366 return -1; | 401 return -1; |
| 367 } | 402 } |
| 368 int lastIndexOf(Object element, [int startIndex]) { | 403 if (startIndex >= this.length) { |
| 369 if (startIndex == null) { | 404 startIndex = this.length - 1; |
| 370 startIndex = this.length - 1; | 405 } |
| 371 } else { | 406 } |
| 372 if (startIndex < 0) { | 407 for (int i = startIndex; |
| 373 return -1; | 408 i >= 0; |
| 374 } | 409 i--) { |
| 375 if (startIndex >= this.length) { | 410 if (this[i] == element) { |
| 376 startIndex = this.length - 1; | 411 return i; |
| 377 } | 412 } |
| 378 } | 413 } |
| 379 for (int i = startIndex; i >= 0; i--) { | 414 return -1; |
| 380 if (this[i] == element) { | 415 } |
| 381 return i; | 416 void insert(int index, E element) { |
| 382 } | 417 RangeError.checkValueInInterval(index, 0, length, "index"); |
| 383 } | 418 if (index == this.length) { |
| 384 return -1; | 419 add(element); |
| 385 } | 420 return;} |
| 386 void insert(int index, E element) { | 421 if (index is! int) throw new ArgumentError(index); |
| 387 RangeError.checkValueInInterval(index, 0, length, "index"); | 422 this.length++; |
| 388 if (index == this.length) { | 423 setRange(index + 1, this.length, this, index); |
| 389 add(element); | 424 this[index] = element; |
| 390 return; | 425 } |
| 391 } | 426 E removeAt(int index) { |
| 392 if (index is! int) throw new ArgumentError(index); | 427 E result = this[index]; |
| 393 this.length++; | 428 setRange(index, this.length - 1, this, index + 1); |
| 394 setRange(index + 1, this.length, this, index); | 429 length--; |
| 395 this[index] = element; | 430 return result; |
| 396 } | 431 } |
| 397 E removeAt(int index) { | 432 void insertAll(int index, Iterable<E> iterable) { |
| 398 E result = this[index]; | 433 RangeError.checkValueInInterval(index, 0, length, "index"); |
| 399 setRange(index, this.length - 1, this, index + 1); | 434 if (iterable is EfficientLength) { |
| 400 length--; | 435 iterable = iterable.toList(); |
| 401 return result; | 436 } |
| 402 } | 437 int insertionLength = iterable.length; |
| 403 void insertAll(int index, Iterable<E> iterable) { | 438 this.length += insertionLength; |
| 404 RangeError.checkValueInInterval(index, 0, length, "index"); | 439 setRange(index + insertionLength, this.length, this, index); |
| 405 if (iterable is EfficientLength) { | 440 setAll(index, iterable); |
| 406 iterable = iterable.toList(); | 441 } |
| 407 } | 442 void setAll(int index, Iterable<E> iterable) { |
| 408 int insertionLength = iterable.length; | 443 if (iterable is List) { |
| 409 this.length += insertionLength; | 444 setRange(index, index + iterable.length, iterable); |
| 410 setRange(index + insertionLength, this.length, this, index); | 445 } |
| 411 setAll(index, iterable); | 446 else { |
| 412 } | 447 for (E element in iterable) { |
| 413 void setAll(int index, Iterable<E> iterable) { | 448 this[index++] = element; |
| 414 if (iterable is List) { | 449 } |
| 415 setRange(index, index + iterable.length, iterable); | 450 } |
| 416 } else { | 451 } |
| 417 for (E element in iterable) { | 452 Iterable<E> get reversed => new ReversedListIterable<E>(this); |
| 418 this[index++] = element; | 453 String toString() => IterableBase.iterableToFullString(this, '[', ']'); |
| 419 } | 454 } |
| 420 } | 455 typedef bool __t11(dynamic __u12); |
| 421 } | 456 typedef bool __t13<E>(E __u14); |
| 422 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 457 typedef int __t18(dynamic __u19, dynamic __u20); |
| 423 String toString() => IterableBase.iterableToFullString(this, '[', ']'); | 458 typedef int __t21<E>(E __u22, E __u23); |
| 424 } | |
| 425 typedef bool __t11(dynamic __u12); | |
| 426 typedef bool __t13<E>(E __u14); | |
| 427 typedef int __t18(dynamic __u19, dynamic __u20); | |
| 428 typedef int __t21<E>(E __u22, E __u23); | |
| OLD | NEW |