--- a/OrderedCollection.st Thu May 12 09:30:28 2016 +0200
+++ b/OrderedCollection.st Fri May 13 20:17:32 2016 +0200
@@ -323,6 +323,7 @@
"
! !
+
!OrderedCollection methodsFor:'accessing'!
at:anInteger
@@ -1637,6 +1638,7 @@
! !
+
!OrderedCollection methodsFor:'private'!
initContents:size
@@ -1717,19 +1719,17 @@
|newContents
newSize "{ Class:SmallInteger }"
oldSize "{ Class:SmallInteger }"
- oneFourthOfSize "{ Class:SmallInteger }"
first "{ Class:SmallInteger }"
last "{ Class:SmallInteger }"
index "{ Class:SmallInteger }"
shiftLeft shiftRight|
oldSize := contentsArray size.
- oneFourthOfSize := oldSize // 4.
index := whereToMakeEmptySlot.
first := firstIndex.
last := lastIndex.
- ((first > 1) "and:[first > oneFourthOfSize]") ifTrue:[
+ (first > 1) ifTrue:[
"there is room at the beginning"
shiftLeft := true.
@@ -1742,14 +1742,14 @@
"/ copy the remaining elements. To copy the least possible number.
(last - index) < (index - first) ifTrue:[
- last < oldSize "(oneFourthOfSize * 3)" ifTrue:[
+ last < oldSize ifTrue:[
shiftLeft := false.
shiftRight := true.
]
]
]
] ifFalse:[
- last < oldSize "(oneFourthOfSize * 3)" ifTrue:[
+ last < oldSize ifTrue:[
shiftRight := true
]
].
@@ -1781,7 +1781,8 @@
^ index
].
- oldSize == 0 ifTrue:[
+ "/ no space at either end
+ oldSize < MinContentsArraySize ifTrue:[
newSize := MinContentsArraySize
] ifFalse:[
newSize := oldSize * 2.
@@ -1796,6 +1797,7 @@
firstIndex := lastIndex - (last - first).
] ifFalse:[
firstIndex := oldSize * 3 // 4.
+ firstIndex < 2 ifTrue:[firstIndex := 2]. "/ pathological case (was explicitly allocated with size<MinSize
lastIndex := firstIndex + (last - first).
].
newContents
@@ -1850,7 +1852,8 @@
shiftLeft shiftRight|
oldSize := contentsArray size.
- oneFourthOfSize := oldSize // 4.
+ oneFourthOfSize := (oldSize // 4).
+ oneFourthOfSize == 0 ifTrue:[oneFourthOfSize := 1].
index := whereToMakeEmptySlots.
first := firstIndex.
last := lastIndex.