If the with: argument to SequenceableCollection >> copyReplaceFrom:to:with:
is an empty collection, this method incorrectly returned the receiver.
File in the following as SystemUser and commit:
category: 'Copying'
method: SequenceableCollection
copyReplaceFrom: startIndex to: stopIndex with: aSequenceableCollection
"Returns a copy of the receiver in which all elements in the
receiver between indexes startIndex and stopIndex inclusive have
been replaced by those contained in aSequenceableCollection."
| selfSize seqCollSize targetIndex result |
startIndex > stopIndex ifTrue:
[^startIndex _error: #rtErrBadCopyFromTo args: #[stopIndex]].
seqCollSize := aSequenceableCollection size.
result := self species new.
targetIndex := 1.
startIndex > 1 ifTrue:
[self
copyFrom: 1
to: startIndex - 1
into: result
startingAt: targetIndex.
targetIndex := targetIndex + startIndex - 1].
0 < seqCollSize ifTrue: [
aSequenceableCollection
copyFrom: 1
to: seqCollSize
into: result
startingAt: targetIndex.
].
targetIndex := targetIndex + seqCollSize.
selfSize := self size.
stopIndex < selfSize ifTrue:
[self
copyFrom: stopIndex + 1
to: selfSize
into: result
startingAt: targetIndex].
^result
%
Last updated: 6/2/10