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

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

Issue 26695002: Growable typed data buffers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 * Abstract implementation of a list. 8 * Abstract implementation of a list.
9 * 9 *
10 * All operations are defined in terms of `length`, `operator[]`, 10 * All operations are defined in terms of `length`, `operator[]`,
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 setRange(index, this.length - 1, this, index + 1); 455 setRange(index, this.length - 1, this, index + 1);
456 length--; 456 length--;
457 return result; 457 return result;
458 } 458 }
459 459
460 void insertAll(int index, Iterable<E> iterable) { 460 void insertAll(int index, Iterable<E> iterable) {
461 if (index < 0 || index > length) { 461 if (index < 0 || index > length) {
462 throw new RangeError.range(index, 0, length); 462 throw new RangeError.range(index, 0, length);
463 } 463 }
464 // TODO(floitsch): we can probably detect more cases. 464 // TODO(floitsch): we can probably detect more cases.
465 // TODO(lrn): How about having a marker interface that promises that length
floitsch 2013/10/15 15:28:05 That should be done now.
466 // is efficient? List implements EfficientLength.
465 if (iterable is! List && iterable is! Set && iterable is! SubListIterable) { 467 if (iterable is! List && iterable is! Set && iterable is! SubListIterable) {
466 iterable = iterable.toList(); 468 iterable = iterable.toList();
467 } 469 }
468 int insertionLength = iterable.length; 470 int insertionLength = iterable.length;
469 // There might be errors after the length change, in which case the list 471 // There might be errors after the length change, in which case the list
470 // will end up being modified but the operation not complete. Unless we 472 // will end up being modified but the operation not complete. Unless we
471 // always go through a "toList" we can't really avoid that. 473 // always go through a "toList" we can't really avoid that.
472 this.length += insertionLength; 474 this.length += insertionLength;
473 setRange(index + insertionLength, this.length, this, index); 475 setRange(index + insertionLength, this.length, this, index);
474 setAll(index, iterable); 476 setAll(index, iterable);
(...skipping 23 matching lines...) Expand all
498 result.writeAll(this, ', '); 500 result.writeAll(this, ', ');
499 result.write(']'); 501 result.write(']');
500 } finally { 502 } finally {
501 assert(identical(_toStringList.last, this)); 503 assert(identical(_toStringList.last, this));
502 _toStringList.removeLast(); 504 _toStringList.removeLast();
503 } 505 }
504 506
505 return result.toString(); 507 return result.toString();
506 } 508 }
507 } 509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698