[squeak-dev] The Inbox: Collections-nice.634.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 6 21:09:13 UTC 2015


Nicolas Cellier uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/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) ] ] ]!



More information about the Squeak-dev mailing list