Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.669.mcz ==================== Summary ==================== Name: Collections-ul.669 Author: ul Time: 2 November 2015, 2:00:09.732 am UUID: 01e30af9-3dd4-4b5e-ab40-89ce43884565 Ancestors: Collections-ul.668 Changed Set >> #= and Dictionary >> #= to check the species of the receiver and the argument. PluggableDictionary and PluggableSet also check hashBlock and equalBlock. WeakSet and friends will work once we start using ephemerons. =============== Diff against Collections-ul.668 =============== Item was changed: ----- Method: Dictionary>>= (in category 'comparing') ----- = anObject "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 ]. + self species == anObject species ifFalse: [ ^false ]. - 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! Item was added: + ----- Method: PluggableDictionary>>= (in category 'comparing') ----- + = anObject + "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 ]. + self species == anObject species ifFalse: [ ^false ]. + hashBlock = anObject hashBlock ifFalse: [ ^false ]. + equalBlock = anObject equalBlock ifFalse: [ ^false ]. + self size = anObject size ifFalse: [ ^false ]. + self associationsDo: [ :association | + (anObject at: association key ifAbsent: [ ^false ]) = association value + ifFalse: [ ^false ] ]. + ^true! Item was added: + ----- Method: PluggableSet>>= (in category 'as yet unclassified') ----- + = anObject + "Two sets 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 ]. + self species == anObject species ifFalse: [ ^false ]. + hashBlock = anObject hashBlock ifFalse: [ ^false ]. + equalBlock = anObject equalBlock ifFalse: [ ^false ]. + self size = anObject size ifFalse: [ ^false ]. + ^self allSatisfy: [ :each | anObject includes: each ]! Item was changed: ----- Method: Set>>= (in category 'comparing') ----- + = anObject + "Two sets 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 ]. + self species == anObject species ifFalse: [ ^false ]. + self size = anObject size ifFalse: [ ^false ]. + ^self allSatisfy: [ :each | anObject includes: each ]! - = aSet - self == aSet ifTrue: [^ true]. "stop recursion" - (aSet isKindOf: Set) ifFalse: [^ false]. - self size = aSet size ifFalse: [^ false]. - self do: [:each | (aSet includes: each) ifFalse: [^ false]]. - ^ true! |
Free forum by Nabble | Edit this page |