Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: sdk/lib/core/list.dart

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address comments and fix. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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].
sra1 2012/11/07 21:36:34 'extendable' is not quite right since it can be sh
floitsch 2012/11/12 13:21:50 reworded.
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);
sra1 2012/11/07 21:36:34 It is a pity that 'fill' is a named parameter in o
floitsch 2012/11/12 13:21:50 Completely agree. There is bug open, but currently
27
28 /**
29 * Creates an extandable list with the elements of [other]. The order in
sra1 2012/11/07 21:36:34 extEndable, if you keep the name.
floitsch 2012/11/12 13:21:50 Reworded.
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 * [:start + length - 1:]. The entries are filled with [initialValue]. 171 * [:start + length - 1:]. The entries are filled with [initialValue].
166 * Throws an [UnsupportedError] if the list is 172 * Throws an [UnsupportedError] if the list is
167 * not extendable. 173 * not extendable.
168 * If [length] is 0, this method does not do anything. 174 * If [length] is 0, this method does not do anything.
169 * If [start] is the length of the list, this method inserts the 175 * If [start] is the length of the list, this method inserts the
170 * range at the end of the list. 176 * range at the end of the list.
171 * Throws an [ArgumentError] if [length] is negative. 177 * Throws an [ArgumentError] if [length] is negative.
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]);
sra1 2012/11/07 21:36:34 Should initialValue be renamed to fill?
floitsch 2012/11/12 13:21:50 Done.
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698