| 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(int length) native "ObjectArray_allocate"; | 9 factory _ObjectArray(int length) native "ObjectArray_allocate"; |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 String join([String separator]) { | 99 String join([String separator]) { |
| 100 return IterableMixinWorkaround.joinList(this, separator); | 100 return IterableMixinWorkaround.joinList(this, separator); |
| 101 } | 101 } |
| 102 | 102 |
| 103 Iterable map(f(E element)) { | 103 Iterable map(f(E element)) { |
| 104 return IterableMixinWorkaround.mapList(this, f); | 104 return IterableMixinWorkaround.mapList(this, f); |
| 105 } | 105 } |
| 106 | 106 |
| 107 List mappedBy(f(E element)) { |
| 108 IterableMixinWorkaround.mappedByList(this, f); |
| 109 } |
| 110 |
| 107 reduce(initialValue, combine(previousValue, E element)) { | 111 reduce(initialValue, combine(previousValue, E element)) { |
| 108 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 112 return IterableMixinWorkaround.reduce(this, initialValue, combine); |
| 109 } | 113 } |
| 110 | 114 |
| 111 Iterable<E> where(bool f(E element)) { | 115 Iterable<E> where(bool f(E element)) { |
| 112 return IterableMixinWorkaround.where(this, f); | 116 return IterableMixinWorkaround.where(this, f); |
| 113 } | 117 } |
| 114 | 118 |
| 115 Iterable expand(Iterable f(E element)) { | 119 Iterable expand(Iterable f(E element)) { |
| 116 return IterableMixinWorkaround.expand(this, f); | 120 return IterableMixinWorkaround.expand(this, f); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 157 } |
| 154 | 158 |
| 155 E elementAt(int index) { | 159 E elementAt(int index) { |
| 156 return this[index]; | 160 return this[index]; |
| 157 } | 161 } |
| 158 | 162 |
| 159 bool get isEmpty { | 163 bool get isEmpty { |
| 160 return this.length == 0; | 164 return this.length == 0; |
| 161 } | 165 } |
| 162 | 166 |
| 163 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 167 List<E> get reversed => new ReversedListView<E>(this, 0, null); |
| 164 | 168 |
| 165 void sort([int compare(E a, E b)]) { | 169 void sort([int compare(E a, E b)]) { |
| 166 IterableMixinWorkaround.sortList(this, compare); | 170 IterableMixinWorkaround.sortList(this, compare); |
| 167 } | 171 } |
| 168 | 172 |
| 169 int indexOf(E element, [int start = 0]) { | 173 int indexOf(E element, [int start = 0]) { |
| 170 return Arrays.indexOf(this, element, start, this.length); | 174 return Arrays.indexOf(this, element, start, this.length); |
| 171 } | 175 } |
| 172 | 176 |
| 173 int lastIndexOf(E element, [int start = null]) { | 177 int lastIndexOf(E element, [int start = null]) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 331 } |
| 328 | 332 |
| 329 void forEach(f(E element)) { | 333 void forEach(f(E element)) { |
| 330 IterableMixinWorkaround.forEach(this, f); | 334 IterableMixinWorkaround.forEach(this, f); |
| 331 } | 335 } |
| 332 | 336 |
| 333 Iterable map(f(E element)) { | 337 Iterable map(f(E element)) { |
| 334 return IterableMixinWorkaround.mapList(this, f); | 338 return IterableMixinWorkaround.mapList(this, f); |
| 335 } | 339 } |
| 336 | 340 |
| 341 List mappedBy(f(E element)) { |
| 342 return IterableMixinWorkaround.mappedByList(this, f); |
| 343 } |
| 344 |
| 337 String join([String separator]) { | 345 String join([String separator]) { |
| 338 return IterableMixinWorkaround.joinList(this, separator); | 346 return IterableMixinWorkaround.joinList(this, separator); |
| 339 } | 347 } |
| 340 | 348 |
| 341 reduce(initialValue, combine(previousValue, E element)) { | 349 reduce(initialValue, combine(previousValue, E element)) { |
| 342 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 350 return IterableMixinWorkaround.reduce(this, initialValue, combine); |
| 343 } | 351 } |
| 344 | 352 |
| 345 Iterable<E> where(bool f(E element)) { | 353 Iterable<E> where(bool f(E element)) { |
| 346 return IterableMixinWorkaround.where(this, f); | 354 return IterableMixinWorkaround.where(this, f); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 395 } |
| 388 | 396 |
| 389 E elementAt(int index) { | 397 E elementAt(int index) { |
| 390 return this[index]; | 398 return this[index]; |
| 391 } | 399 } |
| 392 | 400 |
| 393 bool get isEmpty { | 401 bool get isEmpty { |
| 394 return this.length == 0; | 402 return this.length == 0; |
| 395 } | 403 } |
| 396 | 404 |
| 397 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 405 List<E> get reversed => new ReversedListView<E>(this, 0, null); |
| 398 | 406 |
| 399 void sort([int compare(E a, E b)]) { | 407 void sort([int compare(E a, E b)]) { |
| 400 throw new UnsupportedError( | 408 throw new UnsupportedError( |
| 401 "Cannot modify an immutable array"); | 409 "Cannot modify an immutable array"); |
| 402 } | 410 } |
| 403 | 411 |
| 404 String toString() { | 412 String toString() { |
| 405 return Collections.collectionToString(this); | 413 return Collections.collectionToString(this); |
| 406 } | 414 } |
| 407 | 415 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 506 } |
| 499 _position = _length; | 507 _position = _length; |
| 500 _current = null; | 508 _current = null; |
| 501 return false; | 509 return false; |
| 502 } | 510 } |
| 503 | 511 |
| 504 E get current { | 512 E get current { |
| 505 return _current; | 513 return _current; |
| 506 } | 514 } |
| 507 } | 515 } |
| OLD | NEW |