[squeak-dev] The Trunk: Collections-ar.129.mcz

Göran Krampe goran at krampe.se
Mon Sep 14 09:28:51 UTC 2009


Hey!

> Andreas Raab uploaded a new version of Collections to project The Trunk:
> Merging Collections-ul.128:
> 
> - introduced #new:streamContents: in SequenceableCollection class. It's like #streamContents: but if you know the size of the new collection this method doesn't copy the result.
> - updated SequenceableCollection class >> #streamContents: to use #new:streamContents:, kept the original default size 100.
> - also updated Dictionary >> #association, Bag >> #sortedCounts and Dictionary >> #keysSortedSafely to use #new:streamContents:.
> 
> - introduced #sort: in OrderedCollection. It uses Array's merge sort to sort the internal array. This is much faster than sorting with SortedCollection (though it uses an extra Array object). Also added #sort which uses the same default block as Array >> #sort.

Great.

> - updated Bag >> #sortedCounts, Bag >> #sortedElements, Dictionary >> #keysSortedSafely, SequenceableCollection >> #sortBy: to use OrderedCollection's or Array's #sort method which can be significantly faster in these cases.
> 
> - modified OrderedCollection class >> #newFrom: to avoid reallocating the internal array of the new OrderedCollection when the sender of #newFrom: doesn't extend the collection.
> 
> - changed the variable name from anOrderedCollection to aCollection in OrderedCollection >> #addAllLast: since it is being used with other Collections. Also changed the comment which seems to be superfluous.

Now that we are actually touching these classes again :) - how about 
adding Collection>>removeAll? With proper implementations in subclasses.

I don't have a current trunk in front of me, so perhaps it has already 
been done. Why you may ask? It preserves identity (instead of creating a 
new collection) and it can be implemented really fast in some 
subclasses. A default implementation in Collection can be:

"self copy do: [:each | self remove: each]" ...or whatever.

A few years back when I proposed it... well :)

regards, Göran




More information about the Squeak-dev mailing list