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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 void clear() { | 79 void clear() { |
80 length = 0; | 80 length = 0; |
81 } | 81 } |
82 | 82 |
83 void forEach(void f(E element)) { | 83 void forEach(void f(E element)) { |
84 return IterableMixinWorkaround.forEach(this, f); | 84 return IterableMixinWorkaround.forEach(this, f); |
85 } | 85 } |
86 | 86 |
| 87 Iterable map(f(E element)) { |
| 88 return IterableMixinWorkaround.map(this, f); |
| 89 } |
| 90 |
87 List mappedBy(f(E element)) { | 91 List mappedBy(f(E element)) { |
88 return IterableMixinWorkaround.mappedByList(this, f); | 92 return IterableMixinWorkaround.mappedByList(this, f); |
89 } | 93 } |
90 | 94 |
91 String join([String separator]) { | 95 String join([String separator]) { |
92 if (separator == null) separator = ""; | 96 if (separator == null) separator = ""; |
93 var list = new List(this.length); | 97 var list = new List(this.length); |
94 for (int i = 0; i < this.length; i++) { | 98 for (int i = 0; i < this.length; i++) { |
95 list[i] = "${this[i]}"; | 99 list[i] = "${this[i]}"; |
96 } | 100 } |
97 return JS('String', "#.join(#)", list, separator); | 101 return JS('String', "#.join(#)", list, separator); |
98 } | 102 } |
99 | 103 |
100 List<E> take(int n) { | 104 Iterable<E> take(int n) { |
101 return IterableMixinWorkaround.takeList(this, n); | 105 return IterableMixinWorkaround.takeList(this, n); |
102 } | 106 } |
103 | 107 |
104 Iterable<E> takeWhile(bool test(E value)) { | 108 Iterable<E> takeWhile(bool test(E value)) { |
105 return IterableMixinWorkaround.takeWhile(this, test); | 109 return IterableMixinWorkaround.takeWhile(this, test); |
106 } | 110 } |
107 | 111 |
108 List<E> skip(int n) { | 112 Iterable<E> skip(int n) { |
109 return IterableMixinWorkaround.skipList(this, n); | 113 return IterableMixinWorkaround.skipList(this, n); |
110 } | 114 } |
111 | 115 |
112 Iterable<E> skipWhile(bool test(E value)) { | 116 Iterable<E> skipWhile(bool test(E value)) { |
113 return IterableMixinWorkaround.skipWhile(this, test); | 117 return IterableMixinWorkaround.skipWhile(this, test); |
114 } | 118 } |
115 | 119 |
116 reduce(initialValue, combine(previousValue, E element)) { | 120 reduce(initialValue, combine(previousValue, E element)) { |
117 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 121 return IterableMixinWorkaround.reduce(this, initialValue, combine); |
118 } | 122 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 return JS('var', '#[#]', this, index); | 282 return JS('var', '#[#]', this, index); |
279 } | 283 } |
280 | 284 |
281 void operator []=(int index, E value) { | 285 void operator []=(int index, E value) { |
282 checkMutable(this, 'indexed set'); | 286 checkMutable(this, 'indexed set'); |
283 if (index is !int) throw new ArgumentError(index); | 287 if (index is !int) throw new ArgumentError(index); |
284 if (index >= length || index < 0) throw new RangeError.value(index); | 288 if (index >= length || index < 0) throw new RangeError.value(index); |
285 JS('void', r'#[#] = #', this, index, value); | 289 JS('void', r'#[#] = #', this, index, value); |
286 } | 290 } |
287 } | 291 } |
OLD | NEW |