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

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

Issue 1999793002: Make Iterable.toList more efficient if the length is known. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Avoid iterator for empty list Created 4 years, 7 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
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 collection of values, or "elements", that can be accessed sequentially. 8 * A collection of values, or "elements", that can be accessed sequentially.
9 * 9 *
10 * The elements of the iterable are accessed by getting an [Iterator] 10 * The elements of the iterable are accessed by getting an [Iterator]
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 return false; 330 return false;
331 } 331 }
332 332
333 /** 333 /**
334 * Creates a [List] containing the elements of this [Iterable]. 334 * Creates a [List] containing the elements of this [Iterable].
335 * 335 *
336 * The elements are in iteration order. 336 * The elements are in iteration order.
337 * The list is fixed-length if [growable] is false. 337 * The list is fixed-length if [growable] is false.
338 */ 338 */
339 List<E> toList({ bool growable: true }) => 339 List<E> toList({bool growable: true}) {
340 new List<E>.from(this, growable: growable); 340 return new List<E>.from(this, growable: growable);
341 }
341 342
342 /** 343 /**
343 * Creates a [Set] containing the same elements as this iterable. 344 * Creates a [Set] containing the same elements as this iterable.
344 * 345 *
345 * The set may contain fewer elements than the iterable, 346 * The set may contain fewer elements than the iterable,
346 * if the iterable contains an element more than once, 347 * if the iterable contains an element more than once,
347 * or it contains one or more elements that are equal. 348 * or it contains one or more elements that are equal.
348 * The order of the elements in the set is not guaranteed to be the same 349 * The order of the elements in the set is not guaranteed to be the same
349 * as for the iterable. 350 * as for the iterable.
350 */ 351 */
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 */ 638 */
638 abstract class BidirectionalIterator<E> implements Iterator<E> { 639 abstract class BidirectionalIterator<E> implements Iterator<E> {
639 /** 640 /**
640 * Move back to the previous element. 641 * Move back to the previous element.
641 * 642 *
642 * Returns true and updates [current] if successful. Returns false 643 * Returns true and updates [current] if successful. Returns false
643 * and sets [current] to null if there is no previous element. 644 * and sets [current] to null if there is no previous element.
644 */ 645 */
645 bool movePrevious(); 646 bool movePrevious();
646 } 647 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698