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

Side by Side Diff: runtime/lib/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 | « lib/core/list.dart ('k') | 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) 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(int length) native "ObjectArray_allocate"; 9 factory ObjectArray(int length) native "ObjectArray_allocate";
10 10
11 E operator [](int index) native "ObjectArray_getIndexed"; 11 E operator [](int index) native "ObjectArray_getIndexed";
12 12
13 void operator []=(int index, E value) native "ObjectArray_setIndexed"; 13 void operator []=(int index, E value) native "ObjectArray_setIndexed";
14 14
15 String toString() { 15 String toString() {
16 return Collections.collectionToString(this); 16 return Collections.collectionToString(this);
17 } 17 }
18 18
19 int get length native "ObjectArray_getLength"; 19 int get length native "ObjectArray_getLength";
20 20
21 void _copyFromObjectArray(ObjectArray src, 21 void _copyFromObjectArray(ObjectArray src,
22 int srcStart, 22 int srcStart,
23 int dstStart, 23 int dstStart,
24 int count) 24 int count)
25 native "ObjectArray_copyFromObjectArray"; 25 native "ObjectArray_copyFromObjectArray";
26 26
27 E removeAt(int index) {
28 throw const UnsupportedOperationException(
29 "Cannot remove element of a non-extendable array");
30 }
31
27 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { 32 void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
28 if (length < 0) { 33 if (length < 0) {
29 throw new IllegalArgumentException("negative length $length"); 34 throw new IllegalArgumentException("negative length $length");
30 } 35 }
31 if (from is ObjectArray) { 36 if (from is ObjectArray) {
32 _copyFromObjectArray(from, startFrom, start, length); 37 _copyFromObjectArray(from, startFrom, start, length);
33 } else { 38 } else {
34 Arrays.copy(from, startFrom, this, start, length); 39 Arrays.copy(from, startFrom, this, start, length);
35 } 40 }
36 } 41 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 159
155 E operator [](int index) native "ObjectArray_getIndexed"; 160 E operator [](int index) native "ObjectArray_getIndexed";
156 161
157 void operator []=(int index, E value) { 162 void operator []=(int index, E value) {
158 throw const UnsupportedOperationException( 163 throw const UnsupportedOperationException(
159 "Cannot modify an immutable array"); 164 "Cannot modify an immutable array");
160 } 165 }
161 166
162 int get length native "ObjectArray_getLength"; 167 int get length native "ObjectArray_getLength";
163 168
169 E removeAt(int index) {
170 throw const UnsupportedOperationException(
171 "Cannot modify an immitable array");
172 }
173
164 void copyFrom(List src, int srcStart, int dstStart, int count) { 174 void copyFrom(List src, int srcStart, int dstStart, int count) {
165 throw const UnsupportedOperationException( 175 throw const UnsupportedOperationException(
166 "Cannot modify an immutable array"); 176 "Cannot modify an immutable array");
167 } 177 }
168 178
169 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { 179 void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
170 throw const UnsupportedOperationException( 180 throw const UnsupportedOperationException(
171 "Cannot modify an immutable array"); 181 "Cannot modify an immutable array");
172 } 182 }
173 183
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (!hasNext()) { 304 if (!hasNext()) {
295 throw const NoMoreElementsException(); 305 throw const NoMoreElementsException();
296 } 306 }
297 return _array[_pos++]; 307 return _array[_pos++];
298 } 308 }
299 309
300 final List<E> _array; 310 final List<E> _array;
301 final int _length; // Cache array length for faster access. 311 final int _length; // Cache array length for faster access.
302 int _pos; 312 int _pos;
303 } 313 }
OLDNEW
« no previous file with comments | « lib/core/list.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698