| 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 /** | 5 /** |
| 6 * A [List] is an indexable collection with a length. It can be of | 6 * A [List] is an indexable collection with a length. It can be of |
| 7 * fixed size or extendable. | 7 * fixed size or extendable. |
| 8 */ | 8 */ |
| 9 interface List<E> extends Collection<E>, Sequence<E> | 9 interface List<E> extends Collection<E>, Sequence<E> |
| 10 default _ListImpl<E> { | 10 default _ListImpl<E> { |
| 11 /** | 11 /** |
| 12 * Creates a list of the given [length]. | 12 * Creates an extendable list of the given [length]. |
| 13 * | |
| 14 * If no [length] argument is supplied an extendable list of | |
| 15 * length 0 is created. | |
| 16 * | |
| 17 * If a [length] argument is supplied, a fixed size list of that | |
| 18 * length is created. | |
| 19 */ | 13 */ |
| 20 List([int length]); | 14 List([int length = 0]); |
| 21 | 15 |
| 22 /** | 16 /** |
| 23 * Creates a list with the elements of [other]. The order in | 17 * Creates a fixed-sized list of the given [length] where each entry is |
| 18 * filled with [fill]. |
| 19 */ |
| 20 List.fixedLength(int length, {E fill: null}); |
| 21 |
| 22 /** |
| 23 * Creates an extendable list of the given [length] where each entry is |
| 24 * filled with [fill]. |
| 25 */ |
| 26 List.filled(int length, E fill); |
| 27 |
| 28 /** |
| 29 * Creates an extandable list with the elements of [other]. The order in |
| 24 * the list will be the order provided by the iterator of [other]. | 30 * the list will be the order provided by the iterator of [other]. |
| 25 */ | 31 */ |
| 26 List.from(Iterable<E> other); | 32 List.from(Iterable<E> other); |
| 27 | 33 |
| 28 /** | 34 /** |
| 29 * Returns the element at the given [index] in the list or throws | 35 * Returns the element at the given [index] in the list or throws |
| 30 * an [RangeError] if [index] is out of bounds. | 36 * an [RangeError] if [index] is out of bounds. |
| 31 */ | 37 */ |
| 32 E operator [](int index); | 38 E operator [](int index); |
| 33 | 39 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 * Throws an [RangeError] if [start] is negative or if | 178 * Throws an [RangeError] if [start] is negative or if |
| 173 * [start] is greater than the length of the list. | 179 * [start] is greater than the length of the list. |
| 174 */ | 180 */ |
| 175 void insertRange(int start, int length, [E initialValue]); | 181 void insertRange(int start, int length, [E initialValue]); |
| 176 } | 182 } |
| 177 | 183 |
| 178 class _ListImpl<E> { | 184 class _ListImpl<E> { |
| 179 /** | 185 /** |
| 180 * Factory implementation of List(). | 186 * Factory implementation of List(). |
| 181 * | 187 * |
| 182 * Creates a list of the given [length]. | 188 * Creates an extendable list of the given [length]. |
| 183 */ | 189 */ |
| 184 external factory List([int length]); | 190 external factory List([int length = 0]); |
| 191 |
| 192 /** |
| 193 * Creates a fixed-sized list of the given [length] where each entry is |
| 194 * filled with [fill]. |
| 195 */ |
| 196 external factory List.fixedLength(int length, {E fill: null}); |
| 197 |
| 198 /** |
| 199 * Creates an extendable list of the given [length] where each entry is |
| 200 * filled with [fill]. |
| 201 */ |
| 202 external factory List.filled(int length, E fill); |
| 185 | 203 |
| 186 /** | 204 /** |
| 187 * Factory implementation of List.from(). | 205 * Factory implementation of List.from(). |
| 188 * | 206 * |
| 189 * Creates a list with the elements of [other]. The order in | 207 * Creates a list with the elements of [other]. The order in |
| 190 * the list will be the order provided by the iterator of [other]. | 208 * the list will be the order provided by the iterator of [other]. |
| 191 */ | 209 */ |
| 192 external factory List.from(Iterable<E> other); | 210 external factory List.from(Iterable<E> other); |
| 193 } | 211 } |
| OLD | NEW |