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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_array.dart

Issue 11931034: Add methods to Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | sdk/lib/collection/collections.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/lib/js_array.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
index d7148a5981ce074417f3ec1534aa04d1508567b6..62d7463d25f3f69a86127709a6e57c80a3f29cc9 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
@@ -33,6 +33,33 @@ class JSArray<E> implements List<E> {
return JS('var', r'#.pop()', this);
}
+ void remove(Object element) {
+ checkGrowable(this, 'remove');
+ for (int i = 0; i < this.length; i++) {
+ if (this[i] == element) {
+ JS('var', r'#.splice(#, 1)', this, i);
+ return;
+ }
+ }
+ }
+
+ void removeAll(Iterable elements) {
+ Collections.removeAll(this, elements);
+ }
+
+ void retainAll(Iterable elements) {
+ Collections.retainAll(this, elements);
+ }
+
+ void removeMatching(bool test(E element)) {
+ // This could, and should, be optimized.
+ Collections.removeMatching(this, test);
+ }
+
+ void reatainMatching(bool test(E element)) {
+ Collections.reatainMatching(this, test);
+ }
+
Iterable<E> where(bool f(E element)) {
return IterableMixinWorkaround.where(this, f);
}
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | sdk/lib/collection/collections.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698