diff --git a/kernel/Array.st b/kernel/Array.st index b3ef3fd..009c803 100644 --- a/kernel/Array.st +++ b/kernel/Array.st @@ -76,7 +76,7 @@ and general access behavior from SequenceableCollection.'> ^self isReadOnly not ] - replaceFrom: start to: stop with: byteArray startingAt: replaceStart [ + replaceFrom: start to: stop with: aCollection startingAt: replaceStart [ "Replace the characters from start to stop with new characters whose ASCII codes are contained in byteArray, starting at the replaceStart location of byteArray" @@ -86,7 +86,7 @@ and general access behavior from SequenceableCollection.'> ^super replaceFrom: start to: stop - with: byteArray + with: aCollection startingAt: replaceStart ] diff --git a/kernel/Collection.st b/kernel/Collection.st index 948b62f..de93e1d 100644 --- a/kernel/Collection.st +++ b/kernel/Collection.st @@ -647,4 +647,10 @@ of objects.'> self remove: anObject ifAbsent: []. self == Object finalizableObjects ifTrue: [anObject key finalize] ] + + basicFirstIndex [ + + + ^ 1 + ] ] diff --git a/kernel/OrderColl.st b/kernel/OrderColl.st index 9f0cf29..daecc16 100644 --- a/kernel/OrderColl.st +++ b/kernel/OrderColl.st @@ -508,15 +508,49 @@ on content (such as add:after:)'> self become: newOrderedCollection ] - primReplaceFrom: start to: stop with: byteArray startingAt: replaceStart [ - "Replace the characters from start to stop with new characters whose - ASCII codes are contained in byteArray, starting at the replaceStart - location of byteArray" + basicFirstIndex [ + + + ^ firstIndex + ] + + replaceFrom: start to: stop with: aCollection startingAt: replaceStart [ + "Replace the objects from start to stop with new objects whose + items are contained in aCollection, starting at the replaceStart + location of aCollection" + + + + | minStop maxStop size | + size := aCollection size. + minStop := start - 1. + maxStop := self size min: minStop + size. + (start <= stop and: [ start >= 1 and: [ stop <= maxStop ] ]) + ifFalse: [ + ^ SystemExceptions.ArgumentOutOfRange + signalOn: stop + mustBeBetween: minStop + and: maxStop ]. + (replaceStart + stop - start) > size ifTrue: [ + ^ SystemExceptions.ArgumentOutOfRange + signalOn: replaceStart + mustBeBetween: 1 + and: size ]. + ^ self + primReplaceFrom: firstIndex + start - 1 + to: firstIndex + stop - 1 + with: aCollection + startingAt: aCollection basicFirstIndex + replaceStart - 1 + ] + + primReplaceFrom: start to: stop with: aCollection startingAt: replaceStart [ + "Replace the objects from start to stop with new objects whose + items are contained in aCollection, starting at the replaceStart + location of aCollection" - self primitiveFailed + self primitiveFailed ] - ] diff --git a/kernel/SortCollect.st b/kernel/SortCollect.st index ef8a8bc..0e97f24 100644 --- a/kernel/SortCollect.st +++ b/kernel/SortCollect.st @@ -113,6 +113,11 @@ above criteria -- actually any object which responds to #value:value:.'> self shouldNotImplement ] + replaceFrom: start to: stop with: aCollection startingAt: replaceStart [ + + self shouldNotImplement + ] + do: aBlock [ "Evaluate aBlock for all the elements in the collection"