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

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

Issue 18282008: Revert "Move toString() to collection classes." (Closed) Base URL: https://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 | « sdk/lib/collection/maps.dart ('k') | tests/corelib/list_to_string2_test.dart » ('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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 DoubleLinkedQueueEntry<E> nextEntry = entry._next; 294 DoubleLinkedQueueEntry<E> nextEntry = entry._next;
295 f(entry); 295 f(entry);
296 entry = nextEntry; 296 entry = nextEntry;
297 } 297 }
298 } 298 }
299 299
300 _DoubleLinkedQueueIterator<E> get iterator { 300 _DoubleLinkedQueueIterator<E> get iterator {
301 return new _DoubleLinkedQueueIterator<E>(_sentinel); 301 return new _DoubleLinkedQueueIterator<E>(_sentinel);
302 } 302 }
303 303
304 // TODO(zarah) Remove this, and let it be inherited by IterableBase 304 String toString() {
305 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}'); 305 return ToString.iterableToString(this);
306 }
306 } 307 }
307 308
308 class _DoubleLinkedQueueIterator<E> implements Iterator<E> { 309 class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
309 _DoubleLinkedQueueEntrySentinel<E> _sentinel; 310 _DoubleLinkedQueueEntrySentinel<E> _sentinel;
310 DoubleLinkedQueueEntry<E> _currentEntry = null; 311 DoubleLinkedQueueEntry<E> _currentEntry = null;
311 E _current; 312 E _current;
312 313
313 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel<E> sentinel) 314 _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel<E> sentinel)
314 : _sentinel = sentinel, _currentEntry = sentinel; 315 : _sentinel = sentinel, _currentEntry = sentinel;
315 316
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 void clear() { 523 void clear() {
523 if (_head != _tail) { 524 if (_head != _tail) {
524 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { 525 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) {
525 _table[i] = null; 526 _table[i] = null;
526 } 527 }
527 _head = _tail = 0; 528 _head = _tail = 0;
528 _modificationCount++; 529 _modificationCount++;
529 } 530 }
530 } 531 }
531 532
532 // TODO(zarah) Remove this, and let it be inherited by IterableBase 533 String toString() {
533 String toString() => IterableMixinWorkaround.toStringIterable(this, '{', '}'); 534 return ToString.iterableToString(this);
535 }
534 536
535 // Queue interface. 537 // Queue interface.
536 538
537 void addLast(E element) { _add(element); } 539 void addLast(E element) { _add(element); }
538 540
539 void addFirst(E element) { 541 void addFirst(E element) {
540 _head = (_head - 1) & (_table.length - 1); 542 _head = (_head - 1) & (_table.length - 1);
541 _table[_head] = element; 543 _table[_head] = element;
542 if (_head == _tail) _grow(); 544 if (_head == _tail) _grow();
543 _modificationCount++; 545 _modificationCount++;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 _queue._checkModification(_modificationCount); 701 _queue._checkModification(_modificationCount);
700 if (_position == _end) { 702 if (_position == _end) {
701 _current = null; 703 _current = null;
702 return false; 704 return false;
703 } 705 }
704 _current = _queue._table[_position]; 706 _current = _queue._table[_position];
705 _position = (_position + 1) & (_queue._table.length - 1); 707 _position = (_position + 1) & (_queue._table.length - 1);
706 return true; 708 return true;
707 } 709 }
708 } 710 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/maps.dart ('k') | tests/corelib/list_to_string2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698