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 class _GrowableObjectArray<T> implements List<T> { | 5 class _GrowableObjectArray<T> implements List<T> { |
| 6 factory _GrowableObjectArray._uninstantiable() { | 6 factory _GrowableObjectArray._uninstantiable() { |
| 7 throw new UnsupportedError( | 7 throw new UnsupportedError( |
| 8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 f(this[i]); | 177 f(this[i]); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 Iterable mappedBy(f(T element)) => new MappedIterable(this, f); | 181 Iterable mappedBy(f(T element)) => new MappedIterable(this, f); |
| 182 | 182 |
| 183 reduce(initialValue, combine(previousValue, T element)) { | 183 reduce(initialValue, combine(previousValue, T element)) { |
| 184 return Collections.reduce(this, initialValue, combine); | 184 return Collections.reduce(this, initialValue, combine); |
| 185 } | 185 } |
| 186 | 186 |
| 187 Collection<T> where(bool f(T element)) { | 187 Iterable<T> where(bool f(T element)) => new FilteredIterable<T>(this, f); |
|
Lasse Reichstein Nielsen
2012/11/20 11:44:57
We can't just inherit this from Iterable?
floitsch
2012/11/28 13:49:38
Yes. we could, but currently this class is not ext
| |
| 188 return Collections.where(this, new _GrowableObjectArray<T>(), f); | |
| 189 } | |
| 190 | 188 |
| 191 bool every(bool f(T element)) { | 189 bool every(bool f(T element)) { |
| 192 return Collections.every(this, f); | 190 return Collections.every(this, f); |
| 193 } | 191 } |
| 194 | 192 |
| 195 bool some(bool f(T element)) { | 193 bool some(bool f(T element)) { |
| 196 return Collections.some(this, f); | 194 return Collections.some(this, f); |
| 197 } | 195 } |
| 198 | 196 |
| 199 bool get isEmpty { | 197 bool get isEmpty { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 215 Iterator<T> get iterator => new SequenceIterator<T>(this); | 213 Iterator<T> get iterator => new SequenceIterator<T>(this); |
| 216 | 214 |
| 217 List<T> toList() { | 215 List<T> toList() { |
| 218 return new List<T>.from(this); | 216 return new List<T>.from(this); |
| 219 } | 217 } |
| 220 | 218 |
| 221 Set<T> toSet() { | 219 Set<T> toSet() { |
| 222 return new Set<T>.from(this); | 220 return new Set<T>.from(this); |
| 223 } | 221 } |
| 224 } | 222 } |
| OLD | NEW |