[FIX] OrderedCollection

Bert Freudenberg bert at isgnw.CS.Uni-Magdeburg.De
Thu May 18 15:41:21 UTC 2000


Fixes OrderedCollection methods #collect:from:to: and #withIndexCollect:
to use #addLast: instead of #at:put:.

-- Bert
-------------- next part --------------
'From Squeak2.8alpha of 18 January 2000 [latest update: #2158] on 18 May 2000 at 5:40:50 pm'!
"Change Set:		OC-fix-bf
Date:			18 May 2000
Author:			Bert Freudenberg

Fixes OrderedCollection methods #collect:from:to: and #withIndexCollect:    
to use #addLast: instead of #at:put:."!


!OrderedCollection methodsFor: 'enumerating' stamp: 'bf 5/18/2000 17:34'!
collect: aBlock from: fromIndex to: toIndex
	"Override superclass in order to use addLast:, not at:put:."
	| result |
	(fromIndex < 1 or:[toIndex + firstIndex - 1 > lastIndex])
		ifTrue: [^self errorNoSuchElement].
	result _ self species new: toIndex - fromIndex + 1.
	firstIndex + fromIndex - 1 to: firstIndex + toIndex - 1 do:
		[:index | result addLast: (aBlock value: (array at: index))].
	^ result
! !

!OrderedCollection methodsFor: 'enumerating' stamp: 'bf 5/16/2000 16:30'!
withIndexCollect: elementAndIndexBlock 
	"Just like with:collect: except that the iteration index supplies the second argument to the block. Override superclass in order to use addLast:, not at:put:."

	| newCollection |
	newCollection _ self species new: self size.
	firstIndex to: lastIndex do:
		[:index |
		newCollection addLast: (elementAndIndexBlock
			value: (array at: index)
			value: index - firstIndex + 1)].
	^ newCollection! !



More information about the Squeak-dev mailing list