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

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

Issue 13863012: Refactor List.setRange function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 7 years, 8 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 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 8
9 factory _ObjectArray(length) native "ObjectArray_allocate"; 9 factory _ObjectArray(length) native "ObjectArray_allocate";
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void retainWhere(bool test(E element)) { 58 void retainWhere(bool test(E element)) {
59 throw new UnsupportedError( 59 throw new UnsupportedError(
60 "Cannot remove element of a non-extendable array"); 60 "Cannot remove element of a non-extendable array");
61 } 61 }
62 62
63 Iterable<E> getRange(int start, [int end]) { 63 Iterable<E> getRange(int start, [int end]) {
64 return IterableMixinWorkaround.getRangeList(this, start, end); 64 return IterableMixinWorkaround.getRangeList(this, start, end);
65 } 65 }
66 66
67 // List interface. 67 // List interface.
68 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { 68 void setRange(int start, int end, List<E> from, [int startFrom = 0]) {
69 if (length < 0) { 69 if (start < 0 || start > this.length) {
70 throw new ArgumentError("negative length $length"); 70 throw new RangeError.range(start, 0, this.length);
71 } 71 }
72 if (end < 0 || end > this.length) {
73 throw new RangeError.range(end, start, this.length);
74 }
75 int length = end - start;
72 if (from is _ObjectArray) { 76 if (from is _ObjectArray) {
73 _copyFromObjectArray(from, startFrom, start, length); 77 _copyFromObjectArray(from, startFrom, start, length);
74 } else { 78 } else {
75 Arrays.copy(from, startFrom, this, start, length); 79 Arrays.copy(from, startFrom, this, start, length);
76 } 80 }
77 } 81 }
78 82
79 void removeRange(int start, int length) { 83 void removeRange(int start, int length) {
80 throw new UnsupportedError( 84 throw new UnsupportedError(
81 "Cannot remove range of a non-extendable array"); 85 "Cannot remove range of a non-extendable array");
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 void retainWhere(bool test(E element)) { 314 void retainWhere(bool test(E element)) {
311 throw new UnsupportedError( 315 throw new UnsupportedError(
312 "Cannot modify an immutable array"); 316 "Cannot modify an immutable array");
313 } 317 }
314 318
315 void copyFrom(List src, int srcStart, int dstStart, int count) { 319 void copyFrom(List src, int srcStart, int dstStart, int count) {
316 throw new UnsupportedError( 320 throw new UnsupportedError(
317 "Cannot modify an immutable array"); 321 "Cannot modify an immutable array");
318 } 322 }
319 323
320 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { 324 void setRange(int start, int end, List<E> from, [int startFrom = 0]) {
321 throw new UnsupportedError( 325 throw new UnsupportedError(
322 "Cannot modify an immutable array"); 326 "Cannot modify an immutable array");
323 } 327 }
324 328
325 void removeRange(int start, int length) { 329 void removeRange(int start, int length) {
326 throw new UnsupportedError( 330 throw new UnsupportedError(
327 "Cannot remove range of an immutable array"); 331 "Cannot remove range of an immutable array");
328 } 332 }
329 333
330 void insertRange(int start, int length, [E initialValue = null]) { 334 void insertRange(int start, int length, [E initialValue = null]) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 533 }
530 _position = _length; 534 _position = _length;
531 _current = null; 535 _current = null;
532 return false; 536 return false;
533 } 537 }
534 538
535 E get current { 539 E get current {
536 return _current; 540 return _current;
537 } 541 }
538 } 542 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698