Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: runtime/lib/growable_array.dart

Issue 11414069: Make mappedBy lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Remove CollectionUtils.mappedBy in Swarm. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bool contains(T element) => Collections.contains(this, element); 171 bool contains(T element) => Collections.contains(this, element);
172 172
173 void forEach(f(T element)) { 173 void forEach(f(T element)) {
174 // TODO(srdjan): Use Collections.forEach(this, f); 174 // TODO(srdjan): Use Collections.forEach(this, f);
175 // Accessing the list directly improves DeltaBlue performance by 25%. 175 // Accessing the list directly improves DeltaBlue performance by 25%.
176 for (int i = 0; i < length; i++) { 176 for (int i = 0; i < length; i++) {
177 f(this[i]); 177 f(this[i]);
178 } 178 }
179 } 179 }
180 180
181 Collection mappedBy(f(T element)) { 181 Iterable mappedBy(f(T element)) => new MappedIterable(this, f);
182 return Collections.mappedBy(this,
183 new _GrowableObjectArray.withCapacity(length), f);
184 }
185 182
186 reduce(initialValue, combine(previousValue, T element)) { 183 reduce(initialValue, combine(previousValue, T element)) {
187 return Collections.reduce(this, initialValue, combine); 184 return Collections.reduce(this, initialValue, combine);
188 } 185 }
189 186
190 Collection<T> where(bool f(T element)) { 187 Collection<T> where(bool f(T element)) {
191 return Collections.where(this, new _GrowableObjectArray<T>(), f); 188 return Collections.where(this, new _GrowableObjectArray<T>(), f);
192 } 189 }
193 190
194 bool every(bool f(T element)) { 191 bool every(bool f(T element)) {
(...skipping 23 matching lines...) Expand all
218 Iterator<T> get iterator => new SequenceIterator<T>(this); 215 Iterator<T> get iterator => new SequenceIterator<T>(this);
219 216
220 List<T> toList() { 217 List<T> toList() {
221 return new List<T>.from(this); 218 return new List<T>.from(this);
222 } 219 }
223 220
224 Set<T> toSet() { 221 Set<T> toSet() {
225 return new Set<T>.from(this); 222 return new Set<T>.from(this);
226 } 223 }
227 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698