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