Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.348.mcz ==================== Summary ==================== Name: Collections-nice.348 Author: nice Time: 26 March 2010, 9:03:00.205 pm UUID: 7b1df1f0-43d8-4731-8c1b-081b4cf85df9 Ancestors: Collections-ar.347 1) Fix a few _ assignments 2) implement #errorCantGoBack http://bugs.squeak.org/view.php?id=7483 =============== Diff against Collections-ar.347 =============== Item was changed: ----- Method: RFC2047MimeConverter>>mimeDecode (in category 'conversion') ----- mimeDecode "Do conversion reading from mimeStream writing to dataStream. See String>>decodeMimeHeader" | c | [mimeStream atEnd] whileFalse: [ + c := mimeStream next. - c _ mimeStream next. c = $= + ifTrue: [c := Character value: mimeStream next digitValue * 16 - ifTrue: [c _ Character value: mimeStream next digitValue * 16 + mimeStream next digitValue] + ifFalse: [c = $_ ifTrue: [c := $ ]]. - ifFalse: [c = $_ ifTrue: [c _ $ ]]. dataStream nextPut: c]. ^ dataStream! Item was changed: ----- Method: IntegerArray>>atAllPut: (in category 'accessing') ----- atAllPut: anInteger | word | anInteger < 0 ifTrue:[anInteger < -16r80000000 ifTrue: [self error: anInteger asString , ' out of range']. + "word := 16r100000000 + anInteger" - "word _ 16r100000000 + anInteger" word := (anInteger + 1) negated bitInvert32] ifFalse:[anInteger > 16r7FFFFFFF ifTrue: [self error: anInteger asString , ' out of range']. word := anInteger]. self primFill: word.! Item was changed: Set subclass: #PluggableSet instanceVariableNames: 'hashBlock equalBlock' classVariableNames: '' poolDictionaries: '' category: 'Collections-Unordered'! + !PluggableSet commentStamp: 'nice 3/25/2010 23:02' prior: 0! - !PluggableSet commentStamp: '<historical>' prior: 0! PluggableSets allow the redefinition of hashing and equality by clients. This is in particular useful if the clients know about specific properties of the objects stored in the set which in turn can heavily improve the performance of sets and dictionaries. Instance variables: hashBlock <BlockContext> A one argument block used for hashing the elements. equalBlock <BlockContext> A two argument block used for comparing the elements. Example: Adding 1000 integer points in the range (0@0) to: (100@100) to a set. | rnd set max pt | + set := Set new: 1000. + rnd := Random new. + max := 100. - set _ Set new: 1000. - rnd _ Random new. - max _ 100. Time millisecondsToRun:[ 1 to: 1000 do:[:i| + pt := (rnd next * max) truncated @ (rnd next * max) truncated. - pt _ (rnd next * max) truncated @ (rnd next * max) truncated. set add: pt. ]. ]. The above is way slow since the default hashing function of points leads to an awful lot of collisions in the set. And now the same, with a somewhat different hash function: | rnd set max pt | + set := PluggableSet new: 1000. - set _ PluggableSet new: 1000. set hashBlock:[:item| (item x bitShift: 16) + item y]. + rnd := Random new. + max := 100. - rnd _ Random new. - max _ 100. Time millisecondsToRun:[ 1 to: 1000 do:[:i| + pt := (rnd next * max) truncated @ (rnd next * max) truncated. - pt _ (rnd next * max) truncated @ (rnd next * max) truncated. set add: pt. ]. ]. ! Item was added: + ----- Method: PositionableStream>>errorCantGoBack (in category 'accessing') ----- + errorCantGoBack + self error: ' CantGoBack '! Item was changed: ----- Method: IntegerArray>>at:put: (in category 'accessing') ----- at: index put: anInteger | word | <primitive: 166> anInteger < 0 ifTrue:[anInteger < -16r80000000 ifTrue: [self error: anInteger asString , ' out of range']. + "word := 16r100000000 + anInteger" - "word _ 16r100000000 + anInteger" word := (anInteger + 1) negated bitInvert32] ifFalse:[anInteger > 16r7FFFFFFF ifTrue: [self error: anInteger asString , ' out of range']. word := anInteger]. self basicAt: index put: word. ^anInteger! |
Free forum by Nabble | Edit this page |