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

Side by Side Diff: sdk/lib/collection/queue.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; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * A [Queue] is a collection that can be manipulated at both ends. One 8 * A [Queue] is a collection that can be manipulated at both ends. One
9 * can iterate over the elements of a queue through [forEach] or with 9 * can iterate over the elements of a queue through [forEach] or with
10 * an [Iterator]. 10 * an [Iterator].
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return _table[_head]; 402 return _table[_head];
403 } 403 }
404 404
405 E elementAt(int index) { 405 E elementAt(int index) {
406 if (index < 0 || index > length) { 406 if (index < 0 || index > length) {
407 throw new RangeError.range(index, 0, length); 407 throw new RangeError.range(index, 0, length);
408 } 408 }
409 return _table[(_head + index) & (_table.length - 1)]; 409 return _table[(_head + index) & (_table.length - 1)];
410 } 410 }
411 411
412 List<E> toList({ bool growable: false }) { 412 List<E> toList({ bool growable: true }) {
413 List<E> list; 413 List<E> list;
414 if (growable) { 414 if (growable) {
415 list = new List<E>()..length = length; 415 list = new List<E>()..length = length;
416 } else { 416 } else {
417 list = new List<E>(length); 417 list = new List<E>(length);
418 } 418 }
419 _writeToList(list); 419 _writeToList(list);
420 return list; 420 return list;
421 } 421 }
422 422
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 _queue._checkModification(_modificationCount); 692 _queue._checkModification(_modificationCount);
693 if (_position == _end) { 693 if (_position == _end) {
694 _current = null; 694 _current = null;
695 return false; 695 return false;
696 } 696 }
697 _current = _queue._table[_position]; 697 _current = _queue._table[_position];
698 _position = (_position + 1) & (_queue._table.length - 1); 698 _position = (_position + 1) & (_queue._table.length - 1);
699 return true; 699 return true;
700 } 700 }
701 } 701 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/util/link_implementation.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698