logo       

Re: Recap: How to empty a collection: msg#00165

lang.smalltalk.squeak.beginners

Subject: Re: Recap: How to empty a collection

On Wed, 20 Feb 2008 23:05:47 +0100, nicolas cellier wrote:

Klaus D. Witzel a écrit :
On Wed, 20 Feb 2008 02:01:49 +0100, nicolas cellier wrote:

Some proposed an alternative based on (self removeAll: self), and started writing optimized versions of #removeAll:.
No, (anOrderedCollection removeAll: anOrderedCollection) was not optimized. It had a *very* long known bug, which was fixed. Please do less mixing of subjects in threads.


OK, I'm extrapolating.

O.K. the fix from OrderedCollection *could* be applied to Set (the fix requires #copyEmpty), but see Heap below.

In this case, while you are at it:

| aSet |
aSet :='Klaus' asSet.
aSet removeAll: aSet.
aSet

| aHeap |
aHeap := Heap withAll: 'Witzel'.
aHeap removeAll: aHeap.
aHeap

Don't use Heap much, it is not very conformant; example: (Heap withAll: 'array') reject: [:x | x = $r] => an Array. Perhaps people didn't know about *all* senders of #species ...


I would have used my name, but it seems i am removeable ;-)
| aSet |
aSet :='Cellier' asSet.
aSet removeAll: aSet.
aSet

Try with the collection of your choice.

In the mean time, don't use (self removeAll: self)...

One step after the other :) no doubt #removeAll: gets fixed, perhaps in the next release?

Yes i'm mixing threads,should be How to NOT empty a collection ;-)

Nicolas

I think our biggest problem is that we have plenty possible ways to do it... Finding a balance between genericity and efficiency...
No, more correctness at the price of less efficiency :)

Nicolas

Agree on this one.
Then allow removeAllSuchThat: as default implementation.

Nicolas


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise