| OLD | NEW |
| 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 // Utilities used by the node library. | 5 // Utilities used by the node library. |
| 6 | 6 |
| 7 #library('nodeimpl'); | 7 #library('nodeimpl'); |
| 8 #import('dart:coreimpl'); | 8 #import('dart:coreimpl'); |
| 9 | 9 |
| 10 var require(String module) native; | 10 var require(String module) native; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 List filtered = []; | 199 List filtered = []; |
| 200 int len = list.length; | 200 int len = list.length; |
| 201 for (int i = 0; i < len; i++) { | 201 for (int i = 0; i < len; i++) { |
| 202 var e = list[i]; | 202 var e = list[i]; |
| 203 if (f(e)) { | 203 if (f(e)) { |
| 204 filtered.add(e); | 204 filtered.add(e); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 int filteredLength = filtered.length; | 207 int filteredLength = filtered.length; |
| 208 List result = ctor(filteredLength); | 208 List result = ctor(filteredLength); |
| 209 for (int i = 0; i < len; i++) { | 209 for (int i = 0; i < filteredLength; i++) { |
| 210 result[i] = filtered[i]; | 210 result[i] = filtered[i]; |
| 211 } | 211 } |
| 212 return result; | 212 return result; |
| 213 } | 213 } |
| 214 | 214 |
| 215 static bool every(List list, bool f(int element)) { | 215 static bool every(List list, bool f(int element)) { |
| 216 int len = list.length; | 216 int len = list.length; |
| 217 for (int i = 0; i < len; i++) { | 217 for (int i = 0; i < len; i++) { |
| 218 if (! f(list[i])) { | 218 if (! f(list[i])) { |
| 219 return false; | 219 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 236 for (int i = 0; i < len; i++) { | 236 for (int i = 0; i < len; i++) { |
| 237 if (f(list[i])) { | 237 if (f(list[i])) { |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 return false; | 241 return false; |
| 242 } | 242 } |
| 243 | 243 |
| 244 static bool isEmpty(List list) => list.length == 0; | 244 static bool isEmpty(List list) => list.length == 0; |
| 245 } | 245 } |
| OLD | NEW |