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

Side by Side Diff: runtime/lib/growable_array.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _GrowableObjectArray<T> implements List<T> { 5 class _GrowableObjectArray<T> implements List<T> {
6 static final int _classId = (new _GrowableObjectArray(0))._cid; 6 static final int _classId = (new _GrowableObjectArray(0))._cid;
7 static List _toStringList = new List();
7 8
8 void insert(int index, T element) { 9 void insert(int index, T element) {
9 if (index < 0 || index > length) { 10 if (index < 0 || index > length) {
10 throw new RangeError.range(index, 0, length); 11 throw new RangeError.range(index, 0, length);
11 } 12 }
12 if (index == this.length) { 13 if (index == this.length) {
13 add(element); 14 add(element);
14 return; 15 return;
15 } 16 }
16 int oldLength = this.length; 17 int oldLength = this.length;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 this.length = 0; 331 this.length = 0;
331 } 332 }
332 333
333 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); 334 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this);
334 335
335 void sort([int compare(T a, T b)]) { 336 void sort([int compare(T a, T b)]) {
336 IterableMixinWorkaround.sortList(this, compare); 337 IterableMixinWorkaround.sortList(this, compare);
337 } 338 }
338 339
339 String toString() { 340 String toString() {
340 return ToString.iterableToString(this); 341 for(int i = 0; i < _toStringList.length; i++) {
floitsch 2013/07/08 12:00:50 change to IterableMixinWorkaround.toStringList(thi
zarah 2013/07/08 14:35:15 Done.
342 if(identical(_toStringList[i], this))
343 return '[...]';
344 }
345 _toStringList.add(this);
346 String result = IterableMixinWorkaround.toStringList(this);
347 _toStringList.remove(this);
348 return result;
341 } 349 }
342 350
343 Iterator<T> get iterator { 351 Iterator<T> get iterator {
344 return new ListIterator<T>(this); 352 return new ListIterator<T>(this);
345 } 353 }
346 354
347 List<T> toList({ bool growable: true }) { 355 List<T> toList({ bool growable: true }) {
348 return new List<T>.from(this, growable: growable); 356 return new List<T>.from(this, growable: growable);
349 } 357 }
350 358
351 Set<T> toSet() { 359 Set<T> toSet() {
352 return new Set<T>.from(this); 360 return new Set<T>.from(this);
353 } 361 }
354 362
355 Map<int, T> asMap() { 363 Map<int, T> asMap() {
356 return IterableMixinWorkaround.asMapList(this); 364 return IterableMixinWorkaround.asMapList(this);
357 } 365 }
358 } 366 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698