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

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

Issue 10960011: Made removeAt errors consistent between dart2js and VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « lib/core/list.dart ('k') | tests/corelib/corelib.status » ('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) 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 factory GrowableObjectArray._uninstantiable() { 6 factory GrowableObjectArray._uninstantiable() {
7 throw const UnsupportedOperationException( 7 throw const UnsupportedOperationException(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
11 E removeAt(int index) { 11 T removeAt(int index) {
12 E result = this[index]; 12 if (index is! int) throw new IllegalArgumentException(index);
13 T result = this[index];
13 Arrays.copy(this, 14 Arrays.copy(this,
kasperl 2012/09/20 12:42:41 Cache this.length in a local variable?
Lasse Reichstein Nielsen 2012/09/20 12:52:30 Better yet, I'll cache this.length - 1.
14 index + 1, 15 index + 1,
15 this, 16 this,
16 index, 17 index,
17 this.length - index - 1); 18 this.length - index - 1);
18 this.length = this.length - 1; 19 this.length = this.length - 1;
19 return result; 20 return result;
20 } 21 }
21 22
22 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { 23 void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
23 if (length < 0) { 24 if (length < 0) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 T next() { 239 T next() {
239 if (!hasNext()) { 240 if (!hasNext()) {
240 throw const NoMoreElementsException(); 241 throw const NoMoreElementsException();
241 } 242 }
242 return _array[_pos++]; 243 return _array[_pos++];
243 } 244 }
244 245
245 final GrowableObjectArray<T> _array; 246 final GrowableObjectArray<T> _array;
246 int _pos; 247 int _pos;
247 } 248 }
OLDNEW
« no previous file with comments | « lib/core/list.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698