[update] #10453

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[update] #10453

Stéphane Ducasse
10453
-----

- adding removeAll to collections (missing some of them of course)  
from nicolas

add #removeAll suport to collections
This is to solve both
http://bugs.squeak.org/view.php?id=7177
http://bugs.squeak.org/view.php?id=6937

Comments about the implementation:

The super implementation might be enhanced with a shallowCopy in order  
to provide a working implementation in more cases:
     self shallowCopy do: [:each | self remove: each].
I believe much subclasses will override, so I did not even bother.

Subclass implementation tries to preserve original capacity.
This choice is arbitrary and really depends on application side...

CharacterSetComplement use a #become:. This is not efficient, but  
neither would be the addition of all existing characters to the  
complement (this set is defined by its complement as the name tells).

Collection>>#removeAll: also has been modified to handle case of (self  
removeAll: self). This extends and supersedes the changes from kwl at http://bugs.squeak.org/view.php?id=6937

The big question is what should (self removeAll: self) return?
My answer is simple: it returns self (an empty collection).
Beware, this will break some chaining:
(b removeAll: (a removeAll: a)) ~= (a removeAll: (b removeAll: a)).
Anyway, that is not worse than current implementation which will not  
lead to the most predictible results.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project