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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } else { | 115 } else { |
116 result = new List<E>(length); | 116 result = new List<E>(length); |
117 } | 117 } |
118 for (int i = 0; i < length; i++) { | 118 for (int i = 0; i < length; i++) { |
119 result[i] = generator(i); | 119 result[i] = generator(i); |
120 } | 120 } |
121 return result; | 121 return result; |
122 } | 122 } |
123 | 123 |
124 /** | 124 /** |
| 125 * Creates an unmodifiable list containing all [elements]. |
| 126 * |
| 127 * The [Iterator] of [elements] provides the order of the elements. |
| 128 * |
| 129 * An unmodifiable list cannot have its length or elements changed. |
| 130 * If the elements are themselves immutable, then the resulting list |
| 131 * is also immutable. |
| 132 */ |
| 133 external factory List.unmodifiable(Iterable elements); |
| 134 |
| 135 /** |
125 * Returns the object at the given [index] in the list | 136 * Returns the object at the given [index] in the list |
126 * or throws a [RangeError] if [index] is out of bounds. | 137 * or throws a [RangeError] if [index] is out of bounds. |
127 */ | 138 */ |
128 E operator [](int index); | 139 E operator [](int index); |
129 | 140 |
130 /** | 141 /** |
131 * Sets the value at the given [index] in the list to [value] | 142 * Sets the value at the given [index] in the list to [value] |
132 * or throws a [RangeError] if [index] is out of bounds. | 143 * or throws a [RangeError] if [index] is out of bounds. |
133 */ | 144 */ |
134 void operator []=(int index, E value); | 145 void operator []=(int index, E value); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 * as values. The `Map.keys` [Iterable] iterates the indices of this list | 465 * as values. The `Map.keys` [Iterable] iterates the indices of this list |
455 * in numerical order. | 466 * in numerical order. |
456 * | 467 * |
457 * List<String> words = ['fee', 'fi', 'fo', 'fum']; | 468 * List<String> words = ['fee', 'fi', 'fo', 'fum']; |
458 * Map<int, String> map = words.asMap(); | 469 * Map<int, String> map = words.asMap(); |
459 * map[0] + map[1]; // 'feefi'; | 470 * map[0] + map[1]; // 'feefi'; |
460 * map.keys.toList(); // [0, 1, 2, 3] | 471 * map.keys.toList(); // [0, 1, 2, 3] |
461 */ | 472 */ |
462 Map<int, E> asMap(); | 473 Map<int, E> asMap(); |
463 } | 474 } |
OLD | NEW |