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

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

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 months 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
« no previous file with comments | « runtime/lib/collections.dart ('k') | tests/corelib/src/GrowableObjectArrayVMTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 ObjectArray<T> backingArray; 6 ObjectArray<T> backingArray;
7 7
8 factory GrowableObjectArray._uninstantiable() { 8 factory GrowableObjectArray._uninstantiable() {
9 throw const UnsupportedOperationException( 9 throw const UnsupportedOperationException(
10 "GrowableObjectArray can only be allocated by the VM"); 10 "GrowableObjectArray can only be allocated by the VM");
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 */ 191 */
192 192
193 void forEach(f(T element)) { 193 void forEach(f(T element)) {
194 // TODO(srdjan): Use Collections.forEach(this, f); 194 // TODO(srdjan): Use Collections.forEach(this, f);
195 // Using backingArray directly improves DeltaBlue performance by 25%. 195 // Using backingArray directly improves DeltaBlue performance by 25%.
196 for (int i = 0; i < _length; i++) { 196 for (int i = 0; i < _length; i++) {
197 f(backingArray[i]); 197 f(backingArray[i]);
198 } 198 }
199 } 199 }
200 200
201 Collection map(f(T element)) {
202 return Collections.map(this, new GrowableObjectArray.withCapacity(length), f );
203 }
204
201 Collection<T> filter(bool f(T element)) { 205 Collection<T> filter(bool f(T element)) {
202 return Collections.filter(this, new GrowableObjectArray<T>(), f); 206 return Collections.filter(this, new GrowableObjectArray<T>(), f);
203 } 207 }
204 208
205 bool every(bool f(T element)) { 209 bool every(bool f(T element)) {
206 return Collections.every(this, f); 210 return Collections.every(this, f);
207 } 211 }
208 212
209 bool some(bool f(T element)) { 213 bool some(bool f(T element)) {
210 return Collections.some(this, f); 214 return Collections.some(this, f);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!hasNext()) { 250 if (!hasNext()) {
247 throw const NoMoreElementsException(); 251 throw const NoMoreElementsException();
248 } 252 }
249 return _array[_pos++]; 253 return _array[_pos++];
250 } 254 }
251 255
252 final GrowableObjectArray<T> _array; 256 final GrowableObjectArray<T> _array;
253 int _pos; 257 int _pos;
254 } 258 }
255 259
OLDNEW
« no previous file with comments | « runtime/lib/collections.dart ('k') | tests/corelib/src/GrowableObjectArrayVMTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698