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

Side by Side Diff: frog/utils.dart

Issue 9107067: Work in progress: changes to interpretation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: work in progress 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 | « frog/type.dart ('k') | frog/value.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 // Collection<T> supports most of the ES 5 Array methods, but it's missing 5 // Collection<T> supports most of the ES 5 Array methods, but it's missing
6 // map and reduce. 6 // map and reduce.
7 7
8 // TODO(jmesserly): we might want a version of this that return an iterable, 8 // TODO(jmesserly): we might want a version of this that return an iterable,
9 // however JS, Python and Ruby versions are all eager. 9 // however JS, Python and Ruby versions are all eager.
10 // TODO(jmesserly): remove this now that it exists in corelib.
10 List map(Iterable source, mapper(source)) { 11 List map(Iterable source, mapper(source)) {
11 List result = new List(); 12 List result = new List();
12 if (source is List) { 13 if (source is List) {
13 List list = source; // TODO: shouldn't need this 14 List list = source; // TODO: shouldn't need this
14 result.length = list.length; 15 result.length = list.length;
15 for (int i = 0; i < list.length; i++) { 16 for (int i = 0; i < list.length; i++) {
16 result[i] = mapper(list[i]); 17 result[i] = mapper(list[i]);
17 } 18 }
18 } else { 19 } else {
19 for (final item in source) { 20 for (final item in source) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Forwarding methods: 171 // Forwarding methods:
171 V operator [](K key) => _map[key]; 172 V operator [](K key) => _map[key];
172 bool isEmpty() => _map.isEmpty(); 173 bool isEmpty() => _map.isEmpty();
173 int get length() => _map.length; 174 int get length() => _map.length;
174 void forEach(void f(K key, V value)) => _map.forEach(f); 175 void forEach(void f(K key, V value)) => _map.forEach(f);
175 Collection<K> getKeys() => _map.getKeys(); 176 Collection<K> getKeys() => _map.getKeys();
176 Collection<V> getValues() => _map.getValues(); 177 Collection<V> getValues() => _map.getValues();
177 bool containsKey(K key) => _map.containsKey(key); 178 bool containsKey(K key) => _map.containsKey(key);
178 bool containsValue(V value) => _map.containsValue(value); 179 bool containsValue(V value) => _map.containsValue(value);
179 } 180 }
OLDNEW
« no previous file with comments | « frog/type.dart ('k') | frog/value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698