| 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 class GrowableObjectArray<T> implements List<T> { | 5 class GrowableObjectArray<T> implements List<T> { |
| 6 factory GrowableObjectArray._uninstantiable() { | 6 factory GrowableObjectArray._uninstantiable() { |
| 7 throw const UnsupportedOperationException( | 7 throw const UnsupportedOperationException( |
| 8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 for (int i = 0; i < length; i++) { | 173 for (int i = 0; i < length; i++) { |
| 174 f(this[i]); | 174 f(this[i]); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 Collection map(f(T element)) { | 178 Collection map(f(T element)) { |
| 179 return Collections.map(this, | 179 return Collections.map(this, |
| 180 new GrowableObjectArray.withCapacity(length), f); | 180 new GrowableObjectArray.withCapacity(length), f); |
| 181 } | 181 } |
| 182 | 182 |
| 183 Dynamic reduce(Dynamic initialValue, |
| 184 Dynamic combine(Dynamic previousValue, E element)) { |
| 185 return Collections.reduce(this, initialValue, combine); |
| 186 } |
| 187 |
| 183 Collection<T> filter(bool f(T element)) { | 188 Collection<T> filter(bool f(T element)) { |
| 184 return Collections.filter(this, new GrowableObjectArray<T>(), f); | 189 return Collections.filter(this, new GrowableObjectArray<T>(), f); |
| 185 } | 190 } |
| 186 | 191 |
| 187 bool every(bool f(T element)) { | 192 bool every(bool f(T element)) { |
| 188 return Collections.every(this, f); | 193 return Collections.every(this, f); |
| 189 } | 194 } |
| 190 | 195 |
| 191 bool some(bool f(T element)) { | 196 bool some(bool f(T element)) { |
| 192 return Collections.some(this, f); | 197 return Collections.some(this, f); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 T next() { | 232 T next() { |
| 228 if (!hasNext()) { | 233 if (!hasNext()) { |
| 229 throw const NoMoreElementsException(); | 234 throw const NoMoreElementsException(); |
| 230 } | 235 } |
| 231 return _array[_pos++]; | 236 return _array[_pos++]; |
| 232 } | 237 } |
| 233 | 238 |
| 234 final GrowableObjectArray<T> _array; | 239 final GrowableObjectArray<T> _array; |
| 235 int _pos; | 240 int _pos; |
| 236 } | 241 } |
| OLD | NEW |