The Trunk: Collections-klc.329.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-klc.329.mcz

commits-2
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-klc.329.mcz

==================== Summary ====================

Name: Collections-klc.329
Author: klc
Time: 7 March 2010, 6:51:24.486 pm
UUID: 0781052e-3725-47a4-abca-df8299e9bace
Ancestors: Collections-klc.328

Return both the minimum and maximum of the given collection in a single pass.

Better (certainly reads better) implementation from Randal Schwartz.

=============== Diff against Collections-ar.327 ===============

Item was added:
+ ----- Method: Collection>>minMax (in category 'math functions') -----
+ minMax
+ "Scans for minimum and maximum in one pass returning the results as a two-element array"
+ | min max |
+ min := max := self anyOne.
+ self do: [ :each |
+ min := min min: each.
+ max := max max: each ].
+ ^ Array with: min with: max!