--- a/Collection.st Wed Aug 04 12:30:16 2010 +0200
+++ b/Collection.st Thu Aug 05 13:52:37 2010 +0200
@@ -903,7 +903,7 @@
!
removeAll:aCollection
- "remove all elements of the argument, aCollection from the receiver.
+ "remove all elements from the receiver which are equal to any in aCollection.
Return the argument, aCollection.
Raises an error, if some element-to-remove is not in the receiver.
(see also: #removeAllFoundIn:, which does not raise an error).
@@ -941,12 +941,11 @@
coll
"
-
+ "Modified: / 05-08-2010 / 13:50:33 / cg"
!
removeAllFoundIn:aCollection
- "Remove each element of aCollection, which is present in the receiver
- from the receiver.
+ "remove all elements from the receiver which are equal to any in aCollection.
No error is raised, if some element-to-remove is not in the receiver.
(see also: #removeAll:, which does raise an error)."
@@ -969,6 +968,76 @@
coll
"
+ "Modified: / 05-08-2010 / 13:51:05 / cg"
+!
+
+removeAllIdentical:aCollection
+ "remove all elements from the receiver which are in aCollection.
+ Return the argument, aCollection.
+ Raises an error, if some element-to-remove is not in the receiver.
+ (see also: #removeAllFoundIn:, which does not raise an error).
+
+ Notice: for some collections (those not tuned for
+ resizing themself) this may be very slow.
+ If the number of removed elements is big compared to to
+ the receivers size, it may be better to copy the
+ ones which are not to be removed into a new collection."
+
+ aCollection do:[:element | self removeIdentical:element].
+ ^ aCollection
+
+ "
+ |coll|
+
+ coll := #(1 2 3 4 5 6) asSet.
+ coll removeAll:#(4 5 6).
+ coll
+ "
+
+ "raises an error:
+ |coll|
+
+ coll := #(1 2 3 4 5 6) asSet.
+ coll removeAll:#(4 5 6 7 8).
+ coll
+ "
+
+ "no error raised:
+ |coll|
+
+ coll := #(1 2 3 4 5 6) asSet.
+ coll removeAllFoundIn:#(4 5 6 7 8).
+ coll
+ "
+
+ "Created: / 05-08-2010 / 13:51:51 / cg"
+!
+
+removeAllIdenticalFoundIn:aCollection
+ "remove all elements from the receiver which are in aCollection.
+ No error is raised, if some element-to-remove is not in the receiver.
+ (see also: #removeAll:, which does raise an error)."
+
+ aCollection do:[:each | self removeIdentical:each ifAbsent:[]].
+ ^ aCollection
+
+ "
+ |coll|
+
+ coll := #(1 2 3 4 5 6) asSet.
+ coll removeAllFoundIn:#(4 5 6 7 8).
+ coll
+ "
+
+ "raises an error:
+ |coll|
+
+ coll := #(1 2 3 4 5 6) asSet.
+ coll removeAll:#(4 5 6 7 8).
+ coll
+ "
+
+ "Created: / 05-08-2010 / 13:52:21 / cg"
!
removeAllKeys:aCollection
@@ -3652,11 +3721,11 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.244 2010-07-11 15:06:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.245 2010-08-05 11:52:37 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.244 2010-07-11 15:06:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.245 2010-08-05 11:52:37 cg Exp $'
! !
Collection initialize!