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

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

Issue 12401002: Make List.from and Iterable.toList default to not growable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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) 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._collection.dev; 5 part of dart._collection.dev;
6 6
7 /** 7 /**
8 * An [Iterable] for classes that have efficient [length] and [elementAt]. 8 * An [Iterable] for classes that have efficient [length] and [elementAt].
9 * 9 *
10 * All other methods are implemented in terms of [length] and [elementAt], 10 * All other methods are implemented in terms of [length] and [elementAt],
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 Iterable<E> skip(int count) => new SubListIterable(this, count, null); 214 Iterable<E> skip(int count) => new SubListIterable(this, count, null);
215 215
216 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test); 216 Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test);
217 217
218 Iterable<E> take(int count) => new SubListIterable(this, 0, count); 218 Iterable<E> take(int count) => new SubListIterable(this, 0, count);
219 219
220 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test); 220 Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test);
221 221
222 List<E> toList({ bool growable: false }) { 222 List<E> toList({ bool growable: true }) {
223 List<E> result; 223 List<E> result;
224 if (growable) { 224 if (growable) {
225 result = new List<E>()..length = length; 225 result = new List<E>()..length = length;
226 } else { 226 } else {
227 result = new List<E>(length); 227 result = new List<E>(length);
228 } 228 }
229 for (int i = 0; i < length; i++) { 229 for (int i = 0; i < length; i++) {
230 result[i] = elementAt(i); 230 result[i] = elementAt(i);
231 } 231 }
232 return result; 232 return result;
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 674 }
675 675
676 Iterable<E> skip(int count) => this; 676 Iterable<E> skip(int count) => this;
677 677
678 Iterable<E> skipWhile(bool test(E element)) => this; 678 Iterable<E> skipWhile(bool test(E element)) => this;
679 679
680 Iterable<E> take(int count) => this; 680 Iterable<E> take(int count) => this;
681 681
682 Iterable<E> takeWhile(bool test(E element)) => this; 682 Iterable<E> takeWhile(bool test(E element)) => this;
683 683
684 List toList({ bool growable: false }) => growable ? <E>[] : new List<E>(0); 684 List toList({ bool growable: true }) => growable ? <E>[] : new List<E>(0);
685 685
686 Set toSet() => new Set<E>(); 686 Set toSet() => new Set<E>();
687 } 687 }
688 688
689 /** The always empty iterator. */ 689 /** The always empty iterator. */
690 class EmptyIterator<E> implements Iterator<E> { 690 class EmptyIterator<E> implements Iterator<E> {
691 const EmptyIterator(); 691 const EmptyIterator();
692 bool moveNext() => false; 692 bool moveNext() => false;
693 E get current => null; 693 E get current => null;
694 } 694 }
695 695
696 /** An [Iterator] that can move in both directions. */ 696 /** An [Iterator] that can move in both directions. */
697 abstract class BidirectionalIterator<T> implements Iterator<T> { 697 abstract class BidirectionalIterator<T> implements Iterator<T> {
698 bool movePrevious(); 698 bool movePrevious();
699 } 699 }
OLDNEW
« no previous file with comments | « samples/third_party/dromaeo/Suites.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698