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

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

Issue 9027026: Implement toString for ImmutableArray and GrowableObjectArray (Issue 952) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years 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') | 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 class ListFactory<E> { 5 class ListFactory<E> {
6 6
7 factory List.from(Iterable<E> other) { 7 factory List.from(Iterable<E> other) {
8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>();
9 for (final e in other) { 9 for (final e in other) {
10 list.add(e); 10 list.add(e);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool isEmpty() { 227 bool isEmpty() {
228 return this.length === 0; 228 return this.length === 0;
229 } 229 }
230 230
231 void sort(int compare(E a, E b)) { 231 void sort(int compare(E a, E b)) {
232 throw const UnsupportedOperationException( 232 throw const UnsupportedOperationException(
233 "Cannot modify an immutable array"); 233 "Cannot modify an immutable array");
234 } 234 }
235 235
236 String toString() { 236 String toString() {
237 return "ImmutableArray"; 237 return Arrays.asString(this);
238 } 238 }
239 239
240 int indexOf(E element, [int start = 0]) { 240 int indexOf(E element, [int start = 0]) {
241 return Arrays.indexOf(this, element, start, this.length); 241 return Arrays.indexOf(this, element, start, this.length);
242 } 242 }
243 243
244 int lastIndexOf(E element, [int start = null]) { 244 int lastIndexOf(E element, [int start = null]) {
245 if (start === null) start = length - 1; 245 if (start === null) start = length - 1;
246 return Arrays.lastIndexOf(this, element, start); 246 return Arrays.lastIndexOf(this, element, start);
247 } 247 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 if (!hasNext()) { 300 if (!hasNext()) {
301 throw const NoMoreElementsException(); 301 throw const NoMoreElementsException();
302 } 302 }
303 return _array[_pos++]; 303 return _array[_pos++];
304 } 304 }
305 305
306 final List<E> _array; 306 final List<E> _array;
307 final int _length; // Cache array length for faster access. 307 final int _length; // Cache array length for faster access.
308 int _pos; 308 int _pos;
309 } 309 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698