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

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

Issue 12335131: Make List.from default to not growable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix one more from. Created 7 years, 9 months 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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A [List] is an indexable collection with a length. 8 * A [List] is an indexable collection with a length.
9 * 9 *
10 * A `List` implementation can be choose not to support all methods 10 * A `List` implementation can be choose not to support all methods
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * *Deprecated*: Use `new List(count)` instead. 53 * *Deprecated*: Use `new List(count)` instead.
54 */ 54 */
55 factory List.fixedLength(int count) => new List(count); 55 factory List.fixedLength(int count) => new List(count);
56 56
57 /** 57 /**
58 * Creates an list with the elements of [other]. The order in 58 * Creates an list with the elements of [other]. The order in
59 * the list will be the order provided by the iterator of [other]. 59 * the list will be the order provided by the iterator of [other].
60 * 60 *
61 * The length of the returned list is not fixed. 61 * The length of the returned list is not fixed.
62 */ 62 */
63 factory List.from(Iterable other, { bool growable: true }) { 63 factory List.from(Iterable other, { bool growable: false }) {
64 List<E> list = new List<E>(); 64 List<E> list = new List<E>();
65 for (E e in other) { 65 for (E e in other) {
66 list.add(e); 66 list.add(e);
67 } 67 }
68 if (growable) return list; 68 if (growable) return list;
69 int length = list.length; 69 int length = list.length;
70 List<E> fixedList = new List<E>(length); 70 List<E> fixedList = new List<E>(length);
71 for (int i = 0; i < length; i++) { 71 for (int i = 0; i < length; i++) {
72 fixedList[i] = list[i]; 72 fixedList[i] = list[i];
73 } 73 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 * not extendable. 241 * not extendable.
242 * If [length] is 0, this method does not do anything. 242 * If [length] is 0, this method does not do anything.
243 * If [start] is the length of the list, this method inserts the 243 * If [start] is the length of the list, this method inserts the
244 * range at the end of the list. 244 * range at the end of the list.
245 * Throws an [ArgumentError] if [length] is negative. 245 * Throws an [ArgumentError] if [length] is negative.
246 * Throws an [RangeError] if [start] is negative or if 246 * Throws an [RangeError] if [start] is negative or if
247 * [start] is greater than the length of the list. 247 * [start] is greater than the length of the list.
248 */ 248 */
249 void insertRange(int start, int length, [E fill]); 249 void insertRange(int start, int length, [E fill]);
250 } 250 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/bailout.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698