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

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

Issue 838463002: Change List/Set/Map/Queue.from constructrs to accept any iterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 * 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 * Creates a fixed-length list of the given length, and initializes the 80 * Creates a fixed-length list of the given length, and initializes the
81 * value at each position with [fill]: 81 * value at each position with [fill]:
82 * 82 *
83 * new List<int>.filled(3, 0); // [0, 0, 0] 83 * new List<int>.filled(3, 0); // [0, 0, 0]
84 * 84 *
85 * The [length] must not be negative or null. 85 * The [length] must not be negative or null.
86 */ 86 */
87 external factory List.filled(int length, E fill); 87 external factory List.filled(int length, E fill);
88 88
89 /** 89 /**
90 * Creates a list and initializes it using the contents of [other]. 90 * Creates a list containing all of [elements].
91 * 91 *
92 * The [Iterator] of [other] provides the order of the objects. 92 * The [Iterator] of [elements] provides the order of the elements.
93 * 93 *
94 * This constructor returns a growable list if [growable] is true; 94 * This constructor returns a growable list when [growable] is true;
95 * otherwise, it returns a fixed-length list. 95 * otherwise, it returns a fixed-length list.
96 */ 96 */
97 external factory List.from(Iterable other, { bool growable: true }); 97 external factory List.from(Iterable elements, { bool growable: true });
98 98
99 /** 99 /**
100 * Generates a list of values. 100 * Generates a list of values.
101 * 101 *
102 * Creates a list with [length] positions and fills it with values created by 102 * Creates a list with [length] positions and fills it with values created by
103 * calling [generator] for each index in the range `0` .. `length - 1` 103 * calling [generator] for each index in the range `0` .. `length - 1`
104 * in increasing order. 104 * in increasing order.
105 * 105 *
106 * new List<int>.generate(3, (int index) => index * index); // [0, 1, 4] 106 * new List<int>.generate(3, (int index) => index * index); // [0, 1, 4]
107 * 107 *
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 * as values. The `Map.keys` [Iterable] iterates the indices of this list 451 * as values. The `Map.keys` [Iterable] iterates the indices of this list
452 * in numerical order. 452 * in numerical order.
453 * 453 *
454 * List<String> words = ['fee', 'fi', 'fo', 'fum']; 454 * List<String> words = ['fee', 'fi', 'fo', 'fum'];
455 * Map<int, String> map = words.asMap(); 455 * Map<int, String> map = words.asMap();
456 * map[0] + map[1]; // 'feefi'; 456 * map[0] + map[1]; // 'feefi';
457 * map.keys.toList(); // [0, 1, 2, 3] 457 * map.keys.toList(); // [0, 1, 2, 3]
458 */ 458 */
459 Map<int, E> asMap(); 459 Map<int, E> asMap();
460 } 460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698