--- a/SequenceableCollection.st Thu Jun 30 21:11:02 2016 +0100
+++ b/SequenceableCollection.st Thu Jun 30 21:12:35 2016 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -639,7 +641,7 @@
around in big chunks"
n := self occurrencesOfAny:elementsToSkip.
- n == 0 ifTrue:[^ self copy].
+ n == 0 ifTrue:[^ self copyFrom:1].
sz := self size.
copy := self copyEmptyAndGrow:(sz - n).
@@ -648,18 +650,18 @@
dstIndex := 1.
n timesRepeat:[
- skipIndex := self indexOfAny:elementsToSkip startingAt:srcIndex.
- l := skipIndex - srcIndex.
- l ~~ 0 ifTrue:[
- copy replaceFrom:dstIndex to:(dstIndex + l - 1)
- with:self startingAt:srcIndex.
- dstIndex := dstIndex + l
- ].
- srcIndex := skipIndex + 1
+ skipIndex := self indexOfAny:elementsToSkip startingAt:srcIndex.
+ l := skipIndex - srcIndex.
+ l ~~ 0 ifTrue:[
+ copy replaceFrom:dstIndex to:(dstIndex + l - 1)
+ with:self startingAt:srcIndex.
+ dstIndex := dstIndex + l
+ ].
+ srcIndex := skipIndex + 1
].
l := sz - srcIndex.
copy replaceFrom:dstIndex to:(dstIndex + l)
- with:self startingAt:srcIndex.
+ with:self startingAt:srcIndex.
^ copy
"
@@ -761,6 +763,7 @@
^ self replaceFrom:start to:stop with:anArray startingAt:repStart
! !
+
!SequenceableCollection methodsFor:'accessing'!
after:anObject
@@ -4041,7 +4044,7 @@
have been replaced by newElement."
"/ 'Warning: #copyReplaceAll:with: will change semantics as defined in ANSI soon' errorPrintCR.
- ^ self copy replaceAll:oldElement with:newElement
+ ^ (self copyFrom:1) replaceAll:oldElement with:newElement
"
#(1 2 1 2 1 2 1 2 1 2) copyReplaceAll:1 with:99
@@ -4107,7 +4110,7 @@
"return a copy of the receiver, where all elements equal to any in collectionOfOldElements
have been replaced by newElement."
- ^ self copy replaceAny:collectionOfOldElements with:newElement
+ ^ (self copyFrom:1) replaceAny:collectionOfOldElements with:newElement
"
#(1 2 3 1 2 3 1 2 3 4 1 2 3 1 2 3) copyReplaceAny:#(1 2) with:99
@@ -4123,7 +4126,7 @@
|newColl sz mySize replSize|
mySize := self size.
- startIndex > mySize ifTrue:[^ self copy].
+ startIndex > mySize ifTrue:[^ self copyFrom:1].
replSize := aCollection size.
sz := mySize - (endIndex - startIndex + 1) + replSize.
@@ -4153,7 +4156,7 @@
|newColl mySize|
mySize := self size.
- startIndex > mySize ifTrue:[^ self copy].
+ startIndex > mySize ifTrue:[^ self copyFrom:1].
newColl := self copyEmptyAndGrow:mySize.
newColl replaceFrom:1 to:(startIndex - 1) with:self.
@@ -4185,7 +4188,7 @@
have been replaced by newElement.
ANSI version of what used to be #copyReplaceAll:with:"
- ^ self copy replaceAll:oldElement with:newElement
+ ^ (self copyFrom:1) replaceAll:oldElement with:newElement
"
#(1 2 1 2 1 2 1 2 1 2) copyReplacing:1 withObject:99
@@ -4560,7 +4563,7 @@
|idx|
idx := self indexOf:element.
- idx == 0 ifTrue:[^ self copy]. "question: is this ok?"
+ idx == 0 ifTrue:[^ self copyFrom:1]. "question: is this ok?"
^ self copyFrom:1 to:idx
"
@@ -4582,7 +4585,7 @@
|idx|
idx := self indexOf:element.
- idx == 0 ifTrue:[^ self copy]. "question: is this ok?"
+ idx == 0 ifTrue:[^ self copyFrom:1]. "question: is this ok?"
idx == 1 ifTrue:[^ self copyEmpty].
^ self copyFrom:1 to:(idx-1)
@@ -4729,7 +4732,7 @@
around in big chunks"
n := self occurrencesOf:elementToSkip.
- n == 0 ifTrue:[^ self copy].
+ n == 0 ifTrue:[^ self copyFrom:1].
sz := self size.
copy := self copyEmptyAndGrow:(sz - n).
@@ -4738,18 +4741,18 @@
dstIndex := 1.
n timesRepeat:[
- skipIndex := self indexOf:elementToSkip startingAt:srcIndex.
- l := skipIndex - srcIndex.
- l ~~ 0 ifTrue:[
- copy replaceFrom:dstIndex to:(dstIndex + l - 1)
- with:self startingAt:srcIndex.
- dstIndex := dstIndex + l
- ].
- srcIndex := skipIndex + 1
+ skipIndex := self indexOf:elementToSkip startingAt:srcIndex.
+ l := skipIndex - srcIndex.
+ l ~~ 0 ifTrue:[
+ copy replaceFrom:dstIndex to:(dstIndex + l - 1)
+ with:self startingAt:srcIndex.
+ dstIndex := dstIndex + l
+ ].
+ srcIndex := skipIndex + 1
].
l := sz - srcIndex.
copy replaceFrom:dstIndex to:(dstIndex + l)
- with:self startingAt:srcIndex.
+ with:self startingAt:srcIndex.
^ copy
"
@@ -4774,7 +4777,7 @@
|copy skipIndex sz|
skipIndex := self indexOf:elementToSkip startingAt:1.
- (skipIndex == 0) ifTrue:[^ self copy].
+ (skipIndex == 0) ifTrue:[^ self copyFrom:1].
sz := self size - 1.
copy := self copyEmptyAndGrow:sz.
@@ -4807,7 +4810,7 @@
around in big chunks"
n := self count:[:el | el == elementToSkip].
- n == 0 ifTrue:[^ self copy].
+ n == 0 ifTrue:[^ self copyFrom:1].
sz := self size.
copy := self copyEmptyAndGrow:(sz - n).
@@ -4816,18 +4819,18 @@
dstIndex := 1.
n timesRepeat:[
- skipIndex := self identityIndexOf:elementToSkip startingAt:srcIndex.
- l := skipIndex - srcIndex.
- l ~~ 0 ifTrue:[
- copy replaceFrom:dstIndex to:(dstIndex + l - 1)
- with:self startingAt:srcIndex.
- dstIndex := dstIndex + l
- ].
- srcIndex := skipIndex + 1
+ skipIndex := self identityIndexOf:elementToSkip startingAt:srcIndex.
+ l := skipIndex - srcIndex.
+ l ~~ 0 ifTrue:[
+ copy replaceFrom:dstIndex to:(dstIndex + l - 1)
+ with:self startingAt:srcIndex.
+ dstIndex := dstIndex + l
+ ].
+ srcIndex := skipIndex + 1
].
l := sz - srcIndex.
copy replaceFrom:dstIndex to:(dstIndex + l)
- with:self startingAt:srcIndex.
+ with:self startingAt:srcIndex.
^ copy
"
@@ -4980,7 +4983,7 @@
|pos|
pos := self indexOf:anElement.
- pos == 0 ifTrue:[^ self copy].
+ pos == 0 ifTrue:[^ self copyFrom:1].
^ self copyFrom:1 to:(pos - 1)
@@ -5063,7 +5066,7 @@
|pos|
pos := self indexOfSubCollection:aSubCollection.
- pos == 0 ifTrue:[^ self copy].
+ pos == 0 ifTrue:[^ self copyFrom:1].
^ self copyFrom:1 to:(pos - 1)
@@ -5087,7 +5090,7 @@
|pos|
pos := self indexOfAny:aCollectionOfObjects.
- pos == 0 ifTrue:[^ self copy].
+ pos == 0 ifTrue:[^ self copyFrom:1].
^ self copyFrom:1 to:(pos - 1)
@@ -5107,7 +5110,7 @@
|pos|
pos := self findFirst:aBlock.
- pos == 0 ifTrue:[^ self copy].
+ pos == 0 ifTrue:[^ self copyFrom:1].
^ self copyFrom:1 to:(pos - 1)
@@ -9295,11 +9298,12 @@
reversed
"return a copy with elements in reverse order"
- ^ self copy reverse
-
- "
- #(4 5 6 7 7) reversed
+ ^ (self copyFrom:1) reverse
+
+ "
+ #(4 5 6 7 7) reversed
#(1 4 7 10 2 5) asOrderedCollection reversed
+ #foo reversed
"
!