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

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

Issue 292323006: Remove uses of IterableMixinWorkaround outside of VM and dart2js lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 DoubleLinkedQueueEntry<E> nextEntry = entry._next; 310 DoubleLinkedQueueEntry<E> nextEntry = entry._next;
311 f(entry); 311 f(entry);
312 entry = nextEntry; 312 entry = nextEntry;
313 } 313 }
314 } 314 }
315 315
316 _DoubleLinkedQueueIterator<E> get iterator { 316 _DoubleLinkedQueueIterator<E> get iterator {
317 return new _DoubleLinkedQueueIterator<E>(_sentinel); 317 return new _DoubleLinkedQueueIterator<E>(_sentinel);
318 } 318 }
319 319
320 // TODO(zarah) Remove this, and let it be inherited by IterableBase 320 String toString() => _collectionToString(this, '{', '}');
321 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}');
322 } 321 }
323 322
324 class _DoubleLinkedQueueIterator<E> implements Iterator<E> { 323 class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
325 _DoubleLinkedQueueEntrySentinel<E> _sentinel; 324 _DoubleLinkedQueueEntrySentinel<E> _sentinel;
326 DoubleLinkedQueueEntry<E> _nextEntry = null; 325 DoubleLinkedQueueEntry<E> _nextEntry = null;
327 E _current; 326 E _current;
328 327
329 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel<E> sentinel) 328 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel<E> sentinel)
330 : _sentinel = sentinel, _nextEntry = sentinel._next; 329 : _sentinel = sentinel, _nextEntry = sentinel._next;
331 330
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 void clear() { 529 void clear() {
531 if (_head != _tail) { 530 if (_head != _tail) {
532 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { 531 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) {
533 _table[i] = null; 532 _table[i] = null;
534 } 533 }
535 _head = _tail = 0; 534 _head = _tail = 0;
536 _modificationCount++; 535 _modificationCount++;
537 } 536 }
538 } 537 }
539 538
540 // TODO(zarah) Remove this, and let it be inherited by IterableBase 539 String toString() => _collectionToString(this, '{', '}');
541 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}');
542 540
543 // Queue interface. 541 // Queue interface.
544 542
545 void addLast(E element) { _add(element); } 543 void addLast(E element) { _add(element); }
546 544
547 void addFirst(E element) { 545 void addFirst(E element) {
548 _head = (_head - 1) & (_table.length - 1); 546 _head = (_head - 1) & (_table.length - 1);
549 _table[_head] = element; 547 _table[_head] = element;
550 if (_head == _tail) _grow(); 548 if (_head == _tail) _grow();
551 _modificationCount++; 549 _modificationCount++;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 _queue._checkModification(_modificationCount); 708 _queue._checkModification(_modificationCount);
711 if (_position == _end) { 709 if (_position == _end) {
712 _current = null; 710 _current = null;
713 return false; 711 return false;
714 } 712 }
715 _current = _queue._table[_position]; 713 _current = _queue._table[_position];
716 _position = (_position + 1) & (_queue._table.length - 1); 714 _position = (_position + 1) & (_queue._table.length - 1);
717 return true; 715 return true;
718 } 716 }
719 } 717 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698