| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of _interceptors; | 5 part of _interceptors; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The interceptor class for [List]. The compiler recognizes this | 8 * The interceptor class for [List]. The compiler recognizes this |
| 9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
| 10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 void forEach(void f(E element)) { | 87 void forEach(void f(E element)) { |
| 88 return IterableMixinWorkaround.forEach(this, f); | 88 return IterableMixinWorkaround.forEach(this, f); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Iterable map(f(E element)) { | 91 Iterable map(f(E element)) { |
| 92 return IterableMixinWorkaround.mapList(this, f); | 92 return IterableMixinWorkaround.mapList(this, f); |
| 93 } | 93 } |
| 94 | 94 |
| 95 List mappedBy(f(E element)) { |
| 96 return IterableMixinWorkaround.mappedByList(this, f); |
| 97 } |
| 98 |
| 95 String join([String separator]) { | 99 String join([String separator]) { |
| 96 if (separator == null) separator = ""; | 100 if (separator == null) separator = ""; |
| 97 var list = new List(this.length); | 101 var list = new List(this.length); |
| 98 for (int i = 0; i < this.length; i++) { | 102 for (int i = 0; i < this.length; i++) { |
| 99 list[i] = "${this[i]}"; | 103 list[i] = "${this[i]}"; |
| 100 } | 104 } |
| 101 return JS('String', "#.join(#)", list, separator); | 105 return JS('String', "#.join(#)", list, separator); |
| 102 } | 106 } |
| 103 | 107 |
| 104 Iterable<E> take(int n) { | 108 Iterable<E> take(int n) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 throw new RangeError.value(start + length); | 223 throw new RangeError.value(start + length); |
| 220 } | 224 } |
| 221 | 225 |
| 222 Arrays.copy(from, startFrom, this, start, length); | 226 Arrays.copy(from, startFrom, this, start, length); |
| 223 } | 227 } |
| 224 | 228 |
| 225 bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f); | 229 bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f); |
| 226 | 230 |
| 227 bool every(bool f(E element)) => IterableMixinWorkaround.every(this, f); | 231 bool every(bool f(E element)) => IterableMixinWorkaround.every(this, f); |
| 228 | 232 |
| 229 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 233 List<E> get reversed => IterableMixinWorkaround.reversedList(this); |
| 230 | 234 |
| 231 void sort([int compare(E a, E b)]) { | 235 void sort([int compare(E a, E b)]) { |
| 232 checkMutable(this, 'sort'); | 236 checkMutable(this, 'sort'); |
| 233 IterableMixinWorkaround.sortList(this, compare); | 237 IterableMixinWorkaround.sortList(this, compare); |
| 234 } | 238 } |
| 235 | 239 |
| 236 int indexOf(E element, [int start = 0]) { | 240 int indexOf(E element, [int start = 0]) { |
| 237 if (start is !int) throw new ArgumentError(start); | 241 if (start is !int) throw new ArgumentError(start); |
| 238 return Arrays.indexOf(this, element, start, length); | 242 return Arrays.indexOf(this, element, start, length); |
| 239 } | 243 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 return JS('var', '#[#]', this, index); | 286 return JS('var', '#[#]', this, index); |
| 283 } | 287 } |
| 284 | 288 |
| 285 void operator []=(int index, E value) { | 289 void operator []=(int index, E value) { |
| 286 checkMutable(this, 'indexed set'); | 290 checkMutable(this, 'indexed set'); |
| 287 if (index is !int) throw new ArgumentError(index); | 291 if (index is !int) throw new ArgumentError(index); |
| 288 if (index >= length || index < 0) throw new RangeError.value(index); | 292 if (index >= length || index < 0) throw new RangeError.value(index); |
| 289 JS('void', r'#[#] = #', this, index, value); | 293 JS('void', r'#[#] = #', this, index, value); |
| 290 } | 294 } |
| 291 } | 295 } |
| OLD | NEW |