[BUG]Collection>>removeAll:
Norton, Chris
chrisn at Kronos.com
Fri Aug 23 15:19:34 UTC 2002
Richard, please don't start with the name calling (re: "This is a
slander."). None of my replies were intended to put you down or malign you
in any way. I am only opposed to the copying that can be plainly seen in
your method (below). I don't *know* what kind of penalties that that
innocent looking #copy will result in. And, as I've said before, I would
prefer to retain the identity of method argument.
!Collection methodsFor: 'removing' stamp: 'raok 8/21/2002 10:45'!
removeAll: aCollection
"Remove each element of aCollection from the receiver. If successful
for
each, answer aCollection. Otherwise create an error notification.
In the
rare case that aCollection == self, a copy of aCollection is
returned.
ArrayedCollections cannot respond to this message."
|c|
(c _ aCollection) == self ifTrue: [c _ c copy].
c do: [:each | self remove: each].
^c! !
In an effort to remain on a constructive plain, I'd like to promote Stephan
Rudlof's implementation suggestion; it looks very promising to me.
Collection>>removeAll: aCollection
self isEmpty
ifFalse: [self assert: [self ~~ aCollection].
aCollection do: [:each | self remove: each]].
^aCollection
In his implementation, he retains the original functionality and he adds a
warning. Without actually trying it, the code looks good to me.
I hope y'all have a nice weekend.
---==> Chris
More information about the Squeak-dev
mailing list
|