| 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 dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An indexable collection of objects with a length. | 8 * An indexable collection of objects with a length. |
| 9 * | 9 * |
| 10 * Subclasses of this class implement different kinds of lists. | 10 * Subclasses of this class implement different kinds of lists. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool get isEmpty => length == 0; | 239 bool get isEmpty => length == 0; |
| 240 | 240 |
| 241 bool get isNotEmpty => !isEmpty; | 241 bool get isNotEmpty => !isEmpty; |
| 242 | 242 |
| 243 String toString() => ListBase.listToString(this); | 243 String toString() => ListBase.listToString(this); |
| 244 | 244 |
| 245 List<E> toList({ bool growable: true }) { | 245 List<E> toList({ bool growable: true }) { |
| 246 if (growable) { | 246 // TODO(vsm): Enforce growable / non-growable. |
| 247 return new JSArray<E>.markGrowable(JS('', '#.slice()', this)); | 247 // See: https://github.com/dart-lang/dev_compiler/issues/175 |
| 248 } else { | 248 return JS('', 'dart.setType(#.slice(), core.List\$(#))', this, E); |
| 249 return new JSArray<E>.markFixed(JS('', '#.slice()', this)); | |
| 250 } | |
| 251 } | 249 } |
| 252 | 250 |
| 253 Set<E> toSet() => new Set<E>.from(this); | 251 Set<E> toSet() => new Set<E>.from(this); |
| 254 | 252 |
| 255 Iterator<E> get iterator => new ListIterator<E>(this); | 253 Iterator<E> get iterator => new ListIterator<E>(this); |
| 256 | 254 |
| 257 int get hashCode => Primitives.objectHashCode(this); | 255 int get hashCode => Primitives.objectHashCode(this); |
| 258 | 256 |
| 259 // BORDER XXXX | 257 // BORDER XXXX |
| 260 | 258 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 * | 706 * |
| 709 * List<String> words = ['fee', 'fi', 'fo', 'fum']; | 707 * List<String> words = ['fee', 'fi', 'fo', 'fum']; |
| 710 * Map<int, String> map = words.asMap(); | 708 * Map<int, String> map = words.asMap(); |
| 711 * map[0] + map[1]; // 'feefi'; | 709 * map[0] + map[1]; // 'feefi'; |
| 712 * map.keys.toList(); // [0, 1, 2, 3] | 710 * map.keys.toList(); // [0, 1, 2, 3] |
| 713 */ | 711 */ |
| 714 Map<int, E> asMap() { | 712 Map<int, E> asMap() { |
| 715 return new IterableMixinWorkaround<E>().asMapList(this); | 713 return new IterableMixinWorkaround<E>().asMapList(this); |
| 716 } | 714 } |
| 717 } | 715 } |
| OLD | NEW |