OLD | NEW |
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 |
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 ToString.iterableToString(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 void insert(int index, E element) { | 27 void insert(int index, E element) { |
28 throw new UnsupportedError( | 28 throw new UnsupportedError( |
29 "Cannot add to a non-extendable array"); | 29 "Cannot add to a non-extendable array"); |
30 } | 30 } |
31 | 31 |
32 E removeAt(int index) { | 32 E removeAt(int index) { |
33 throw new UnsupportedError( | 33 throw new UnsupportedError( |
34 "Cannot remove element of a non-extendable array"); | 34 "Cannot remove element of a non-extendable array"); |
35 } | 35 } |
36 | 36 |
37 void remove(Object element) { | 37 void remove(Object element) { |
38 throw new UnsupportedError( | 38 throw new UnsupportedError( |
39 "Cannot remove element of a non-extendable array"); | 39 "Cannot remove element of a non-extendable array"); |
40 } | 40 } |
41 | 41 |
42 // Collection interface. | |
43 void removeAll(Iterable elements) { | |
44 throw new UnsupportedError( | |
45 "Cannot remove element of a non-extendable array"); | |
46 } | |
47 | |
48 void retainAll(Iterable elements) { | |
49 throw new UnsupportedError( | |
50 "Cannot remove element of a non-extendable array"); | |
51 } | |
52 | |
53 void removeWhere(bool test(E element)) { | 42 void removeWhere(bool test(E element)) { |
54 throw new UnsupportedError( | 43 throw new UnsupportedError( |
55 "Cannot remove element of a non-extendable array"); | 44 "Cannot remove element of a non-extendable array"); |
56 } | 45 } |
57 | 46 |
58 void retainWhere(bool test(E element)) { | 47 void retainWhere(bool test(E element)) { |
59 throw new UnsupportedError( | 48 throw new UnsupportedError( |
60 "Cannot remove element of a non-extendable array"); | 49 "Cannot remove element of a non-extendable array"); |
61 } | 50 } |
62 | 51 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 E removeAt(int index) { | 268 E removeAt(int index) { |
280 throw new UnsupportedError( | 269 throw new UnsupportedError( |
281 "Cannot modify an immutable array"); | 270 "Cannot modify an immutable array"); |
282 } | 271 } |
283 | 272 |
284 void remove(Object element) { | 273 void remove(Object element) { |
285 throw new UnsupportedError( | 274 throw new UnsupportedError( |
286 "Cannot modify an immutable array"); | 275 "Cannot modify an immutable array"); |
287 } | 276 } |
288 | 277 |
289 void removeAll(Iterable elements) { | |
290 throw new UnsupportedError( | |
291 "Cannot modify an immutable array"); | |
292 } | |
293 | |
294 void retainAll(Iterable elements) { | |
295 throw new UnsupportedError( | |
296 "Cannot modify an immutable array"); | |
297 } | |
298 | |
299 void removeWhere(bool test(E element)) { | 278 void removeWhere(bool test(E element)) { |
300 throw new UnsupportedError( | 279 throw new UnsupportedError( |
301 "Cannot modify an immutable array"); | 280 "Cannot modify an immutable array"); |
302 } | 281 } |
303 | 282 |
304 void retainWhere(bool test(E element)) { | 283 void retainWhere(bool test(E element)) { |
305 throw new UnsupportedError( | 284 throw new UnsupportedError( |
306 "Cannot modify an immutable array"); | 285 "Cannot modify an immutable array"); |
307 } | 286 } |
308 | 287 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 397 } |
419 | 398 |
420 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 399 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); |
421 | 400 |
422 void sort([int compare(E a, E b)]) { | 401 void sort([int compare(E a, E b)]) { |
423 throw new UnsupportedError( | 402 throw new UnsupportedError( |
424 "Cannot modify an immutable array"); | 403 "Cannot modify an immutable array"); |
425 } | 404 } |
426 | 405 |
427 String toString() { | 406 String toString() { |
428 return Collections.collectionToString(this); | 407 return ToString.iterableToString(this); |
429 } | 408 } |
430 | 409 |
431 int indexOf(E element, [int start = 0]) { | 410 int indexOf(E element, [int start = 0]) { |
432 return Arrays.indexOf(this, element, start, this.length); | 411 return Arrays.indexOf(this, element, start, this.length); |
433 } | 412 } |
434 | 413 |
435 int lastIndexOf(E element, [int start = null]) { | 414 int lastIndexOf(E element, [int start = null]) { |
436 if (start == null) start = length - 1; | 415 if (start == null) start = length - 1; |
437 return Arrays.lastIndexOf(this, element, start); | 416 return Arrays.lastIndexOf(this, element, start); |
438 } | 417 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 496 } |
518 _position = _length; | 497 _position = _length; |
519 _current = null; | 498 _current = null; |
520 return false; | 499 return false; |
521 } | 500 } |
522 | 501 |
523 E get current { | 502 E get current { |
524 return _current; | 503 return _current; |
525 } | 504 } |
526 } | 505 } |
OLD | NEW |