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

Side by Side Diff: samples/ui_lib/util/CollectionUtils.dart

Issue 10908291: Reapply "Remove Object.dynamic." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « samples/maps/directions.dart ('k') | tests/co19/co19-compiler.status » ('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 typedef num NumericValueSelector<T>(T value); 5 typedef num NumericValueSelector<T>(T value);
6 6
7 /** 7 /**
8 * General purpose collection utilities. 8 * General purpose collection utilities.
9 * TODO(jmesserly): make these top level functions? 9 * TODO(jmesserly): make these top level functions?
10 */ 10 */
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 // Collection<T> supports most of the ES 5 list methods, but it's missing 41 // Collection<T> supports most of the ES 5 list methods, but it's missing
42 // map. 42 // map.
43 43
44 // TODO(jmesserly): we might want a version of this that return an iterable, 44 // TODO(jmesserly): we might want a version of this that return an iterable,
45 // however JS, Python and Ruby versions are all eager. 45 // however JS, Python and Ruby versions are all eager.
46 static List map(Iterable source, var mapper) { 46 static List map(Iterable source, var mapper) {
47 // TODO(jmesserly): I was trying to set the capacity here, but instead it 47 // TODO(jmesserly): I was trying to set the capacity here, but instead it
48 // seems to create a fixed list. Hence assigning by index below. 48 // seems to create a fixed list. Hence assigning by index below.
49 List result = new List(source is List ? source.dynamic.length : null); 49 List result = new List(source is List ? (source as List).length : null);
50 int i = 0; 50 int i = 0;
51 for (final item in source) { 51 for (final item in source) {
52 result[i++] = mapper(item); 52 result[i++] = mapper(item);
53 } 53 }
54 return result; 54 return result;
55 } 55 }
56 56
57 /** 57 /**
58 * Finds the item in [source] that matches [test]. Returns null if 58 * Finds the item in [source] that matches [test]. Returns null if
59 * no item matches. The typing should be: 59 * no item matches. The typing should be:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 // TODO(jmesserly): something like should exist on Map, either a method or a 132 // TODO(jmesserly): something like should exist on Map, either a method or a
133 // constructor, see bug #5340679 133 // constructor, see bug #5340679
134 static void copyMap(Map dest, Map source) { 134 static void copyMap(Map dest, Map source) {
135 for (final k in source.getKeys()) { 135 for (final k in source.getKeys()) {
136 dest[k] = source[k]; 136 dest[k] = source[k];
137 } 137 }
138 } 138 }
139 } 139 }
OLDNEW
« no previous file with comments | « samples/maps/directions.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698