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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Collection interface. | 62 // Collection interface. |
| 63 | 63 |
| 64 bool contains(E element) => Collections.contains(this, element); | 64 bool contains(E element) => Collections.contains(this, element); |
| 65 | 65 |
| 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 Collection mappedBy(f(E element)) { | 70 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); |
|
Ivan Posva
2012/11/26 18:29:09
We like our curlys. Please leave them in.
floitsch
2012/11/28 13:48:23
Done.
| |
| 71 return Collections.mappedBy( | |
| 72 this, new _GrowableObjectArray.withCapacity(length), f); | |
| 73 } | |
| 74 | 71 |
| 75 reduce(initialValue, combine(previousValue, E element)) { | 72 reduce(initialValue, combine(previousValue, E element)) { |
| 76 return Collections.reduce(this, initialValue, combine); | 73 return Collections.reduce(this, initialValue, combine); |
| 77 } | 74 } |
| 78 | 75 |
| 79 Collection<E> where(bool f(E element)) { | 76 Collection<E> where(bool f(E element)) { |
| 80 return Collections.where(this, new _GrowableObjectArray<E>(), f); | 77 return Collections.where(this, new _GrowableObjectArray<E>(), f); |
| 81 } | 78 } |
| 82 | 79 |
| 83 bool every(bool f(E element)) { | 80 bool every(bool f(E element)) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 } | 205 } |
| 209 | 206 |
| 210 // Collection interface. | 207 // Collection interface. |
| 211 | 208 |
| 212 bool contains(E element) => Collections.contains(this, element); | 209 bool contains(E element) => Collections.contains(this, element); |
| 213 | 210 |
| 214 void forEach(f(E element)) { | 211 void forEach(f(E element)) { |
| 215 Collections.forEach(this, f); | 212 Collections.forEach(this, f); |
| 216 } | 213 } |
| 217 | 214 |
| 218 Collection mappedBy(f(E element)) { | 215 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f); |
|
Ivan Posva
2012/11/26 18:29:09
ditto
floitsch
2012/11/28 13:48:23
Done.
| |
| 219 return Collections.mappedBy( | |
| 220 this, new _GrowableObjectArray.withCapacity(length), f); | |
| 221 } | |
| 222 | 216 |
| 223 reduce(initialValue, combine(previousValue, E element)) { | 217 reduce(initialValue, combine(previousValue, E element)) { |
| 224 return Collections.reduce(this, initialValue, combine); | 218 return Collections.reduce(this, initialValue, combine); |
| 225 } | 219 } |
| 226 | 220 |
| 227 Collection<E> where(bool f(E element)) { | 221 Collection<E> where(bool f(E element)) { |
| 228 return Collections.where(this, new _GrowableObjectArray<E>(), f); | 222 return Collections.where(this, new _GrowableObjectArray<E>(), f); |
| 229 } | 223 } |
| 230 | 224 |
| 231 bool every(bool f(E element)) { | 225 bool every(bool f(E element)) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 return _array[_pos]; | 319 return _array[_pos]; |
| 326 } | 320 } |
| 327 // TODO(floitsch): bad error message. | 321 // TODO(floitsch): bad error message. |
| 328 throw new StateError("No more elements"); | 322 throw new StateError("No more elements"); |
| 329 } | 323 } |
| 330 | 324 |
| 331 final List<E> _array; | 325 final List<E> _array; |
| 332 final int _length; // Cache array length for faster access. | 326 final int _length; // Cache array length for faster access. |
| 333 int _pos; | 327 int _pos; |
| 334 } | 328 } |
| OLD | NEW |