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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 * Changes the length of this list. | 147 * Changes the length of this list. |
148 * | 148 * |
149 * If [newLength] is greater than | 149 * If [newLength] is greater than |
150 * the current length, entries are initialized to [:null:]. | 150 * the current length, entries are initialized to [:null:]. |
151 * | 151 * |
152 * Throws an [UnsupportedError] if the list is fixed-length. | 152 * Throws an [UnsupportedError] if the list is fixed-length. |
153 */ | 153 */ |
154 void set length(int newLength); | 154 void set length(int newLength); |
155 | 155 |
156 /** | 156 /** |
| 157 * Replaces the last element of the list with [value]. |
| 158 * |
| 159 * Using `list.last = value` is equivalent to `list[list.length - 1] = value`, |
| 160 * only shorter and more readable. |
| 161 * |
| 162 * The list must be modifiable and must have a length greater than zero. |
| 163 */ |
| 164 void set last(E value); |
| 165 |
| 166 /** |
157 * Adds [value] to the end of this list, | 167 * Adds [value] to the end of this list, |
158 * extending the length by one. | 168 * extending the length by one. |
159 * | 169 * |
160 * Throws an [UnsupportedError] if the list is fixed-length. | 170 * Throws an [UnsupportedError] if the list is fixed-length. |
161 */ | 171 */ |
162 void add(E value); | 172 void add(E value); |
163 | 173 |
164 /** | 174 /** |
165 * Appends all objects of [iterable] to the end of this list. | 175 * Appends all objects of [iterable] to the end of this list. |
166 * | 176 * |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 * as values. The `Map.keys` [Iterable] iterates the indices of this list | 464 * as values. The `Map.keys` [Iterable] iterates the indices of this list |
455 * in numerical order. | 465 * in numerical order. |
456 * | 466 * |
457 * List<String> words = ['fee', 'fi', 'fo', 'fum']; | 467 * List<String> words = ['fee', 'fi', 'fo', 'fum']; |
458 * Map<int, String> map = words.asMap(); | 468 * Map<int, String> map = words.asMap(); |
459 * map[0] + map[1]; // 'feefi'; | 469 * map[0] + map[1]; // 'feefi'; |
460 * map.keys.toList(); // [0, 1, 2, 3] | 470 * map.keys.toList(); // [0, 1, 2, 3] |
461 */ | 471 */ |
462 Map<int, E> asMap(); | 472 Map<int, E> asMap(); |
463 } | 473 } |
OLD | NEW |