[squeak-dev] The Trunk: Collections-eem.656.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Sep 25 18:37:09 UTC 2015
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.656.mcz
==================== Summary ====================
Name: Collections-eem.656
Author: eem
Time: 25 September 2015, 11:36:48.911 am
UUID: 50ec1b3e-c058-4167-889e-836e994b500b
Ancestors: Collections-ul.655
Add Dictionary>>at:ifPresent:ifAbsentPut:.
Move Dictionary>>fasterKeys & keyForIdentity: to 50Deprecated
=============== Diff against Collections-ul.655 ===============
Item was added:
+ ----- Method: Dictionary>>at:ifPresent:ifAbsentPut: (in category 'accessing') -----
+ at: key ifPresent: oneArgBlock ifAbsentPut: absentBlock
+ "Lookup the given key in the receiver. If it is present, answer the value of
+ evaluating oneArgBlock with the value associated with the key. Otherwise
+ add the value of absentBlock under the key, and answer that value."
+
+ | index value |
+ index := self scanFor: key.
+ (array at: index) ifNotNil:
+ [:element|
+ ^oneArgBlock value: element value].
+ value := absentBlock value.
+ self atNewIndex: index put: (Association key: key value: value).
+ ^value!
Item was removed:
- ----- Method: Dictionary>>fasterKeys (in category 'accessing') -----
- fasterKeys
- "Contrary to old version of #keys, this method returned an Array rather than a Set.
- This was faster because no lookup: was performed.
- But now, #keys also return an Array, so don't use #fasterKeys anymore."
-
- self deprecated: 'use #keys'.
-
- ^self keys.
- !
Item was removed:
- ----- Method: Dictionary>>keyForIdentity: (in category 'accessing') -----
- keyForIdentity: anObject
- "If anObject is one of the values of the receive, return its key, else return nil. Contrast #keyAtValue: in which there is only an equality check, here there is an identity check"
-
- self deprecated: 'Use #keyAtIdentityValue:ifAbsent:'.
- ^self keyAtIdentityValue: anObject ifAbsent: nil!
More information about the Squeak-dev
mailing list
|