[squeak-dev] The Trunk: Collections-eem.913.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Oct 1 23:19:56 UTC 2020
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.913.mcz
==================== Summary ====================
Name: Collections-eem.913
Author: eem
Time: 1 October 2020, 4:19:52.930593 pm
UUID: fb7fd4f9-a89f-4a71-8807-66b7d9861f06
Ancestors: Collections-eem.912
Move arrayType to the instance side where it matches associationClass, and where it is more convenient for everything except arguably OrderedCollection. Have OrderedCollection compensate very simply.
=============== Diff against Collections-eem.912 ===============
Item was removed:
- ----- Method: FloatCollection class>>arrayType (in category 'private') -----
- arrayType
- ^ Float32Array!
Item was added:
+ ----- Method: FloatCollection>>arrayType (in category 'private') -----
+ arrayType
+ ^ Float32Array!
Item was removed:
- ----- Method: HashedCollection class>>arrayType (in category 'private') -----
- arrayType
- ^ Array!
Item was added:
+ ----- Method: HashedCollection>>arrayType (in category 'private') -----
+ arrayType
+ ^ Array!
Item was changed:
----- Method: HashedCollection>>growTo: (in category 'private') -----
growTo: anInteger
"Grow the elements array and reinsert the old elements"
| oldElements |
oldElements := array.
+ array := self arrayType new: anInteger.
- array := self class arrayType new: anInteger.
self noCheckNoGrowFillFrom: oldElements!
Item was changed:
----- Method: HashedCollection>>initialize: (in category 'private') -----
initialize: n
"Initialize array to an array size of n"
+ array := self arrayType new: n.
- array := self class arrayType new: n.
tally := 0!
Item was removed:
- ----- Method: NonPointersOrderedCollection class>>arrayType (in category 'private') -----
- arrayType
- "This method must return a non-pointers array class."
-
- self subclassResponsibility!
Item was added:
+ ----- Method: NonPointersOrderedCollection>>arrayType (in category 'private') -----
+ arrayType
+ "This method must return a non-pointers array class."
+
+ self subclassResponsibility!
Item was removed:
- ----- Method: OrderedCollection class>>arrayType (in category 'private') -----
- arrayType
- ^ Array!
Item was changed:
----- Method: OrderedCollection class>>new: (in category 'instance creation') -----
new: anInteger
+ | instance |
+ ^(instance := self basicNew) setCollection: (instance arrayType new: anInteger)!
- ^ self basicNew setCollection: (self arrayType new: anInteger)!
Item was changed:
----- Method: OrderedCollection class>>new:withAll: (in category 'instance creation') -----
new: anInteger withAll: anObject
+ | instance |
+ ^(instance := self basicNew) setContents: (instance arrayType new: anInteger withAll: anObject)!
- ^ self basicNew setContents: (self arrayType new: anInteger withAll: anObject)!
Item was added:
+ ----- Method: OrderedCollection>>arrayType (in category 'private') -----
+ arrayType
+ ^ Array!
Item was changed:
----- Method: OrderedCollection>>growAtFirst (in category 'private') -----
growAtFirst
"Add new empty slots to the front of array, while keeping the empty slots at the end."
| newArray newFirstIndex newLastIndex |
+ newArray := self arrayType new: (array size * 2 max: 1).
- newArray := self class arrayType new: (array size * 2 max: 1).
newFirstIndex := newArray size - array size + firstIndex.
newLastIndex := newFirstIndex + lastIndex - firstIndex.
newArray
replaceFrom: newFirstIndex
to: newLastIndex
with: array
startingAt: firstIndex.
array := newArray.
firstIndex := newFirstIndex.
lastIndex := newLastIndex!
Item was changed:
----- Method: OrderedCollection>>growAtLast (in category 'private') -----
growAtLast
"Add new empty slots to the end of array, while keeping the empty slots at the front."
| newArray |
+ newArray := self arrayType new: (array size * 2 max: 1).
- newArray := self class arrayType new: (array size * 2 max: 1).
newArray
replaceFrom: firstIndex
to: lastIndex
with: array
startingAt: firstIndex.
array := newArray!
Item was changed:
----- Method: OrderedCollection>>removeAll (in category 'removing') -----
removeAll
"remove all the elements from this collection.
Keep same amount of storage"
+ self setCollection: (self arrayType new: array size)!
- self setCollection: (self class arrayType new: array size)!
Item was changed:
----- Method: OrderedDictionary>>growTo: (in category 'private') -----
growTo: anInteger
| oldOrder |
super growTo: anInteger.
oldOrder := order.
"Grow only to 75%. See #atNewIndex:put: in HashedCollection."
+ order := self arrayType new: anInteger + 1 * 3 // 4.
- order := self class arrayType new: anInteger + 1 * 3 // 4.
order
replaceFrom: 1
to: tally
with: oldOrder
startingAt: 1!
Item was changed:
----- Method: OrderedDictionary>>initialize: (in category 'private') -----
initialize: n
super initialize: n.
+ order := self arrayType new: n + 1 * 3 // 4!
- order := self class arrayType new: n + 1 * 3 // 4!
Item was changed:
----- Method: OrderedDictionary>>postCopyFrom:to: (in category 'copying') -----
postCopyFrom: startIndex to: endIndex
"Adapted from SequenceableCollection and OrderedCollection."
| oldOrder |
oldOrder := order.
+ array := self arrayType
- array := self class arrayType
new: (self class goodPrimeAtLeast: endIndex - startIndex + 1 * 4 // 3). "fill 75% to 100%"
+ order := self arrayType
- order := self class arrayType
new: array size + 1 * 3 // 4. "remove 25%"
startIndex to: endIndex do: [:index | | element |
element := (oldOrder at: index) copy.
order at: index - startIndex + 1 put: element.
array at: (self scanFor: element key) put: element].
+ tally := endIndex - startIndex + 1!
- tally := endIndex - startIndex + 1.!
Item was added:
+ ----- Method: ReadStream>>contentsFrom:to: (in category 'accessing') -----
+ contentsFrom: startIndex to: stopIndex
+ "Answer with a copy of my collection from startIndex to stopIndex."
+
+ ^collection copyFrom: (initialPositionOrNil ifNil: [1]) + startIndex - 1 to: ((initialPositionOrNil ifNil: [1]) + stopIndex - 1 min: readLimit)!
Item was removed:
- ----- Method: WeakIdentityDictionary class>>arrayType (in category 'private') -----
- arrayType
- ^ WeakArray!
Item was added:
+ ----- Method: WeakIdentityDictionary>>arrayType (in category 'private') -----
+ arrayType
+ ^ WeakArray!
Item was changed:
----- Method: WeakIdentityDictionary>>growTo: (in category 'private') -----
growTo: anInteger
"Grow the elements array and reinsert the old elements"
| oldElements |
oldElements := array.
+ array := self arrayType new: anInteger withAll: vacuum.
- array := self class arrayType new: anInteger withAll: vacuum.
self noCheckNoGrowFillFrom: oldElements!
Item was changed:
----- Method: WeakIdentityDictionary>>initialize: (in category 'private') -----
initialize: n
vacuum := Object new.
+ array := self arrayType new: n withAll: vacuum.
- array := self class arrayType new: n withAll: vacuum.
tally := 0!
Item was removed:
- ----- Method: WeakOrderedCollection class>>arrayType (in category 'private') -----
- arrayType
- ^ WeakArray!
Item was added:
+ ----- Method: WeakOrderedCollection>>arrayType (in category 'private') -----
+ arrayType
+ ^ WeakArray!
Item was removed:
- ----- Method: WeakSet class>>arrayType (in category 'private') -----
- arrayType
-
- ^WeakArray!
Item was added:
+ ----- Method: WeakSet>>arrayType (in category 'private') -----
+ arrayType
+
+ ^WeakArray!
Item was changed:
----- Method: WeakSet>>growTo: (in category 'private') -----
growTo: anInteger
"Grow the elements array and reinsert the old elements"
| oldElements |
oldElements := array.
+ array := self arrayType new: anInteger withAll: flag.
- array := self class arrayType new: anInteger withAll: flag.
self noCheckNoGrowFillFrom: oldElements!
More information about the Squeak-dev
mailing list
|