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

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

Issue 9456017: Fix issue 1741: add map to immutable list. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | 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) 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 ListFactory<E> { 5 class ListFactory<E> {
6 6
7 factory List.from(Iterable<E> other) { 7 factory List.from(Iterable<E> other) {
8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>();
9 for (final e in other) { 9 for (final e in other) {
10 list.add(e); 10 list.add(e);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 /** 211 /**
212 * Collection interface. 212 * Collection interface.
213 */ 213 */
214 214
215 void forEach(f(E element)) { 215 void forEach(f(E element)) {
216 Collections.forEach(this, f); 216 Collections.forEach(this, f);
217 } 217 }
218 218
219 Collection map(f(E element)) {
220 return Collections.map(this, new GrowableObjectArray.withCapacity(length), f );
221 }
222
siva 2012/02/23 19:11:46 Not for this change list but maybe a future refact
srdjan 2012/02/23 19:23:24 We need mixins :-). Having subclass hierarchies ju
219 Collection<E> filter(bool f(E element)) { 223 Collection<E> filter(bool f(E element)) {
220 return Collections.filter(this, new GrowableObjectArray<E>(), f); 224 return Collections.filter(this, new GrowableObjectArray<E>(), f);
221 } 225 }
222 226
223 bool every(bool f(E element)) { 227 bool every(bool f(E element)) {
224 return Collections.every(this, f); 228 return Collections.every(this, f);
225 } 229 }
226 230
227 bool some(bool f(E element)) { 231 bool some(bool f(E element)) {
228 return Collections.some(this, f); 232 return Collections.some(this, f);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (!hasNext()) { 308 if (!hasNext()) {
305 throw const NoMoreElementsException(); 309 throw const NoMoreElementsException();
306 } 310 }
307 return _array[_pos++]; 311 return _array[_pos++];
308 } 312 }
309 313
310 final List<E> _array; 314 final List<E> _array;
311 final int _length; // Cache array length for faster access. 315 final int _length; // Cache array length for faster access.
312 int _pos; 316 int _pos;
313 } 317 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698