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

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

Issue 10970009: Add list.removeAt method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated doc-comment. 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 | « runtime/lib/array.dart ('k') | tests/corelib/list_removeat_test.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) 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) {
12 E result = this[index];
13 Arrays.copy(this,
14 index + 1,
15 this,
16 index,
17 this.length - index - 1);
18 this.length = this.length - 1;
19 return result;
20 }
21
11 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { 22 void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
12 if (length < 0) { 23 if (length < 0) {
13 throw new IllegalArgumentException("negative length $length"); 24 throw new IllegalArgumentException("negative length $length");
14 } 25 }
15 Arrays.copy(from, startFrom, this, start, length); 26 Arrays.copy(from, startFrom, this, start, length);
16 } 27 }
17 28
18 void removeRange(int start, int length) { 29 void removeRange(int start, int length) {
19 if (length == 0) { 30 if (length == 0) {
20 return; 31 return;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 T next() { 238 T next() {
228 if (!hasNext()) { 239 if (!hasNext()) {
229 throw const NoMoreElementsException(); 240 throw const NoMoreElementsException();
230 } 241 }
231 return _array[_pos++]; 242 return _array[_pos++];
232 } 243 }
233 244
234 final GrowableObjectArray<T> _array; 245 final GrowableObjectArray<T> _array;
235 int _pos; 246 int _pos;
236 } 247 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | tests/corelib/list_removeat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698