Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.277.mcz==================== Summary ====================
Name: Collections-ul.277
Author: ul
Time: 11 January 2010, 8:14:18.037 am
UUID: 9866315b-49ee-0442-93e1-12f448adafb6
Ancestors: Collections-dtl.276
- code critics
=============== Diff against Collections-dtl.276 ===============
Item was changed:
----- Method: Collection>>groupBy:having: (in category 'enumerating') -----
groupBy: keyBlock having: selectBlock
"Like in SQL operation - Split the recievers contents into collections of
elements for which keyBlock returns the same results, and return those
collections allowed by selectBlock. keyBlock should return an Integer."
| result |
result := PluggableDictionary integerDictionary.
self do:
[:e |
| key |
key := keyBlock value: e.
(result includesKey: key)
ifFalse: [result at: key put: OrderedCollection new].
(result at: key)
add: e].
+ ^result select: selectBlock!
- ^ result := result select: selectBlock!