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

Unified Diff: runtime/lib/growable_array.dart

Issue 12049065: Fix bugs in GrowableList.remove*. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: runtime/lib/growable_array.dart
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index 52bced7530f0e787bc4a62c24874859ecc3b9669..39e35fdb049586f3f867094c0b8e11ecf73dcca0 100644
--- a/runtime/lib/growable_array.dart
+++ b/runtime/lib/growable_array.dart
@@ -24,18 +24,29 @@ class _GrowableObjectArray<T> implements List<T> {
void remove(Object element) {
for (int i = 0; i < this.length; i++) {
if (this[i] == element) {
- int newLength = this.length - 1;
- Arrays.copy(this,
- index + 1,
- this,
- index,
- newLength - index);
- this.length = newLength;
+ removeAt(i);
Anders Johnsen 2013/01/24 09:40:46 Nice :)
return;
}
}
}
+ void removeAll(Iterable elements) {
+ IterableMixinWorkaround.removeAllList(this, elements);
+ }
+
+ void retainAll(Iterable elements) {
+ IterableMixinWorkaround.retainAll(this, elements);
+ }
+
+ void removeMatching(bool test(E element)) {
+ IterableMixinWorkaround.removeMatchingList(this, test);
+ }
+
+ void retainMatching(bool test(T element)) {
+ IterableMixinWorkaround.removeMatchingList(this,
+ (T element) => !test(element));
+ }
+
void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
if (length < 0) {
throw new ArgumentError("negative length $length");
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | tests/corelib/collection_removes_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698