--- a/Collection.st Tue Mar 05 12:30:58 2019 +0100
+++ b/Collection.st Tue Mar 05 12:50:49 2019 +0100
@@ -2442,20 +2442,32 @@
No error is reported, if elementToSkip is not in the collection.
This is a slow generic fallback. Many collections redefine this for performance."
- |copy|
-
- copy := self species new.
- self do:[:each |
- each = elementToSkip ifFalse:[
- copy add:each
- ].
- ].
- ^ copy
+ ^ self select:[:each | each ~= elementToSkip]
"
#($a $b $c $d $e $f $g $a $b $a $d $a $f $a) asBag copyWithout:$a
#($a $b $c $d $e $f $g $a $b $a $d $a $f $a) asSet copyWithout:$a
"
+
+ "Modified: / 05-03-2019 / 12:35:12 / Stefan Vogel"
+!
+
+copyWithoutAll:elementsToSkip
+ "return a new collection consisting of a copy of the receiver, with
+ ALL elements equal to any in elementsToSkip are left out.
+ No error is reported, if any in elementsToSkip is not in the collection."
+
+ elementsToSkip size * self size > 10000 ifTrue:[
+ "speed up everything"
+ ^ self \ (elementsToSkip asSet).
+ ].
+ ^ self \ elementsToSkip
+
+ "
+ #($a $b $c $d $e $f $g $a $b $a $d $a $f $a) asBag copyWithoutAll:'abc'
+ "
+
+ "Created: / 05-03-2019 / 11:49:08 / Stefan Vogel"
!
postCopyFrom:original