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