| OLD | NEW |
| 1 part of dart.collection; | 1 part of dart.collection; |
| 2 | 2 abstract class IterableMixin<E> implements Iterable<E> {Iterable map(f(E elemen
t)) => new MappedIterable<E, dynamic>(this, f); |
| 3 abstract class IterableMixin<E> implements Iterable<E> { | 3 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); |
| 4 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); | 4 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this,
f); |
| 5 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); | 5 bool contains(Object element) { |
| 6 Iterable expand(Iterable f(E element)) => | 6 for (E e in this) { |
| 7 new ExpandIterable<E, dynamic>(this, f); | 7 if (e == element) return true; |
| 8 bool contains(Object element) { | |
| 9 for (E e in this) { | |
| 10 if (e == element) return true; | |
| 11 } | 8 } |
| 12 return false; | 9 return false; |
| 13 } | 10 } |
| 14 void forEach(void f(E element)) { | 11 void forEach(void f(E element)) { |
| 15 for (E element in this) f(element); | 12 for (E element in this) f(element); |
| 16 } | 13 } |
| 17 E reduce(E combine(E value, E element)) { | 14 E reduce(E combine(E value, E element)) { |
| 18 Iterator<E> iterator = this.iterator; | 15 Iterator<E> iterator = this.iterator; |
| 19 if (!iterator.moveNext()) { | 16 if (!iterator.moveNext()) { |
| 20 throw IterableElementError.noElement(); | 17 throw IterableElementError.noElement(); |
| 21 } | 18 } |
| 22 E value = iterator.current; | 19 E value = iterator.current; |
| 23 while (iterator.moveNext()) { | 20 while (iterator.moveNext()) { |
| 24 value = combine(value, iterator.current); | 21 value = combine(value, iterator.current); |
| 25 } | 22 } |
| 26 return value; | 23 return value; |
| 27 } | 24 } |
| 28 dynamic fold( | 25 dynamic fold(var initialValue, dynamic combine(var previousValue, E element)) { |
| 29 var initialValue, dynamic combine(var previousValue, E element)) { | 26 var value = initialValue; |
| 30 var value = initialValue; | 27 for (E element in this) value = combine(value, element); |
| 31 for (E element in this) value = combine(value, element); | 28 return value; |
| 32 return value; | 29 } |
| 33 } | 30 bool every(bool f(E element)) { |
| 34 bool every(bool f(E element)) { | 31 for (E element in this) { |
| 35 for (E element in this) { | 32 if (!f(element)) return false; |
| 36 if (!f(element)) return false; | |
| 37 } | 33 } |
| 38 return true; | 34 return true; |
| 39 } | 35 } |
| 40 String join([String separator = ""]) { | 36 String join([String separator = ""]) { |
| 41 Iterator<E> iterator = this.iterator; | 37 Iterator<E> iterator = this.iterator; |
| 42 if (!iterator.moveNext()) return ""; | 38 if (!iterator.moveNext()) return ""; |
| 43 StringBuffer buffer = new StringBuffer(); | 39 StringBuffer buffer = new StringBuffer(); |
| 44 if (separator == null || separator == "") { | 40 if (separator == null || separator == "") { |
| 45 do { | 41 do { |
| 46 buffer.write("${iterator.current}"); | 42 buffer.write("${iterator.current} |
| 47 } while (iterator.moveNext()); | 43 "); |
| 48 } else { | |
| 49 buffer.write("${iterator.current}"); | |
| 50 while (iterator.moveNext()) { | |
| 51 buffer.write(separator); | |
| 52 buffer.write("${iterator.current}"); | |
| 53 } | |
| 54 } | 44 } |
| 55 return buffer.toString(); | 45 while (iterator.moveNext());} |
| 56 } | 46 else { |
| 57 bool any(bool f(E element)) { | 47 buffer.write("${iterator.current} |
| 58 for (E element in this) { | 48 "); |
| 59 if (f(element)) return true; | 49 while (iterator.moveNext()) { |
| 60 } | 50 buffer.write(separator); |
| 61 return false; | 51 buffer.write("${iterator.current} |
| 62 } | 52 "); |
| 63 List<E> toList({bool growable: true}) => | 53 } |
| 64 new List<E>.from(this, growable: growable); | 54 } |
| 65 Set<E> toSet() => new Set<E>.from(this); | 55 return buffer.toString(); |
| 66 int get length { | 56 } |
| 67 assert(this is! EfficientLength); | 57 bool any(bool f(E element)) { |
| 68 int count = 0; | 58 for (E element in this) { |
| 69 Iterator it = iterator; | 59 if (f(element)) return true; |
| 70 while (it.moveNext()) { | 60 } |
| 71 count++; | 61 return false; |
| 72 } | 62 } |
| 73 return count; | 63 List<E> toList({ |
| 74 } | 64 bool growable : true} |
| 75 bool get isEmpty => !iterator.moveNext(); | 65 ) => new List<E>.from(this, growable: growable); |
| 76 bool get isNotEmpty => !isEmpty; | 66 Set<E> toSet() => new Set<E>.from(this); |
| 77 Iterable<E> take(int n) { | 67 int get length { |
| 78 return new TakeIterable<E>(this, n); | 68 assert (this is! EfficientLength); int count = 0; |
| 79 } | 69 Iterator it = iterator; |
| 80 Iterable<E> takeWhile(bool test(E value)) { | 70 while (it.moveNext()) { |
| 81 return new TakeWhileIterable<E>(this, test); | 71 count++; |
| 82 } | 72 } |
| 83 Iterable<E> skip(int n) { | 73 return count; |
| 84 return new SkipIterable<E>(this, n); | 74 } |
| 85 } | 75 bool get isEmpty => !iterator.moveNext(); |
| 86 Iterable<E> skipWhile(bool test(E value)) { | 76 bool get isNotEmpty => !isEmpty; |
| 87 return new SkipWhileIterable<E>(this, test); | 77 Iterable<E> take(int n) { |
| 88 } | 78 return new TakeIterable<E>(this, n); |
| 89 E get first { | 79 } |
| 90 Iterator it = iterator; | 80 Iterable<E> takeWhile(bool test(E value)) { |
| 91 if (!it.moveNext()) { | 81 return new TakeWhileIterable<E>(this, test); |
| 92 throw IterableElementError.noElement(); | 82 } |
| 93 } | 83 Iterable<E> skip(int n) { |
| 94 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 84 return new SkipIterable<E>(this, n); |
| 95 """line 127, column 12 of dart:collection/iterable.dart: """, | 85 } |
| 96 it.current is E, false); | 86 Iterable<E> skipWhile(bool test(E value)) { |
| 97 } | 87 return new SkipWhileIterable<E>(this, test); |
| 98 E get last { | 88 } |
| 99 Iterator it = iterator; | 89 E get first { |
| 100 if (!it.moveNext()) { | 90 Iterator it = iterator; |
| 101 throw IterableElementError.noElement(); | 91 if (!it.moveNext()) { |
| 102 } | 92 throw IterableElementError.noElement(); |
| 103 E result; | 93 } |
| 104 do { | 94 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 127, column 1
2 of dart:collection/iterable.dart: """, it.current is E, false); |
| 105 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 95 } |
| 106 """line 137, column 16 of dart:collection/iterable.dart: """, | 96 E get last { |
| 107 it.current is E, false); | 97 Iterator it = iterator; |
| 108 } while (it.moveNext()); | 98 if (!it.moveNext()) { |
| 109 return result; | 99 throw IterableElementError.noElement(); |
| 110 } | 100 } |
| 111 E get single { | 101 E result; |
| 112 Iterator it = iterator; | 102 do { |
| 113 if (!it.moveNext()) throw IterableElementError.noElement(); | 103 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 137, column
16 of dart:collection/iterable.dart: """, it.current is E, false); |
| 114 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 104 } |
| 115 """line 145, column 16 of dart:collection/iterable.dart: """, | 105 while (it.moveNext()); return result; |
| 116 it.current is E, false); | 106 } |
| 117 if (it.moveNext()) throw IterableElementError.tooMany(); | 107 E get single { |
| 118 return result; | 108 Iterator it = iterator; |
| 119 } | 109 if (!it.moveNext()) throw IterableElementError.noElement(); |
| 120 E firstWhere(bool test(E value), {E orElse()}) { | 110 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 145, colu
mn 16 of dart:collection/iterable.dart: """, it.current is E, false); |
| 121 for (E element in this) { | 111 if (it.moveNext()) throw IterableElementError.tooMany(); |
| 122 if (test(element)) return element; | 112 return result; |
| 123 } | 113 } |
| 124 if (orElse != null) return orElse(); | 114 E firstWhere(bool test(E value), { |
| 125 throw IterableElementError.noElement(); | 115 E orElse()} |
| 126 } | 116 ) { |
| 127 E lastWhere(bool test(E value), {E orElse()}) { | 117 for (E element in this) { |
| 128 E result = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", | 118 if (test(element)) return element; |
| 129 """line 159, column 16 of dart:collection/iterable.dart: """, __x0 is E, | 119 } |
| 130 false))(null); | 120 if (orElse != null) return orElse(); |
| 131 bool foundMatching = false; | 121 throw IterableElementError.noElement(); |
| 132 for (E element in this) { | 122 } |
| 133 if (test(element)) { | 123 E lastWhere(bool test(E value), { |
| 134 result = element; | 124 E orElse()} |
| 135 foundMatching = true; | 125 ) { |
| 136 } | 126 E result = ((__x0) => DDC$RT.cast(__x0, Null, E, "CastLiteral", """line 159, col
umn 16 of dart:collection/iterable.dart: """, __x0 is E, false))(null); |
| 137 } | 127 bool foundMatching = false; |
| 138 if (foundMatching) return result; | 128 for (E element in this) { |
| 139 if (orElse != null) return orElse(); | 129 if (test(element)) { |
| 140 throw IterableElementError.noElement(); | 130 result = element; |
| 141 } | 131 foundMatching = true; |
| 142 E singleWhere(bool test(E value)) { | 132 } |
| 143 E result = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", | 133 } |
| 144 """line 173, column 16 of dart:collection/iterable.dart: """, __x1 is E, | 134 if (foundMatching) return result; |
| 145 false))(null); | 135 if (orElse != null) return orElse(); |
| 146 bool foundMatching = false; | 136 throw IterableElementError.noElement(); |
| 147 for (E element in this) { | 137 } |
| 148 if (test(element)) { | 138 E singleWhere(bool test(E value)) { |
| 149 if (foundMatching) { | 139 E result = ((__x1) => DDC$RT.cast(__x1, Null, E, "CastLiteral", """line 173, col
umn 16 of dart:collection/iterable.dart: """, __x1 is E, false))(null); |
| 150 throw IterableElementError.tooMany(); | 140 bool foundMatching = false; |
| 151 } | 141 for (E element in this) { |
| 152 result = element; | 142 if (test(element)) { |
| 153 foundMatching = true; | 143 if (foundMatching) { |
| 154 } | 144 throw IterableElementError.tooMany(); |
| 155 } | 145 } |
| 156 if (foundMatching) return result; | 146 result = element; |
| 157 throw IterableElementError.noElement(); | 147 foundMatching = true; |
| 158 } | 148 } |
| 159 E elementAt(int index) { | 149 } |
| 160 if (index is! int) throw new ArgumentError.notNull("index"); | 150 if (foundMatching) return result; |
| 161 RangeError.checkNotNegative(index, "index"); | 151 throw IterableElementError.noElement(); |
| 162 int elementIndex = 0; | 152 } |
| 163 for (E element in this) { | 153 E elementAt(int index) { |
| 164 if (index == elementIndex) return element; | 154 if (index is! int) throw new ArgumentError.notNull("index"); |
| 165 elementIndex++; | 155 RangeError.checkNotNegative(index, "index"); |
| 166 } | 156 int elementIndex = 0; |
| 167 throw new RangeError.index(index, this, "index", null, elementIndex); | 157 for (E element in this) { |
| 168 } | 158 if (index == elementIndex) return element; |
| 169 String toString() => IterableBase.iterableToShortString(this, '(', ')'); | 159 elementIndex++; |
| 170 } | 160 } |
| 171 abstract class IterableBase<E> implements Iterable<E> { | 161 throw new RangeError.index(index, this, "index", null, elementIndex); |
| 172 const IterableBase(); | 162 } |
| 173 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); | 163 String toString() => IterableBase.iterableToShortString(this, '(', ')'); |
| 174 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); | 164 } |
| 175 Iterable expand(Iterable f(E element)) => | 165 abstract class IterableBase<E> implements Iterable<E> {const IterableBase(); |
| 176 new ExpandIterable<E, dynamic>(this, f); | 166 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); |
| 177 bool contains(Object element) { | 167 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); |
| 178 for (E e in this) { | 168 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this,
f); |
| 179 if (e == element) return true; | 169 bool contains(Object element) { |
| 180 } | 170 for (E e in this) { |
| 181 return false; | 171 if (e == element) return true; |
| 182 } | 172 } |
| 183 void forEach(void f(E element)) { | 173 return false; |
| 184 for (E element in this) f(element); | 174 } |
| 185 } | 175 void forEach(void f(E element)) { |
| 186 E reduce(E combine(E value, E element)) { | 176 for (E element in this) f(element); |
| 187 Iterator<E> iterator = this.iterator; | 177 } |
| 188 if (!iterator.moveNext()) { | 178 E reduce(E combine(E value, E element)) { |
| 189 throw IterableElementError.noElement(); | 179 Iterator<E> iterator = this.iterator; |
| 190 } | 180 if (!iterator.moveNext()) { |
| 191 E value = iterator.current; | 181 throw IterableElementError.noElement(); |
| 192 while (iterator.moveNext()) { | 182 } |
| 193 value = combine(value, iterator.current); | 183 E value = iterator.current; |
| 194 } | 184 while (iterator.moveNext()) { |
| 195 return value; | 185 value = combine(value, iterator.current); |
| 196 } | 186 } |
| 197 dynamic fold( | 187 return value; |
| 198 var initialValue, dynamic combine(var previousValue, E element)) { | 188 } |
| 199 var value = initialValue; | 189 dynamic fold(var initialValue, dynamic combine(var previousValue, E element)) { |
| 200 for (E element in this) value = combine(value, element); | 190 var value = initialValue; |
| 201 return value; | 191 for (E element in this) value = combine(value, element); |
| 202 } | 192 return value; |
| 203 bool every(bool f(E element)) { | 193 } |
| 204 for (E element in this) { | 194 bool every(bool f(E element)) { |
| 205 if (!f(element)) return false; | 195 for (E element in this) { |
| 206 } | 196 if (!f(element)) return false; |
| 207 return true; | 197 } |
| 208 } | 198 return true; |
| 209 String join([String separator = ""]) { | 199 } |
| 210 Iterator<E> iterator = this.iterator; | 200 String join([String separator = ""]) { |
| 211 if (!iterator.moveNext()) return ""; | 201 Iterator<E> iterator = this.iterator; |
| 212 StringBuffer buffer = new StringBuffer(); | 202 if (!iterator.moveNext()) return ""; |
| 213 if (separator == null || separator == "") { | 203 StringBuffer buffer = new StringBuffer(); |
| 214 do { | 204 if (separator == null || separator == "") { |
| 215 buffer.write("${iterator.current}"); | 205 do { |
| 216 } while (iterator.moveNext()); | 206 buffer.write("${iterator.current} |
| 217 } else { | 207 "); |
| 218 buffer.write("${iterator.current}"); | 208 } |
| 219 while (iterator.moveNext()) { | 209 while (iterator.moveNext());} |
| 220 buffer.write(separator); | 210 else { |
| 221 buffer.write("${iterator.current}"); | 211 buffer.write("${iterator.current} |
| 222 } | 212 "); |
| 223 } | 213 while (iterator.moveNext()) { |
| 224 return buffer.toString(); | 214 buffer.write(separator); |
| 225 } | 215 buffer.write("${iterator.current} |
| 226 bool any(bool f(E element)) { | 216 "); |
| 227 for (E element in this) { | 217 } |
| 228 if (f(element)) return true; | 218 } |
| 229 } | 219 return buffer.toString(); |
| 230 return false; | 220 } |
| 231 } | 221 bool any(bool f(E element)) { |
| 232 List<E> toList({bool growable: true}) => | 222 for (E element in this) { |
| 233 new List<E>.from(this, growable: growable); | 223 if (f(element)) return true; |
| 234 Set<E> toSet() => new Set<E>.from(this); | 224 } |
| 235 int get length { | 225 return false; |
| 236 assert(this is! EfficientLength); | 226 } |
| 237 int count = 0; | 227 List<E> toList({ |
| 238 Iterator it = iterator; | 228 bool growable : true} |
| 239 while (it.moveNext()) { | 229 ) => new List<E>.from(this, growable: growable); |
| 240 count++; | 230 Set<E> toSet() => new Set<E>.from(this); |
| 241 } | 231 int get length { |
| 242 return count; | 232 assert (this is! EfficientLength); int count = 0; |
| 243 } | 233 Iterator it = iterator; |
| 244 bool get isEmpty => !iterator.moveNext(); | 234 while (it.moveNext()) { |
| 245 bool get isNotEmpty => !isEmpty; | 235 count++; |
| 246 Iterable<E> take(int n) { | 236 } |
| 247 return new TakeIterable<E>(this, n); | 237 return count; |
| 248 } | 238 } |
| 249 Iterable<E> takeWhile(bool test(E value)) { | 239 bool get isEmpty => !iterator.moveNext(); |
| 250 return new TakeWhileIterable<E>(this, test); | 240 bool get isNotEmpty => !isEmpty; |
| 251 } | 241 Iterable<E> take(int n) { |
| 252 Iterable<E> skip(int n) { | 242 return new TakeIterable<E>(this, n); |
| 253 return new SkipIterable<E>(this, n); | 243 } |
| 254 } | 244 Iterable<E> takeWhile(bool test(E value)) { |
| 255 Iterable<E> skipWhile(bool test(E value)) { | 245 return new TakeWhileIterable<E>(this, test); |
| 256 return new SkipWhileIterable<E>(this, test); | 246 } |
| 257 } | 247 Iterable<E> skip(int n) { |
| 258 E get first { | 248 return new SkipIterable<E>(this, n); |
| 259 Iterator it = iterator; | 249 } |
| 260 if (!it.moveNext()) { | 250 Iterable<E> skipWhile(bool test(E value)) { |
| 261 throw IterableElementError.noElement(); | 251 return new SkipWhileIterable<E>(this, test); |
| 262 } | 252 } |
| 263 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 253 E get first { |
| 264 """line 323, column 12 of dart:collection/iterable.dart: """, | 254 Iterator it = iterator; |
| 265 it.current is E, false); | 255 if (!it.moveNext()) { |
| 266 } | 256 throw IterableElementError.noElement(); |
| 267 E get last { | 257 } |
| 268 Iterator it = iterator; | 258 return DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 323, column 1
2 of dart:collection/iterable.dart: """, it.current is E, false); |
| 269 if (!it.moveNext()) { | 259 } |
| 270 throw IterableElementError.noElement(); | 260 E get last { |
| 271 } | 261 Iterator it = iterator; |
| 272 E result; | 262 if (!it.moveNext()) { |
| 273 do { | 263 throw IterableElementError.noElement(); |
| 274 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 264 } |
| 275 """line 333, column 16 of dart:collection/iterable.dart: """, | 265 E result; |
| 276 it.current is E, false); | 266 do { |
| 277 } while (it.moveNext()); | 267 result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 333, column
16 of dart:collection/iterable.dart: """, it.current is E, false); |
| 278 return result; | 268 } |
| 279 } | 269 while (it.moveNext()); return result; |
| 280 E get single { | 270 } |
| 281 Iterator it = iterator; | 271 E get single { |
| 282 if (!it.moveNext()) throw IterableElementError.noElement(); | 272 Iterator it = iterator; |
| 283 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", | 273 if (!it.moveNext()) throw IterableElementError.noElement(); |
| 284 """line 341, column 16 of dart:collection/iterable.dart: """, | 274 E result = DDC$RT.cast(it.current, dynamic, E, "CastGeneral", """line 341, colu
mn 16 of dart:collection/iterable.dart: """, it.current is E, false); |
| 285 it.current is E, false); | 275 if (it.moveNext()) throw IterableElementError.tooMany(); |
| 286 if (it.moveNext()) throw IterableElementError.tooMany(); | 276 return result; |
| 287 return result; | 277 } |
| 288 } | 278 E firstWhere(bool test(E value), { |
| 289 E firstWhere(bool test(E value), {E orElse()}) { | 279 E orElse()} |
| 290 for (E element in this) { | 280 ) { |
| 291 if (test(element)) return element; | 281 for (E element in this) { |
| 292 } | 282 if (test(element)) return element; |
| 293 if (orElse != null) return orElse(); | 283 } |
| 294 throw IterableElementError.noElement(); | 284 if (orElse != null) return orElse(); |
| 295 } | 285 throw IterableElementError.noElement(); |
| 296 E lastWhere(bool test(E value), {E orElse()}) { | 286 } |
| 297 E result = ((__x2) => DDC$RT.cast(__x2, Null, E, "CastLiteral", | 287 E lastWhere(bool test(E value), { |
| 298 """line 355, column 16 of dart:collection/iterable.dart: """, __x2 is E, | 288 E orElse()} |
| 299 false))(null); | 289 ) { |
| 300 bool foundMatching = false; | 290 E result = ((__x2) => DDC$RT.cast(__x2, Null, E, "CastLiteral", """line 355, col
umn 16 of dart:collection/iterable.dart: """, __x2 is E, false))(null); |
| 301 for (E element in this) { | 291 bool foundMatching = false; |
| 302 if (test(element)) { | 292 for (E element in this) { |
| 303 result = element; | 293 if (test(element)) { |
| 304 foundMatching = true; | 294 result = element; |
| 305 } | 295 foundMatching = true; |
| 306 } | 296 } |
| 307 if (foundMatching) return result; | 297 } |
| 308 if (orElse != null) return orElse(); | 298 if (foundMatching) return result; |
| 309 throw IterableElementError.noElement(); | 299 if (orElse != null) return orElse(); |
| 310 } | 300 throw IterableElementError.noElement(); |
| 311 E singleWhere(bool test(E value)) { | 301 } |
| 312 E result = ((__x3) => DDC$RT.cast(__x3, Null, E, "CastLiteral", | 302 E singleWhere(bool test(E value)) { |
| 313 """line 369, column 16 of dart:collection/iterable.dart: """, __x3 is E, | 303 E result = ((__x3) => DDC$RT.cast(__x3, Null, E, "CastLiteral", """line 369, col
umn 16 of dart:collection/iterable.dart: """, __x3 is E, false))(null); |
| 314 false))(null); | 304 bool foundMatching = false; |
| 315 bool foundMatching = false; | 305 for (E element in this) { |
| 316 for (E element in this) { | 306 if (test(element)) { |
| 317 if (test(element)) { | 307 if (foundMatching) { |
| 318 if (foundMatching) { | 308 throw IterableElementError.tooMany(); |
| 319 throw IterableElementError.tooMany(); | 309 } |
| 320 } | 310 result = element; |
| 321 result = element; | 311 foundMatching = true; |
| 322 foundMatching = true; | 312 } |
| 323 } | 313 } |
| 324 } | 314 if (foundMatching) return result; |
| 325 if (foundMatching) return result; | 315 throw IterableElementError.noElement(); |
| 326 throw IterableElementError.noElement(); | 316 } |
| 327 } | 317 E elementAt(int index) { |
| 328 E elementAt(int index) { | 318 if (index is! int) throw new ArgumentError.notNull("index"); |
| 329 if (index is! int) throw new ArgumentError.notNull("index"); | 319 RangeError.checkNotNegative(index, "index"); |
| 330 RangeError.checkNotNegative(index, "index"); | 320 int elementIndex = 0; |
| 331 int elementIndex = 0; | 321 for (E element in this) { |
| 332 for (E element in this) { | 322 if (index == elementIndex) return element; |
| 333 if (index == elementIndex) return element; | 323 elementIndex++; |
| 334 elementIndex++; | 324 } |
| 335 } | 325 throw new RangeError.index(index, this, "index", null, elementIndex); |
| 336 throw new RangeError.index(index, this, "index", null, elementIndex); | 326 } |
| 337 } | 327 String toString() => iterableToShortString(this, '(', ')'); |
| 338 String toString() => iterableToShortString(this, '(', ')'); | 328 static String iterableToShortString(Iterable iterable, [String leftDelimiter =
'(', String rightDelimiter = ')']) { |
| 339 static String iterableToShortString(Iterable iterable, | 329 if (_isToStringVisiting(iterable)) { |
| 340 [String leftDelimiter = '(', String rightDelimiter = ')']) { | 330 if (leftDelimiter == "(" && rightDelimiter == ")") { |
| 341 if (_isToStringVisiting(iterable)) { | 331 return "(...)"; |
| 342 if (leftDelimiter == "(" && rightDelimiter == ")") { | 332 } |
| 343 return "(...)"; | 333 return "$leftDelimiter...$rightDelimiter"; |
| 344 } | 334 } |
| 345 return "$leftDelimiter...$rightDelimiter"; | 335 List parts = []; |
| 346 } | 336 _toStringVisiting.add(iterable); |
| 347 List parts = []; | 337 try { |
| 348 _toStringVisiting.add(iterable); | 338 _iterablePartsToStrings(iterable, parts); |
| 349 try { | 339 } |
| 350 _iterablePartsToStrings(iterable, parts); | 340 finally { |
| 351 } finally { | 341 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.removeLa
st(); |
| 352 assert(identical(_toStringVisiting.last, iterable)); | 342 } |
| 353 _toStringVisiting.removeLast(); | 343 return (new StringBuffer(leftDelimiter)..writeAll(parts, ", ")..write(rightDeli
miter)).toString(); |
| 354 } | 344 } |
| 355 return (new StringBuffer(leftDelimiter) | 345 static String iterableToFullString(Iterable iterable, [String leftDelimiter = '
(', String rightDelimiter = ')']) { |
| 356 ..writeAll(parts, ", ") | 346 if (_isToStringVisiting(iterable)) { |
| 357 ..write(rightDelimiter)).toString(); | 347 return "$leftDelimiter...$rightDelimiter"; |
| 358 } | 348 } |
| 359 static String iterableToFullString(Iterable iterable, | 349 StringBuffer buffer = new StringBuffer(leftDelimiter); |
| 360 [String leftDelimiter = '(', String rightDelimiter = ')']) { | 350 _toStringVisiting.add(iterable); |
| 361 if (_isToStringVisiting(iterable)) { | 351 try { |
| 362 return "$leftDelimiter...$rightDelimiter"; | 352 buffer.writeAll(iterable, ", "); |
| 363 } | 353 } |
| 364 StringBuffer buffer = new StringBuffer(leftDelimiter); | 354 finally { |
| 365 _toStringVisiting.add(iterable); | 355 assert (identical(_toStringVisiting.last, iterable)); _toStringVisiting.removeLa
st(); |
| 366 try { | 356 } |
| 367 buffer.writeAll(iterable, ", "); | 357 buffer.write(rightDelimiter); |
| 368 } finally { | 358 return buffer.toString(); |
| 369 assert(identical(_toStringVisiting.last, iterable)); | 359 } |
| 370 _toStringVisiting.removeLast(); | 360 static final List _toStringVisiting = []; |
| 371 } | 361 static bool _isToStringVisiting(Object o) { |
| 372 buffer.write(rightDelimiter); | 362 for (int i = 0; |
| 373 return buffer.toString(); | 363 i < _toStringVisiting.length; |
| 374 } | 364 i++) { |
| 375 static final List _toStringVisiting = []; | 365 if (identical(o, _toStringVisiting[i])) return true; |
| 376 static bool _isToStringVisiting(Object o) { | 366 } |
| 377 for (int i = 0; i < _toStringVisiting.length; i++) { | 367 return false; |
| 378 if (identical(o, _toStringVisiting[i])) return true; | 368 } |
| 379 } | 369 static void _iterablePartsToStrings(Iterable iterable, List parts) { |
| 380 return false; | 370 const int LENGTH_LIMIT = 80; |
| 381 } | 371 const int HEAD_COUNT = 3; |
| 382 static void _iterablePartsToStrings(Iterable iterable, List parts) { | 372 const int TAIL_COUNT = 2; |
| 383 const int LENGTH_LIMIT = 80; | 373 const int MAX_COUNT = 100; |
| 384 const int HEAD_COUNT = 3; | 374 const int OVERHEAD = 2; |
| 385 const int TAIL_COUNT = 2; | 375 const int ELLIPSIS_SIZE = 3; |
| 386 const int MAX_COUNT = 100; | 376 int length = 0; |
| 387 const int OVERHEAD = 2; | 377 int count = 0; |
| 388 const int ELLIPSIS_SIZE = 3; | 378 Iterator it = iterable.iterator; |
| 389 int length = 0; | 379 while (length < LENGTH_LIMIT || count < HEAD_COUNT) { |
| 390 int count = 0; | 380 if (!it.moveNext()) return; String next = "${it.current} |
| 391 Iterator it = iterable.iterator; | 381 "; |
| 392 while (length < LENGTH_LIMIT || count < HEAD_COUNT) { | 382 parts.add(next); |
| 393 if (!it.moveNext()) return; | 383 length += next.length + OVERHEAD; |
| 394 String next = "${it.current}"; | 384 count++; |
| 395 parts.add(next); | 385 } |
| 396 length += next.length + OVERHEAD; | 386 String penultimateString; |
| 397 count++; | 387 String ultimateString; |
| 398 } | 388 var penultimate = null; |
| 399 String penultimateString; | 389 var ultimate = null; |
| 400 String ultimateString; | 390 if (!it.moveNext()) { |
| 401 var penultimate = null; | 391 if (count <= HEAD_COUNT + TAIL_COUNT) return; ultimateString = ((__x4) => DDC$RT
.cast(__x4, dynamic, String, "CastGeneral", """line 530, column 24 of dart:colle
ction/iterable.dart: """, __x4 is String, true))(parts.removeLast()); |
| 402 var ultimate = null; | 392 penultimateString = ((__x5) => DDC$RT.cast(__x5, dynamic, String, "CastGeneral"
, """line 531, column 27 of dart:collection/iterable.dart: """, __x5 is String,
true))(parts.removeLast()); |
| 403 if (!it.moveNext()) { | 393 } |
| 404 if (count <= HEAD_COUNT + TAIL_COUNT) return; | 394 else { |
| 405 ultimateString = ((__x4) => DDC$RT.cast(__x4, dynamic, String, | 395 penultimate = it.current; |
| 406 "CastGeneral", | 396 count++; |
| 407 """line 530, column 24 of dart:collection/iterable.dart: """, | 397 if (!it.moveNext()) { |
| 408 __x4 is String, true))(parts.removeLast()); | 398 if (count <= HEAD_COUNT + 1) { |
| 409 penultimateString = ((__x5) => DDC$RT.cast(__x5, dynamic, String, | 399 parts.add("$penultimate"); |
| 410 "CastGeneral", | 400 return;} |
| 411 """line 531, column 27 of dart:collection/iterable.dart: """, | 401 ultimateString = "$penultimate"; |
| 412 __x5 is String, true))(parts.removeLast()); | 402 penultimateString = ((__x6) => DDC$RT.cast(__x6, dynamic, String, "CastGeneral"
, """line 541, column 29 of dart:collection/iterable.dart: """, __x6 is String,
true))(parts.removeLast()); |
| 413 } else { | 403 length += ultimateString.length + OVERHEAD; |
| 414 penultimate = it.current; | 404 } |
| 415 count++; | 405 else { |
| 416 if (!it.moveNext()) { | 406 ultimate = it.current; |
| 417 if (count <= HEAD_COUNT + 1) { | 407 count++; |
| 418 parts.add("$penultimate"); | 408 assert (count < MAX_COUNT); while (it.moveNext()) { |
| 419 return; | 409 penultimate = ultimate; |
| 420 } | 410 ultimate = it.current; |
| 421 ultimateString = "$penultimate"; | 411 count++; |
| 422 penultimateString = ((__x6) => DDC$RT.cast(__x6, dynamic, String, | 412 if (count > MAX_COUNT) { |
| 423 "CastGeneral", | 413 while (length > LENGTH_LIMIT - ELLIPSIS_SIZE - OVERHEAD && count > HEAD_COUNT) { |
| 424 """line 541, column 29 of dart:collection/iterable.dart: """, | 414 length -= ((__x7) => DDC$RT.cast(__x7, dynamic, int, "CastGeneral", """line 562,
column 25 of dart:collection/iterable.dart: """, __x7 is int, true))(parts.remo
veLast().length + OVERHEAD); |
| 425 __x6 is String, true))(parts.removeLast()); | 415 count--; |
| 426 length += ultimateString.length + OVERHEAD; | 416 } |
| 427 } else { | 417 parts.add("..."); |
| 428 ultimate = it.current; | 418 return;} |
| 429 count++; | 419 } |
| 430 assert(count < MAX_COUNT); | 420 penultimateString = "$penultimate"; |
| 431 while (it.moveNext()) { | 421 ultimateString = "$ultimate"; |
| 432 penultimate = ultimate; | 422 length += ultimateString.length + penultimateString.length + 2 * OVERHEAD; |
| 433 ultimate = it.current; | 423 } |
| 434 count++; | 424 } |
| 435 if (count > MAX_COUNT) { | 425 String elision = null; |
| 436 while (length > LENGTH_LIMIT - ELLIPSIS_SIZE - OVERHEAD && | 426 if (count > parts.length + TAIL_COUNT) { |
| 437 count > HEAD_COUNT) { | 427 elision = "..."; |
| 438 length -= ((__x7) => DDC$RT.cast(__x7, dynamic, int, | 428 length += ELLIPSIS_SIZE + OVERHEAD; |
| 439 "CastGeneral", | 429 } |
| 440 """line 562, column 25 of dart:collection/iterable.dart: """, | 430 while (length > LENGTH_LIMIT && parts.length > HEAD_COUNT) { |
| 441 __x7 is int, true))(parts.removeLast().length + OVERHEAD); | 431 length -= ((__x8) => DDC$RT.cast(__x8, dynamic, int, "CastGeneral", """line 588,
column 17 of dart:collection/iterable.dart: """, __x8 is int, true))(parts.remo
veLast().length + OVERHEAD); |
| 442 count--; | 432 if (elision == null) { |
| 443 } | 433 elision = "..."; |
| 444 parts.add("..."); | 434 length += ELLIPSIS_SIZE + OVERHEAD; |
| 445 return; | 435 } |
| 446 } | 436 } |
| 447 } | 437 if (elision != null) { |
| 448 penultimateString = "$penultimate"; | 438 parts.add(elision); |
| 449 ultimateString = "$ultimate"; | 439 } |
| 450 length += | 440 parts.add(penultimateString); |
| 451 ultimateString.length + penultimateString.length + 2 * OVERHEAD; | 441 parts.add(ultimateString); |
| 452 } | 442 } |
| 453 } | 443 } |
| 454 String elision = null; | |
| 455 if (count > parts.length + TAIL_COUNT) { | |
| 456 elision = "..."; | |
| 457 length += ELLIPSIS_SIZE + OVERHEAD; | |
| 458 } | |
| 459 while (length > LENGTH_LIMIT && parts.length > HEAD_COUNT) { | |
| 460 length -= ((__x8) => DDC$RT.cast(__x8, dynamic, int, "CastGeneral", | |
| 461 """line 588, column 17 of dart:collection/iterable.dart: """, | |
| 462 __x8 is int, true))(parts.removeLast().length + OVERHEAD); | |
| 463 if (elision == null) { | |
| 464 elision = "..."; | |
| 465 length += ELLIPSIS_SIZE + OVERHEAD; | |
| 466 } | |
| 467 } | |
| 468 if (elision != null) { | |
| 469 parts.add(elision); | |
| 470 } | |
| 471 parts.add(penultimateString); | |
| 472 parts.add(ultimateString); | |
| 473 } | |
| 474 } | |
| OLD | NEW |