The Trunk: Collections-nice.928.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-nice.928.mcz

commits-2
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.928.mcz

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

Name: Collections-nice.928
Author: nice
Time: 3 March 2021, 3:29:05.70662 pm
UUID: ef9658c8-ef7e-a943-8ffc-de7546b29f2f
Ancestors: Collections-nice.927, Collections-nice.634

Merge Collections-nice.634 (Implement replace: in Dictionary)

=============== Diff against Collections-nice.927 ===============

Item was added:
+ ----- Method: Dictionary>>replace: (in category 'enumerating') -----
+ replace: aBlock
+ "Destructively replace the values in this Dictionary by applying aBlock, keeping the same keys.
+ Implementation note: subclasses not storing the key-value pairs as a list of Associations shall refine this method."
+ tally = 0 ifTrue: [ ^self].
+ 1 to: array size do: [ :index |
+ (array at: index) ifNotNil: [ :element |
+ element value: (aBlock value: element value) ] ]!

Item was added:
+ ----- Method: OrderedDictionary>>replace: (in category 'enumerating') -----
+ replace: aBlock
+ "Like super, but iterate in order."
+
+ order from: 1 to: tally do: [:each | each value: (aBlock value: each value)]!

Item was added:
+ ----- Method: WeakKeyDictionary>>replace: (in category 'enumerating') -----
+ replace: aBlock
+ "Like super except that aBlock shouldn't be invoked for any reclaimed (nil) key."
+
+ tally = 0 ifTrue: [ ^self].
+ 1 to: array size do: [ :index |
+ (array at: index) ifNotNil: [ :association |
+ association key ifNotNil: [ :key | "Don't let the key go away."
+ association value: (aBlock value: association value) ] ] ]!