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

Unified Diff: sdk/lib/collection/queue.dart

Issue 18837002: 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/collection/queue.dart
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index 7bc65cab6fe5a63e7da2e3ae1881d748b6025f0d..1236045fae9c5209bf465db4d750776b01495272 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -79,6 +79,7 @@ abstract class Queue<E> implements Iterable<E> {
* at some point in the near future.
*/
class DoubleLinkedQueueEntry<E> {
+
DoubleLinkedQueueEntry<E> _previous;
DoubleLinkedQueueEntry<E> _next;
E _element;
@@ -170,6 +171,7 @@ class _DoubleLinkedQueueEntrySentinel<E> extends DoubleLinkedQueueEntry<E> {
* Can do [removeAll] and [retainAll] in linear time.
*/
class DoubleLinkedQueue<E> extends IterableBase<E> implements Queue<E> {
+ static List _toStringList = new List();
_DoubleLinkedQueueEntrySentinel<E> _sentinel;
int _elementCount = 0;
@@ -300,9 +302,16 @@ class DoubleLinkedQueue<E> extends IterableBase<E> implements Queue<E> {
_DoubleLinkedQueueIterator<E> get iterator {
return new _DoubleLinkedQueueIterator<E>(_sentinel);
}
-
+
String toString() {
- return ToString.iterableToString(this);
+ for(int i = 0; i < _toStringList.length; i++) {
floitsch 2013/07/08 12:00:50 Redirect to IterableMixinWorkaround for now. Add T
zarah 2013/07/08 14:35:15 Done.
+ if(identical(_toStringList[i], this))
+ return '{...}';
+ }
+ _toStringList.add(this);
+ String result = IterableMixinWorkaround.toStringIterable(this);
+ _toStringList.remove(this);
+ return result;
}
}
@@ -348,6 +357,7 @@ class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
*/
class ListQueue<E> extends IterableBase<E> implements Queue<E> {
static const int _INITIAL_CAPACITY = 8;
+ static List _toStringList = new List();
List<E> _table;
int _head;
int _tail;
@@ -531,7 +541,14 @@ class ListQueue<E> extends IterableBase<E> implements Queue<E> {
}
String toString() {
floitsch 2013/07/08 12:00:50 ditto.
zarah 2013/07/08 14:35:15 Done.
- return ToString.iterableToString(this);
+ for(int i = 0; i < _toStringList.length; i++) {
+ if(identical(_toStringList[i], this))
+ return '{...}';
+ }
+ _toStringList.add(this);
+ String result = IterableMixinWorkaround.toStringIterable(this);
+ _toStringList.remove(this);
+ return result;
}
// Queue interface.
@@ -683,6 +700,7 @@ class ListQueue<E> extends IterableBase<E> implements Queue<E> {
* Considers any add or remove operation a concurrent modification.
*/
class _ListQueueIterator<E> implements Iterator<E> {
+
final ListQueue _queue;
final int _end;
final int _modificationCount;

Powered by Google App Engine
This is Rietveld 408576698