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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 void forEach(f(T element)) { | 237 void forEach(f(T element)) { |
238 // TODO(srdjan): Use IterableMixinWorkaround.forEach(this, f); | 238 // TODO(srdjan): Use IterableMixinWorkaround.forEach(this, f); |
239 // Accessing the list directly improves DeltaBlue performance by 25%. | 239 // Accessing the list directly improves DeltaBlue performance by 25%. |
240 for (int i = 0; i < length; i++) { | 240 for (int i = 0; i < length; i++) { |
241 f(this[i]); | 241 f(this[i]); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 String join([String separator]) { | 245 String join([String separator = ""]) { |
246 if (isEmpty) return ""; | 246 if (isEmpty) return ""; |
247 if (this.length == 1) return "${this[0]}"; | 247 if (this.length == 1) return "${this[0]}"; |
248 StringBuffer buffer = new StringBuffer(); | 248 StringBuffer buffer = new StringBuffer(); |
249 if (separator == null || separator == "") { | 249 if (separator.isEmpty) { |
250 for (int i = 0; i < this.length; i++) { | 250 for (int i = 0; i < this.length; i++) { |
251 buffer.write("${this[i]}"); | 251 buffer.write("${this[i]}"); |
252 } | 252 } |
253 } else { | 253 } else { |
254 buffer.write("${this[0]}"); | 254 buffer.write("${this[0]}"); |
255 for (int i = 1; i < this.length; i++) { | 255 for (int i = 1; i < this.length; i++) { |
256 buffer.write(separator); | 256 buffer.write(separator); |
257 buffer.write("${this[i]}"); | 257 buffer.write("${this[i]}"); |
258 } | 258 } |
259 } | 259 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 Set<T> toSet() { | 349 Set<T> toSet() { |
350 return new Set<T>.from(this); | 350 return new Set<T>.from(this); |
351 } | 351 } |
352 | 352 |
353 Map<int, T> asMap() { | 353 Map<int, T> asMap() { |
354 return IterableMixinWorkaround.asMapList(this); | 354 return IterableMixinWorkaround.asMapList(this); |
355 } | 355 } |
356 } | 356 } |
OLD | NEW |