[squeak-dev] The Trunk: Collections-ul.668.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Oct 13 00:02:40 UTC 2015


Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.668.mcz

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

Name: Collections-ul.668
Author: ul
Time: 13 October 2015, 1:07:48.216 am
UUID: 8abfa05a-70c6-4e38-bc00-7d665183106c
Ancestors: Collections-ul.667

In Dictionary >> #=, make sure that the dictionaries agree on what the common keys are. This way the behaviour of #= will be symmetric when the two dictionaries implement key equality differently.

=============== Diff against Collections-ul.667 ===============

Item was changed:
  ----- Method: Dictionary>>= (in category 'comparing') -----
+ = anObject
- = aDictionary
  	"Two dictionaries are equal if
  	 (a) they are the same 'kind' of thing.
  	 (b) they have the same set of keys.
  	 (c) for each (common) key, they have the same value"
  
+ 	self == anObject ifTrue: [ ^true ].
+ 	anObject isDictionary ifFalse: [ ^false ].
+ 	self size = anObject size ifFalse: [ ^false ].
+ 	self associationsDo: [ :association |
+ 		(anObject at: association key ifAbsent: [ ^false ]) = association value
+ 			ifFalse: [ ^false ] ].
+ 	"The two dictionaries may have different ideas about equal keys, so check both ways to avoid any inconsistency."
+ 	anObject associationsDo: [ :association |
+ 		(self at: association key ifAbsent: [ ^false ]) = association value 
+ 			ifFalse:  [ ^false ] ].
+ 	^true!
- 	self == aDictionary ifTrue: [ ^ true ].
- 	aDictionary isDictionary ifFalse: [^false].
- 	self size = aDictionary size ifFalse: [^false].
- 	self associationsDo: [:assoc|
- 		(aDictionary at: assoc key ifAbsent: [^false]) = assoc value
- 			ifFalse: [^false]].
- 	^true
- 
- !



More information about the Squeak-dev mailing list