Patrick Rein uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-pre.818.mcz ==================== Summary ==================== Name: Collections-pre.818 Author: pre Time: 25 January 2019, 5:54:07.601527 pm UUID: 75f53672-b087-3542-be05-41a072b91917 Ancestors: Collections-topa.806, Collections-mt.817 Adds a isOfSameSizeCheck: analogous to the emptyCheck to be used to check whether an argument has the same size as the receiver. =============== Diff against Collections-mt.817 =============== Item was added: + ----- Method: Collection>>errorDifferentSize (in category 'private') ----- + errorDifferentSize + + self error: 'otherCollection must be the same size'! Item was added: + ----- Method: Collection>>isOfSameSizeCheck: (in category 'private') ----- + isOfSameSizeCheck: otherCollection + + otherCollection size = self size ifFalse: [self errorDifferentSize]! Item was changed: ----- Method: FloatArray>>primAddArray: (in category 'primitives-plugin') ----- primAddArray: floatArray <primitive: 'primitiveAddFloatArray' module: 'FloatArrayPlugin'> + self isOfSameSizeCheck: floatArray. - self size = floatArray size ifFalse:[^self error:'Must be equal size']. 1 to: self size do:[:i| self at: i put: (self at: i) + (floatArray at: i)].! Item was changed: ----- Method: FloatArray>>primDivArray: (in category 'primitives-plugin') ----- primDivArray: floatArray <primitive: 'primitiveDivFloatArray' module: 'FloatArrayPlugin'> + self isOfSameSizeCheck: floatArray. - self size = floatArray size ifFalse:[^self error:'Must be equal size']. 1 to: self size do:[:i| self at: i put: (self at: i) / (floatArray at: i)].! Item was changed: ----- Method: FloatArray>>primMulArray: (in category 'primitives-plugin') ----- primMulArray: floatArray <primitive: 'primitiveMulFloatArray' module: 'FloatArrayPlugin'> + self isOfSameSizeCheck: floatArray. - self size = floatArray size ifFalse:[^self error:'Must be equal size']. 1 to: self size do:[:i| self at: i put: (self at: i) * (floatArray at: i)].! Item was changed: ----- Method: FloatArray>>primSubArray: (in category 'primitives-plugin') ----- primSubArray: floatArray <primitive: 'primitiveSubFloatArray' module: 'FloatArrayPlugin'> + self isOfSameSizeCheck: floatArray. - self size = floatArray size ifFalse:[^self error:'Must be equal size']. 1 to: self size do:[:i| self at: i put: (self at: i) - (floatArray at: i)].! Item was changed: ----- Method: SequenceableCollection>>with:collect: (in category 'enumerating') ----- with: otherCollection collect: twoArgBlock "Collect and return the result of evaluating twoArgBlock with corresponding elements from this collection and otherCollection." | result | + self isOfSameSizeCheck: otherCollection. - otherCollection size = self size ifFalse: [self error: 'otherCollection must be the same size']. result := self species new: self size. 1 to: self size do: [:index | result at: index put: (twoArgBlock value: (self at: index) value: (otherCollection at: index))]. ^ result! Item was changed: ----- Method: SequenceableCollection>>with:do: (in category 'enumerating') ----- with: otherCollection do: twoArgBlock "Evaluate twoArgBlock with corresponding elements from this collection and otherCollection." + self isOfSameSizeCheck: otherCollection. - otherCollection size = self size ifFalse: [self error: 'otherCollection must be the same size']. 1 to: self size do: [:index | twoArgBlock value: (self at: index) value: (otherCollection at: index)]! |
Free forum by Nabble | Edit this page |