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

Side by Side Diff: sdk/lib/collection/queue.dart

Issue 19857010: Fix Queue's iterator to allocate an iterator using type parameter. Enable now passing tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.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.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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 queue._table.setRange(0, length, sourceList, 0); 380 queue._table.setRange(0, length, sourceList, 0);
381 queue._tail = length; 381 queue._tail = length;
382 return queue; 382 return queue;
383 } else { 383 } else {
384 return new ListQueue<E>()..addAll(source); 384 return new ListQueue<E>()..addAll(source);
385 } 385 }
386 } 386 }
387 387
388 // Iterable interface. 388 // Iterable interface.
389 389
390 Iterator<E> get iterator => new _ListQueueIterator(this); 390 Iterator<E> get iterator => new _ListQueueIterator<E>(this);
391 391
392 void forEach(void action (E element)) { 392 void forEach(void action (E element)) {
393 int modificationCount = _modificationCount; 393 int modificationCount = _modificationCount;
394 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { 394 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) {
395 action(_table[i]); 395 action(_table[i]);
396 _checkModification(modificationCount); 396 _checkModification(modificationCount);
397 } 397 }
398 } 398 }
399 399
400 bool get isEmpty => _head == _tail; 400 bool get isEmpty => _head == _tail;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 _queue._checkModification(_modificationCount); 699 _queue._checkModification(_modificationCount);
700 if (_position == _end) { 700 if (_position == _end) {
701 _current = null; 701 _current = null;
702 return false; 702 return false;
703 } 703 }
704 _current = _queue._table[_position]; 704 _current = _queue._table[_position];
705 _position = (_position + 1) & (_queue._table.length - 1); 705 _position = (_position + 1) & (_queue._table.length - 1);
706 return true; 706 return true;
707 } 707 }
708 } 708 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698