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

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

Issue 2754013002: Format all dart: library files (Closed)
Patch Set: Created 3 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
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 * 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 external factory List.filled(int length, E fill, {bool growable: false}); 110 external factory List.filled(int length, E fill, {bool growable: false});
111 111
112 /** 112 /**
113 * Creates a list containing all [elements]. 113 * Creates a list containing all [elements].
114 * 114 *
115 * The [Iterator] of [elements] provides the order of the elements. 115 * The [Iterator] of [elements] provides the order of the elements.
116 * 116 *
117 * This constructor returns a growable list when [growable] is true; 117 * This constructor returns a growable list when [growable] is true;
118 * otherwise, it returns a fixed-length list. 118 * otherwise, it returns a fixed-length list.
119 */ 119 */
120 external factory List.from(Iterable elements, { bool growable: true }); 120 external factory List.from(Iterable elements, {bool growable: true});
121 121
122 /** 122 /**
123 * Generates a list of values. 123 * Generates a list of values.
124 * 124 *
125 * Creates a list with [length] positions and fills it with values created by 125 * Creates a list with [length] positions and fills it with values created by
126 * calling [generator] for each index in the range `0` .. `length - 1` 126 * calling [generator] for each index in the range `0` .. `length - 1`
127 * in increasing order. 127 * in increasing order.
128 * 128 *
129 * new List<int>.generate(3, (int index) => index * index); // [0, 1, 4] 129 * new List<int>.generate(3, (int index) => index * index); // [0, 1, 4]
130 * 130 *
131 * The created list is fixed-length unless [growable] is true. 131 * The created list is fixed-length unless [growable] is true.
132 */ 132 */
133 factory List.generate(int length, E generator(int index), 133 factory List.generate(int length, E generator(int index),
134 { bool growable: true }) { 134 {bool growable: true}) {
135 List<E> result; 135 List<E> result;
136 if (growable) { 136 if (growable) {
137 result = <E>[]..length = length; 137 result = <E>[]..length = length;
138 } else { 138 } else {
139 result = new List<E>(length); 139 result = new List<E>(length);
140 } 140 }
141 for (int i = 0; i < length; i++) { 141 for (int i = 0; i < length; i++) {
142 result[i] = generator(i); 142 result[i] = generator(i);
143 } 143 }
144 return result; 144 return result;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 * as values. The `Map.keys` [Iterable] iterates the indices of this list 511 * as values. The `Map.keys` [Iterable] iterates the indices of this list
512 * in numerical order. 512 * in numerical order.
513 * 513 *
514 * List<String> words = ['fee', 'fi', 'fo', 'fum']; 514 * List<String> words = ['fee', 'fi', 'fo', 'fum'];
515 * Map<int, String> map = words.asMap(); 515 * Map<int, String> map = words.asMap();
516 * map[0] + map[1]; // 'feefi'; 516 * map[0] + map[1]; // 'feefi';
517 * map.keys.toList(); // [0, 1, 2, 3] 517 * map.keys.toList(); // [0, 1, 2, 3]
518 */ 518 */
519 Map<int, E> asMap(); 519 Map<int, E> asMap();
520 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698