| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * Creates a fixed-length list of the given length, and initializes the | 100 * Creates a fixed-length list of the given length, and initializes the |
| 101 * value at each position with [fill]: | 101 * value at each position with [fill]: |
| 102 * | 102 * |
| 103 * new List<int>.filled(3, 0); // [0, 0, 0] | 103 * new List<int>.filled(3, 0); // [0, 0, 0] |
| 104 * | 104 * |
| 105 * The [length] must not be negative or null. | 105 * The [length] must not be negative or null. |
| 106 */ | 106 */ |
| 107 factory List.filled(int length, E fill) { | 107 factory List.filled(int length, E fill) { |
| 108 List result = new List<E>(length); | 108 List<E> result = new List<E>(length); |
| 109 if (length != 0 && fill != null) { | 109 if (length != 0 && fill != null) { |
| 110 for (int i = 0; i < result.length; i++) { | 110 for (int i = 0; i < result.length; i++) { |
| 111 result[i] = fill; | 111 result[i] = fill; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 return result; | 114 return result; |
| 115 } | 115 } |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * Creates a list containing all [elements]. | 118 * Creates a list containing all [elements]. |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 * | 741 * |
| 742 * List<String> words = ['fee', 'fi', 'fo', 'fum']; | 742 * List<String> words = ['fee', 'fi', 'fo', 'fum']; |
| 743 * Map<int, String> map = words.asMap(); | 743 * Map<int, String> map = words.asMap(); |
| 744 * map[0] + map[1]; // 'feefi'; | 744 * map[0] + map[1]; // 'feefi'; |
| 745 * map.keys.toList(); // [0, 1, 2, 3] | 745 * map.keys.toList(); // [0, 1, 2, 3] |
| 746 */ | 746 */ |
| 747 Map<int, E> asMap() { | 747 Map<int, E> asMap() { |
| 748 return new IterableMixinWorkaround<E>().asMapList(this); | 748 return new IterableMixinWorkaround<E>().asMapList(this); |
| 749 } | 749 } |
| 750 } | 750 } |
| OLD | NEW |