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

Side by Side Diff: runtime/lib/array.dart

Issue 18837002: Move toString() to collection classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. 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 | runtime/lib/growable_array.dart » ('j') | runtime/lib/growable_array.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5
6 // TODO(srdjan): Use shared array implementation. 6 // TODO(srdjan): Use shared array implementation.
7 class _ObjectArray<E> implements List<E> { 7 class _ObjectArray<E> implements List<E> {
8 static final int _classId = (new _ObjectArray(0))._cid; 8 static final int _classId = (new _ObjectArray(0))._cid;
9 9
10 factory _ObjectArray(length) native "ObjectArray_allocate"; 10 factory _ObjectArray(length) native "ObjectArray_allocate";
11 11
12 E operator [](int index) native "ObjectArray_getIndexed"; 12 E operator [](int index) native "ObjectArray_getIndexed";
13 13
14 void operator []=(int index, E value) native "ObjectArray_setIndexed"; 14 void operator []=(int index, E value) native "ObjectArray_setIndexed";
15 15
16 String toString() { 16 String toString() => IterableMixinWorkaround.toStringList(this);
floitsch 2013/07/08 16:12:34 VM devs prefer not to use "=>".
zarah 2013/07/08 16:57:46 Done.
17 return ToString.iterableToString(this); 17
18 }
19
20 int get length native "ObjectArray_getLength"; 18 int get length native "ObjectArray_getLength";
21 19
22 void _copyFromObjectArray(_ObjectArray src, 20 void _copyFromObjectArray(_ObjectArray src,
23 int srcStart, 21 int srcStart,
24 int dstStart, 22 int dstStart,
25 int count) 23 int count)
26 native "ObjectArray_copyFromObjectArray"; 24 native "ObjectArray_copyFromObjectArray";
27 25
28 void insert(int index, E element) { 26 void insert(int index, E element) {
29 throw new UnsupportedError( 27 throw new UnsupportedError(
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 447
450 bool get isNotEmpty => !isEmpty; 448 bool get isNotEmpty => !isEmpty;
451 449
452 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); 450 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this);
453 451
454 void sort([int compare(E a, E b)]) { 452 void sort([int compare(E a, E b)]) {
455 throw new UnsupportedError( 453 throw new UnsupportedError(
456 "Cannot modify an immutable array"); 454 "Cannot modify an immutable array");
457 } 455 }
458 456
459 String toString() { 457 String toString() => IterableMixinWorkaround.toStringList(this);
floitsch 2013/07/08 16:12:34 ditto.
zarah 2013/07/08 16:57:46 Done.
460 return ToString.iterableToString(this);
461 }
462 458
463 int indexOf(Object element, [int start = 0]) { 459 int indexOf(Object element, [int start = 0]) {
464 return Arrays.indexOf(this, element, start, this.length); 460 return Arrays.indexOf(this, element, start, this.length);
465 } 461 }
466 462
467 int lastIndexOf(Object element, [int start = null]) { 463 int lastIndexOf(Object element, [int start = null]) {
468 if (start == null) start = length - 1; 464 if (start == null) start = length - 1;
469 return Arrays.lastIndexOf(this, element, start); 465 return Arrays.lastIndexOf(this, element, start);
470 } 466 }
471 467
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 545 }
550 _position = _length; 546 _position = _length;
551 _current = null; 547 _current = null;
552 return false; 548 return false;
553 } 549 }
554 550
555 E get current { 551 E get current {
556 return _current; 552 return _current;
557 } 553 }
558 } 554 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/growable_array.dart » ('j') | runtime/lib/growable_array.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698