| 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void removeAll(Iterable elements) { | 38 void removeAll(Iterable elements) { |
| 39 throw new UnsupportedError( | 39 throw new UnsupportedError( |
| 40 "Cannot remove element of a non-extendable array"); | 40 "Cannot remove element of a non-extendable array"); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void retainAll(Iterable elements) { | 43 void retainAll(Iterable elements) { |
| 44 throw new UnsupportedError( | 44 throw new UnsupportedError( |
| 45 "Cannot remove element of a non-extendable array"); | 45 "Cannot remove element of a non-extendable array"); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void removeMatching(bool test(E element)) { | 48 void removeWhere(bool test(E element)) { |
| 49 throw new UnsupportedError( | 49 throw new UnsupportedError( |
| 50 "Cannot remove element of a non-extendable array"); | 50 "Cannot remove element of a non-extendable array"); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void retainMatching(bool test(E element)) { | 53 void retainWhere(bool test(E element)) { |
| 54 throw new UnsupportedError( | 54 throw new UnsupportedError( |
| 55 "Cannot remove element of a non-extendable array"); | 55 "Cannot remove element of a non-extendable array"); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // List interface. | 58 // List interface. |
| 59 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 59 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
| 60 if (length < 0) { | 60 if (length < 0) { |
| 61 throw new ArgumentError("negative length $length"); | 61 throw new ArgumentError("negative length $length"); |
| 62 } | 62 } |
| 63 if (from is _ObjectArray) { | 63 if (from is _ObjectArray) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool every(bool f(E element)) { | 135 bool every(bool f(E element)) { |
| 136 return IterableMixinWorkaround.every(this, f); | 136 return IterableMixinWorkaround.every(this, f); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool any(bool f(E element)) { | 139 bool any(bool f(E element)) { |
| 140 return IterableMixinWorkaround.any(this, f); | 140 return IterableMixinWorkaround.any(this, f); |
| 141 } | 141 } |
| 142 | 142 |
| 143 E firstMatching(bool test(E value), {E orElse()}) { | 143 E firstWhere(bool test(E value), {E orElse()}) { |
| 144 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 144 return IterableMixinWorkaround.firstWhere(this, test, orElse); |
| 145 } | 145 } |
| 146 | 146 |
| 147 E lastMatching(bool test(E value), {E orElse()}) { | 147 E lastWhere(bool test(E value), {E orElse()}) { |
| 148 return IterableMixinWorkaround.lastMatchingInList(this, test, orElse); | 148 return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
| 149 } | 149 } |
| 150 | 150 |
| 151 E singleMatching(bool test(E value)) { | 151 E singleWhere(bool test(E value)) { |
| 152 return IterableMixinWorkaround.singleMatching(this, test); | 152 return IterableMixinWorkaround.singleWhere(this, test); |
| 153 } | 153 } |
| 154 | 154 |
| 155 E elementAt(int index) { | 155 E elementAt(int index) { |
| 156 return this[index]; | 156 return this[index]; |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool get isEmpty { | 159 bool get isEmpty { |
| 160 return this.length == 0; | 160 return this.length == 0; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void removeAll(Iterable elements) { | 278 void removeAll(Iterable elements) { |
| 279 throw new UnsupportedError( | 279 throw new UnsupportedError( |
| 280 "Cannot modify an immutable array"); | 280 "Cannot modify an immutable array"); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void retainAll(Iterable elements) { | 283 void retainAll(Iterable elements) { |
| 284 throw new UnsupportedError( | 284 throw new UnsupportedError( |
| 285 "Cannot modify an immutable array"); | 285 "Cannot modify an immutable array"); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void removeMatching(bool test(E element)) { | 288 void removeWhere(bool test(E element)) { |
| 289 throw new UnsupportedError( | 289 throw new UnsupportedError( |
| 290 "Cannot modify an immutable array"); | 290 "Cannot modify an immutable array"); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void retainMatching(bool test(E element)) { | 293 void retainWhere(bool test(E element)) { |
| 294 throw new UnsupportedError( | 294 throw new UnsupportedError( |
| 295 "Cannot modify an immutable array"); | 295 "Cannot modify an immutable array"); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void copyFrom(List src, int srcStart, int dstStart, int count) { | 298 void copyFrom(List src, int srcStart, int dstStart, int count) { |
| 299 throw new UnsupportedError( | 299 throw new UnsupportedError( |
| 300 "Cannot modify an immutable array"); | 300 "Cannot modify an immutable array"); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 303 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool every(bool f(E element)) { | 373 bool every(bool f(E element)) { |
| 374 return IterableMixinWorkaround.every(this, f); | 374 return IterableMixinWorkaround.every(this, f); |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool any(bool f(E element)) { | 377 bool any(bool f(E element)) { |
| 378 return IterableMixinWorkaround.any(this, f); | 378 return IterableMixinWorkaround.any(this, f); |
| 379 } | 379 } |
| 380 | 380 |
| 381 E firstMatching(bool test(E value), {E orElse()}) { | 381 E firstWhere(bool test(E value), {E orElse()}) { |
| 382 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 382 return IterableMixinWorkaround.firstWhere(this, test, orElse); |
| 383 } | 383 } |
| 384 | 384 |
| 385 E lastMatching(bool test(E value), {E orElse()}) { | 385 E lastWhere(bool test(E value), {E orElse()}) { |
| 386 return IterableMixinWorkaround.lastMatchingInList(this, test, orElse); | 386 return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
| 387 } | 387 } |
| 388 | 388 |
| 389 E singleMatching(bool test(E value)) { | 389 E singleWhere(bool test(E value)) { |
| 390 return IterableMixinWorkaround.singleMatching(this, test); | 390 return IterableMixinWorkaround.singleWhere(this, test); |
| 391 } | 391 } |
| 392 | 392 |
| 393 E elementAt(int index) { | 393 E elementAt(int index) { |
| 394 return this[index]; | 394 return this[index]; |
| 395 } | 395 } |
| 396 | 396 |
| 397 bool get isEmpty { | 397 bool get isEmpty { |
| 398 return this.length == 0; | 398 return this.length == 0; |
| 399 } | 399 } |
| 400 | 400 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 506 } |
| 507 _position = _length; | 507 _position = _length; |
| 508 _current = null; | 508 _current = null; |
| 509 return false; | 509 return false; |
| 510 } | 510 } |
| 511 | 511 |
| 512 E get current { | 512 E get current { |
| 513 return _current; | 513 return _current; |
| 514 } | 514 } |
| 515 } | 515 } |
| OLD | NEW |