[squeak-dev] Re: Why is Heap>>#species => Array?

nicolas cellier ncellier at ifrance.com
Tue Feb 26 20:42:07 UTC 2008


Paolo Bonzini a écrit :
> 
>>
>> Why doesn't this work for #reversed? 
> 
> Because SortedCollection's #reverse returns an OrderedCollection, like 
> #collect: does.
> 
> Paolo
> 
> 

Why not

SortedCollection>>reversed
	^self asSortedCollection: [:a :b | sortBlock value: b value: a]

Of course, that could be optimized, because we now we do not have to 
sort. Create a new instance with these:

	newFirstIndex := self size - lastIndex + 1.
	newLastIndex := self size - firstIndex + 1.
	newArray := array reversed.
	newSortBlock := [:a :b | sortBlock value: b value: a].

Nicolas




More information about the Squeak-dev mailing list