diff -r aa2498ef6470 -r a27a279701f8 Assoc.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assoc.st Fri Jul 16 11:39:45 1993 +0200 @@ -0,0 +1,112 @@ +" + COPYRIGHT (c) 1989-93 by Claus Gittinger + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" + +Object subclass:#Association + instanceVariableNames:'key value' + classVariableNames:'' + poolDictionaries:'' + category:'Collections-Support' +! + +Association comment:' + +COPYRIGHT (c) 1989-93 by Claus Gittinger + All Rights Reserved + +Associations are a key-value pair; they are the elements of Dictionaries - +storing value under the key. By itself, an Association is not very +useful. + +Instance variables: + +key the key +value the value + +%W% %E% +'! + +!Association class methodsFor:'instance creation'! + +key:aKey + "return a new Association." + + ^ self basicNew key:aKey +! + +key:aKey value:aValue + "return a new Association" + + ^ self basicNew key:aKey value:aValue +! ! + +!Association methodsFor:'accessing'! + +key + "return the key of the association" + + ^ key +! + +key:anObject + "set the key of the receiver to be anObject. + Return the receiver" + + key := anObject +! + +value + "return the value of the association" + + ^ value +! + +value:anObject + "set the value of the receiver to be anObject. + Return the receiver" + + value := anObject +! + +key:aKey value:aValue + "set both the key and value of the receiver. + Return the receiver" + + key := aKey. + value := aValue +! ! + +!Association methodsFor:'comparing'! + += anAssociation + (anAssociation isKindOf:Association) ifTrue:[ + (anAssociation key = key) ifTrue:[ + ^ anAssociation value = value + ] + ]. + ^ false +! ! + +!Association methodsFor:'printing & storing'! + +printString + "return a string containing a printable representation + of the receiver" + + ^ key printString , '->' , value printString +! + +displayString + "return a string containing a printable representation + of the receiver for displaying" + + ^ key displayString , '->' , value displayString +! !