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 class _GrowableObjectArray<T> implements List<T> { | 5 class _GrowableObjectArray<T> implements List<T> { |
6 factory _GrowableObjectArray._uninstantiable() { | 6 factory _GrowableObjectArray._uninstantiable() { |
7 throw new UnsupportedError( | 7 throw new UnsupportedError( |
8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
9 } | 9 } |
10 | 10 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 f(this[i]); | 219 f(this[i]); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 String join([String separator]) { | 223 String join([String separator]) { |
224 if (isEmpty) return ""; | 224 if (isEmpty) return ""; |
225 if (this.length == 1) return "${this[0]}"; | 225 if (this.length == 1) return "${this[0]}"; |
226 StringBuffer buffer = new StringBuffer(); | 226 StringBuffer buffer = new StringBuffer(); |
227 if (separator == null || separator == "") { | 227 if (separator == null || separator == "") { |
228 for (int i = 0; i < this.length; i++) { | 228 for (int i = 0; i < this.length; i++) { |
229 buffer.add("${this[i]}"); | 229 buffer.write("${this[i]}"); |
230 } | 230 } |
231 } else { | 231 } else { |
232 buffer.add("${this[0]}"); | 232 buffer.write("${this[0]}"); |
233 for (int i = 1; i < this.length; i++) { | 233 for (int i = 1; i < this.length; i++) { |
234 buffer.add(separator); | 234 buffer.write(separator); |
235 buffer.add("${this[i]}"); | 235 buffer.write("${this[i]}"); |
236 } | 236 } |
237 } | 237 } |
238 return buffer.toString(); | 238 return buffer.toString(); |
239 } | 239 } |
240 | 240 |
241 Iterable map(f(T element)) { | 241 Iterable map(f(T element)) { |
242 return IterableMixinWorkaround.mapList(this, f); | 242 return IterableMixinWorkaround.mapList(this, f); |
243 } | 243 } |
244 | 244 |
245 reduce(initialValue, combine(previousValue, T element)) { | 245 reduce(initialValue, combine(previousValue, T element)) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 | 322 |
323 Set<T> toSet() { | 323 Set<T> toSet() { |
324 return new Set<T>.from(this); | 324 return new Set<T>.from(this); |
325 } | 325 } |
326 | 326 |
327 Map<int, T> asMap() { | 327 Map<int, T> asMap() { |
328 return IterableMixinWorkaround.asMapList(this); | 328 return IterableMixinWorkaround.asMapList(this); |
329 } | 329 } |
330 } | 330 } |
OLD | NEW |