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 ListImplementation<E> { | 10 default _ListImpl<E> { |
11 /** | 11 /** |
12 * Creates a list of the given [length]. | 12 * Creates a list of the given [length]. |
13 * | 13 * |
14 * If no [length] argument is supplied an extendable list of | 14 * If no [length] argument is supplied an extendable list of |
15 * length 0 is created. | 15 * length 0 is created. |
16 * | 16 * |
17 * If a [length] argument is supplied, a fixed size list of that | 17 * If a [length] argument is supplied, a fixed size list of that |
18 * length is created. | 18 * length is created. |
19 */ | 19 */ |
20 List([int length]); | 20 List([int length]); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 * not extendable. | 167 * not extendable. |
168 * If [length] is 0, this method does not do anything. | 168 * If [length] is 0, this method does not do anything. |
169 * If [start] is the length of the list, this method inserts the | 169 * If [start] is the length of the list, this method inserts the |
170 * range at the end of the list. | 170 * range at the end of the list. |
171 * Throws an [ArgumentError] if [length] is negative. | 171 * Throws an [ArgumentError] if [length] is negative. |
172 * Throws an [IndexOutOfRangeException] if [start] is negative or if | 172 * Throws an [IndexOutOfRangeException] if [start] is negative or if |
173 * [start] is greater than the length of the list. | 173 * [start] is greater than the length of the list. |
174 */ | 174 */ |
175 void insertRange(int start, int length, [E initialValue]); | 175 void insertRange(int start, int length, [E initialValue]); |
176 } | 176 } |
| 177 |
| 178 class _ListImpl<E> { |
| 179 /** |
| 180 * Factory implementation of List(). |
| 181 * |
| 182 * Creates a list of the given [length]. |
| 183 */ |
| 184 external factory List([int length]); |
| 185 |
| 186 /** |
| 187 * Factory implementation of List.from(). |
| 188 * |
| 189 * Creates a list with the elements of [other]. The order in |
| 190 * the list will be the order provided by the iterator of [other]. |
| 191 */ |
| 192 external factory List.from(Iterable<E> other); |
| 193 } |
OLD | NEW |