| 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 static final int _classId = (new _ObjectArray(0))._cid; | 8 static final int _classId = (new _ObjectArray(0))._cid; |
| 9 | 9 |
| 10 factory _ObjectArray(length) native "ObjectArray_allocate"; | 10 factory _ObjectArray(length) native "ObjectArray_allocate"; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 int length = end - start; | 111 int length = end - start; |
| 112 if (start == end) return []; | 112 if (start == end) return []; |
| 113 List list = new _GrowableObjectArray<E>.withCapacity(length); | 113 List list = new _GrowableObjectArray<E>.withCapacity(length); |
| 114 list.length = length; | 114 list.length = length; |
| 115 Arrays.copy(this, start, list, 0, length); | 115 Arrays.copy(this, start, list, 0, length); |
| 116 return list; | 116 return list; |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Iterable interface. | 119 // Iterable interface. |
| 120 | 120 |
| 121 bool contains(E element) { | 121 bool contains(Object element) { |
| 122 return IterableMixinWorkaround.contains(this, element); | 122 return IterableMixinWorkaround.contains(this, element); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void forEach(f(E element)) { | 125 void forEach(f(E element)) { |
| 126 IterableMixinWorkaround.forEach(this, f); | 126 IterableMixinWorkaround.forEach(this, f); |
| 127 } | 127 } |
| 128 | 128 |
| 129 String join([String separator = ""]) { | 129 String join([String separator = ""]) { |
| 130 return IterableMixinWorkaround.joinList(this, separator); | 130 return IterableMixinWorkaround.joinList(this, separator); |
| 131 } | 131 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool get isNotEmpty => !isEmpty; | 197 bool get isNotEmpty => !isEmpty; |
| 198 | 198 |
| 199 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 199 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); |
| 200 | 200 |
| 201 void sort([int compare(E a, E b)]) { | 201 void sort([int compare(E a, E b)]) { |
| 202 IterableMixinWorkaround.sortList(this, compare); | 202 IterableMixinWorkaround.sortList(this, compare); |
| 203 } | 203 } |
| 204 | 204 |
| 205 int indexOf(E element, [int start = 0]) { | 205 int indexOf(Object element, [int start = 0]) { |
| 206 return Arrays.indexOf(this, element, start, this.length); | 206 return Arrays.indexOf(this, element, start, this.length); |
| 207 } | 207 } |
| 208 | 208 |
| 209 int lastIndexOf(E element, [int start = null]) { | 209 int lastIndexOf(Object element, [int start = null]) { |
| 210 if (start == null) start = length - 1; | 210 if (start == null) start = length - 1; |
| 211 return Arrays.lastIndexOf(this, element, start); | 211 return Arrays.lastIndexOf(this, element, start); |
| 212 } | 212 } |
| 213 | 213 |
| 214 Iterator<E> get iterator { | 214 Iterator<E> get iterator { |
| 215 return new _FixedSizeArrayIterator<E>(this); | 215 return new _FixedSizeArrayIterator<E>(this); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void add(E element) { | 218 void add(E element) { |
| 219 throw new UnsupportedError( | 219 throw new UnsupportedError( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 Arrays.copy(this, start, list, 0, length); | 364 Arrays.copy(this, start, list, 0, length); |
| 365 return list; | 365 return list; |
| 366 } | 366 } |
| 367 | 367 |
| 368 Iterable<E> getRange(int start, int end) { | 368 Iterable<E> getRange(int start, int end) { |
| 369 return IterableMixinWorkaround.getRangeList(this, start, end); | 369 return IterableMixinWorkaround.getRangeList(this, start, end); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // Collection interface. | 372 // Collection interface. |
| 373 | 373 |
| 374 bool contains(E element) { | 374 bool contains(Object element) { |
| 375 return IterableMixinWorkaround.contains(this, element); | 375 return IterableMixinWorkaround.contains(this, element); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void forEach(f(E element)) { | 378 void forEach(f(E element)) { |
| 379 IterableMixinWorkaround.forEach(this, f); | 379 IterableMixinWorkaround.forEach(this, f); |
| 380 } | 380 } |
| 381 | 381 |
| 382 Iterable map(f(E element)) { | 382 Iterable map(f(E element)) { |
| 383 return IterableMixinWorkaround.mapList(this, f); | 383 return IterableMixinWorkaround.mapList(this, f); |
| 384 } | 384 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 void sort([int compare(E a, E b)]) { | 454 void sort([int compare(E a, E b)]) { |
| 455 throw new UnsupportedError( | 455 throw new UnsupportedError( |
| 456 "Cannot modify an immutable array"); | 456 "Cannot modify an immutable array"); |
| 457 } | 457 } |
| 458 | 458 |
| 459 String toString() { | 459 String toString() { |
| 460 return ToString.iterableToString(this); | 460 return ToString.iterableToString(this); |
| 461 } | 461 } |
| 462 | 462 |
| 463 int indexOf(E element, [int start = 0]) { | 463 int indexOf(Object element, [int start = 0]) { |
| 464 return Arrays.indexOf(this, element, start, this.length); | 464 return Arrays.indexOf(this, element, start, this.length); |
| 465 } | 465 } |
| 466 | 466 |
| 467 int lastIndexOf(E element, [int start = null]) { | 467 int lastIndexOf(Object element, [int start = null]) { |
| 468 if (start == null) start = length - 1; | 468 if (start == null) start = length - 1; |
| 469 return Arrays.lastIndexOf(this, element, start); | 469 return Arrays.lastIndexOf(this, element, start); |
| 470 } | 470 } |
| 471 | 471 |
| 472 Iterator<E> get iterator { | 472 Iterator<E> get iterator { |
| 473 return new _FixedSizeArrayIterator<E>(this); | 473 return new _FixedSizeArrayIterator<E>(this); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void add(E element) { | 476 void add(E element) { |
| 477 throw new UnsupportedError( | 477 throw new UnsupportedError( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } | 549 } |
| 550 _position = _length; | 550 _position = _length; |
| 551 _current = null; | 551 _current = null; |
| 552 return false; | 552 return false; |
| 553 } | 553 } |
| 554 | 554 |
| 555 E get current { | 555 E get current { |
| 556 return _current; | 556 return _current; |
| 557 } | 557 } |
| 558 } | 558 } |
| OLD | NEW |