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

Unified Diff: sdk/lib/core/queue.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 | « sdk/lib/core/list.dart ('k') | sdk/lib/core/set.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/queue.dart
diff --git a/sdk/lib/core/queue.dart b/sdk/lib/core/queue.dart
index 9a000c34143274a16c5d08f0f5829556efc2a59b..8f20efdcc7cb60614b6922238d85b7278d4d4262 100644
--- a/sdk/lib/core/queue.dart
+++ b/sdk/lib/core/queue.dart
@@ -201,6 +201,44 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
return _sentinel._next.remove();
}
+ void remove(Object o) {
+ DoubleLinkedQueueEntry<E> entry = firstEntry();
+ while (!identical(entry, _sentinel)) {
+ if (entry.element == o) {
+ entry.remove();
+ return;
+ }
+ entry = entry._next;
+ }
+ }
+
+ void removeAll(Iterable elements) {
+ // Use this method when remove is slow and removeMatching more efficient.
+ IterableMixinWorkaround.removeAllList(this, elements);
+ }
+
+ void removeMatching(bool test(E element)) {
+ DoubleLinkedQueueEntry<E> entry = firstEntry();
+ while (!identical(entry, _sentinel)) {
+ DoubleLinkedQueueEntry<E> next = entry._next;
+ if (test(entry.element)) {
+ entry.remove();
+ }
+ entry = next;
+ }
+ }
+
+ void retainMatching(bool test(E element)) {
+ DoubleLinkedQueueEntry<E> entry = firstEntry();
+ while (!identical(entry, _sentinel)) {
+ DoubleLinkedQueueEntry<E> next = entry._next;
+ if (!test(entry.element)) {
+ entry.remove();
+ }
+ entry = next;
+ }
+ }
+
E get first {
return _sentinel._next.element;
}
« no previous file with comments | « sdk/lib/core/list.dart ('k') | sdk/lib/core/set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698