| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 E removeAt(int index) { | 270 E removeAt(int index) { |
| 282 throw new UnsupportedError( | 271 throw new UnsupportedError( |
| 283 "Cannot modify an immutable array"); | 272 "Cannot modify an immutable array"); |
| 284 } | 273 } |
| 285 | 274 |
| 286 void remove(Object element) { | 275 void remove(Object element) { |
| 287 throw new UnsupportedError( | 276 throw new UnsupportedError( |
| 288 "Cannot modify an immutable array"); | 277 "Cannot modify an immutable array"); |
| 289 } | 278 } |
| 290 | 279 |
| 291 void removeAll(Iterable elements) { | |
| 292 throw new UnsupportedError( | |
| 293 "Cannot modify an immutable array"); | |
| 294 } | |
| 295 | |
| 296 void retainAll(Iterable elements) { | |
| 297 throw new UnsupportedError( | |
| 298 "Cannot modify an immutable array"); | |
| 299 } | |
| 300 | |
| 301 void removeWhere(bool test(E element)) { | 280 void removeWhere(bool test(E element)) { |
| 302 throw new UnsupportedError( | 281 throw new UnsupportedError( |
| 303 "Cannot modify an immutable array"); | 282 "Cannot modify an immutable array"); |
| 304 } | 283 } |
| 305 | 284 |
| 306 void retainWhere(bool test(E element)) { | 285 void retainWhere(bool test(E element)) { |
| 307 throw new UnsupportedError( | 286 throw new UnsupportedError( |
| 308 "Cannot modify an immutable array"); | 287 "Cannot modify an immutable array"); |
| 309 } | 288 } |
| 310 | 289 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 401 } |
| 423 | 402 |
| 424 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 403 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); |
| 425 | 404 |
| 426 void sort([int compare(E a, E b)]) { | 405 void sort([int compare(E a, E b)]) { |
| 427 throw new UnsupportedError( | 406 throw new UnsupportedError( |
| 428 "Cannot modify an immutable array"); | 407 "Cannot modify an immutable array"); |
| 429 } | 408 } |
| 430 | 409 |
| 431 String toString() { | 410 String toString() { |
| 432 return Collections.collectionToString(this); | 411 return ToString.iterableToString(this); |
| 433 } | 412 } |
| 434 | 413 |
| 435 int indexOf(E element, [int start = 0]) { | 414 int indexOf(E element, [int start = 0]) { |
| 436 return Arrays.indexOf(this, element, start, this.length); | 415 return Arrays.indexOf(this, element, start, this.length); |
| 437 } | 416 } |
| 438 | 417 |
| 439 int lastIndexOf(E element, [int start = null]) { | 418 int lastIndexOf(E element, [int start = null]) { |
| 440 if (start == null) start = length - 1; | 419 if (start == null) start = length - 1; |
| 441 return Arrays.lastIndexOf(this, element, start); | 420 return Arrays.lastIndexOf(this, element, start); |
| 442 } | 421 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 500 } |
| 522 _position = _length; | 501 _position = _length; |
| 523 _current = null; | 502 _current = null; |
| 524 return false; | 503 return false; |
| 525 } | 504 } |
| 526 | 505 |
| 527 E get current { | 506 E get current { |
| 528 return _current; | 507 return _current; |
| 529 } | 508 } |
| 530 } | 509 } |
| OLD | NEW |