Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 void forEach(f(E element)) { | 66 void forEach(f(E element)) { |
| 67 Collections.forEach(this, f); | 67 Collections.forEach(this, f); |
| 68 } | 68 } |
| 69 | 69 |
| 70 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); | 70 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); |
| 71 | 71 |
| 72 reduce(initialValue, combine(previousValue, E element)) { | 72 reduce(initialValue, combine(previousValue, E element)) { |
| 73 return Collections.reduce(this, initialValue, combine); | 73 return Collections.reduce(this, initialValue, combine); |
| 74 } | 74 } |
| 75 | 75 |
| 76 Collection<E> where(bool f(E element)) { | 76 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); |
|
Ivan Posva
2012/11/26 18:30:40
ditto: curlys
floitsch
2012/11/28 13:49:38
Done.
| |
| 77 return Collections.where(this, new _GrowableObjectArray<E>(), f); | |
| 78 } | |
| 79 | 77 |
| 80 bool every(bool f(E element)) { | 78 bool every(bool f(E element)) { |
| 81 return Collections.every(this, f); | 79 return Collections.every(this, f); |
| 82 } | 80 } |
| 83 | 81 |
| 84 bool some(bool f(E element)) { | 82 bool some(bool f(E element)) { |
| 85 return Collections.some(this, f); | 83 return Collections.some(this, f); |
| 86 } | 84 } |
| 87 | 85 |
| 88 bool get isEmpty { | 86 bool get isEmpty { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 void forEach(f(E element)) { | 209 void forEach(f(E element)) { |
| 212 Collections.forEach(this, f); | 210 Collections.forEach(this, f); |
| 213 } | 211 } |
| 214 | 212 |
| 215 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); | 213 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); |
| 216 | 214 |
| 217 reduce(initialValue, combine(previousValue, E element)) { | 215 reduce(initialValue, combine(previousValue, E element)) { |
| 218 return Collections.reduce(this, initialValue, combine); | 216 return Collections.reduce(this, initialValue, combine); |
| 219 } | 217 } |
| 220 | 218 |
| 221 Collection<E> where(bool f(E element)) { | 219 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); |
|
Ivan Posva
2012/11/26 18:30:40
ditto
floitsch
2012/11/28 13:49:38
Done.
| |
| 222 return Collections.where(this, new _GrowableObjectArray<E>(), f); | |
| 223 } | |
| 224 | 220 |
| 225 bool every(bool f(E element)) { | 221 bool every(bool f(E element)) { |
| 226 return Collections.every(this, f); | 222 return Collections.every(this, f); |
| 227 } | 223 } |
| 228 | 224 |
| 229 bool some(bool f(E element)) { | 225 bool some(bool f(E element)) { |
| 230 return Collections.some(this, f); | 226 return Collections.some(this, f); |
| 231 } | 227 } |
| 232 | 228 |
| 233 bool get isEmpty { | 229 bool get isEmpty { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 return _array[_pos]; | 315 return _array[_pos]; |
| 320 } | 316 } |
| 321 // TODO(floitsch): bad error message. | 317 // TODO(floitsch): bad error message. |
| 322 throw new StateError("No more elements"); | 318 throw new StateError("No more elements"); |
| 323 } | 319 } |
| 324 | 320 |
| 325 final List<E> _array; | 321 final List<E> _array; |
| 326 final int _length; // Cache array length for faster access. | 322 final int _length; // Cache array length for faster access. |
| 327 int _pos; | 323 int _pos; |
| 328 } | 324 } |
| OLD | NEW |