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

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

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

Name: Collections-nice.634
Author: nice
Time: 6 May 2015, 11:08:55.927 pm
UUID: 4d2e458d-25c3-4b58-8df0-858fd2a6e84e
Ancestors: Collections-ul.633

Implement replace: in Dictionary

=============== Diff against Collections-ul.633 ===============

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) ] ] ]!