| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 * value at each position with [fill]: | 81 * value at each position with [fill]: |
| 82 * | 82 * |
| 83 * new List<int>.filled(3, 0); // [0, 0, 0] | 83 * new List<int>.filled(3, 0); // [0, 0, 0] |
| 84 * | 84 * |
| 85 * The [length] must be a non-negative integer. | 85 * The [length] must be a non-negative integer. |
| 86 * | 86 * |
| 87 * If the list is growable, changing its length will not initialize new | 87 * If the list is growable, changing its length will not initialize new |
| 88 * entries with [fill]. After being created and filled, the list is | 88 * entries with [fill]. After being created and filled, the list is |
| 89 * no different from any other growable or fixed-length list | 89 * no different from any other growable or fixed-length list |
| 90 * created using [List]. | 90 * created using [List]. |
| 91 * |
| 92 * All entries in the returned list point to the same provided [fill] value. |
| 93 * That all items in the list are the same object is |
| 94 * observable when the given value is a mutable object. |
| 95 * |
| 96 * ``` |
| 97 * var shared = new List.filled(3, []); |
| 98 * shared[0].add(499); |
| 99 * print(shared); // => [[499], [499], [499]] |
| 100 * ``` |
| 101 * |
| 102 * You may use [List.generate] to create a new object for each position in |
| 103 * in the list. |
| 104 * ``` |
| 105 * var unique = new List.generate(3, (_) => []); |
| 106 * unique[0].add(499); |
| 107 * print(unique); // => [[499], [], []] |
| 108 * ``` |
| 91 */ | 109 */ |
| 92 external factory List.filled(int length, E fill, {bool growable: false}); | 110 external factory List.filled(int length, E fill, {bool growable: false}); |
| 93 | 111 |
| 94 /** | 112 /** |
| 95 * Creates a list containing all [elements]. | 113 * Creates a list containing all [elements]. |
| 96 * | 114 * |
| 97 * The [Iterator] of [elements] provides the order of the elements. | 115 * The [Iterator] of [elements] provides the order of the elements. |
| 98 * | 116 * |
| 99 * This constructor returns a growable list when [growable] is true; | 117 * This constructor returns a growable list when [growable] is true; |
| 100 * otherwise, it returns a fixed-length list. | 118 * otherwise, it returns a fixed-length list. |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 * as values. The `Map.keys` [Iterable] iterates the indices of this list | 498 * as values. The `Map.keys` [Iterable] iterates the indices of this list |
| 481 * in numerical order. | 499 * in numerical order. |
| 482 * | 500 * |
| 483 * List<String> words = ['fee', 'fi', 'fo', 'fum']; | 501 * List<String> words = ['fee', 'fi', 'fo', 'fum']; |
| 484 * Map<int, String> map = words.asMap(); | 502 * Map<int, String> map = words.asMap(); |
| 485 * map[0] + map[1]; // 'feefi'; | 503 * map[0] + map[1]; // 'feefi'; |
| 486 * map.keys.toList(); // [0, 1, 2, 3] | 504 * map.keys.toList(); // [0, 1, 2, 3] |
| 487 */ | 505 */ |
| 488 Map<int, E> asMap(); | 506 Map<int, E> asMap(); |
| 489 } | 507 } |
| OLD | NEW |