Initial revision
authorclaus
Mon, 10 Oct 1994 01:26:32 +0100
changeset 157 1e3f01c45262
parent 156 f03b8fb5e778
child 158 be947d4e7fb2
Initial revision
LookupKey.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LookupKey.st	Mon Oct 10 01:26:32 1994 +0100
@@ -0,0 +1,129 @@
+"
+ COPYRIGHT (c) 1994 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.
+"
+
+Magnitude subclass:#LookupKey
+       instanceVariableNames:'key'
+       classVariableNames:''
+       poolDictionaries:''
+       category:'Collections-Support'
+!
+
+LookupKey comment:'
+COPYRIGHT (c) 1994 by Claus Gittinger
+              All Rights Reserved
+
+$Header: /cvs/stx/stx/libbasic/LookupKey.st,v 1.1 1994-10-10 00:26:32 claus Exp $
+'!
+
+!LookupKey class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1994 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.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libbasic/LookupKey.st,v 1.1 1994-10-10 00:26:32 claus Exp $
+"
+!
+
+documentation
+"
+    LookupKey has been extracted from Association for ST-80 compatibility.
+    They are currently not used directly.
+
+    Instance variables:
+
+        key             <Object>        the key
+"
+! !
+
+!LookupKey class methodsFor:'instance creation'!
+
+key:aKey
+    "return a new instance."
+
+    ^ self basicNew key:aKey
+! !
+
+!LookupKey methodsFor:'accessing'!
+
+key
+    "return the key of the receiver"
+
+    ^ key
+!
+
+key:anObject
+    "set the key of the receiver to be anObject.
+     Return the receiver"
+
+    key := anObject
+! !
+
+!LookupKey methodsFor:'comparing'!
+
+= aLookupKey
+    "return true if the receiver equals the argument.
+     Notice, that in contrast to the less/greater compares,
+     this compares both key AND value."
+
+    ^ (self species == aLookupKey species) and:[key = aLookupKey key]
+!
+
+hash
+    "return an integer useful for hashing on the receiver;
+     redefined since = is redefined here."
+
+    ^ key hash
+!
+
+< aKey
+    "return true, if the receivers KEY is less 
+     than the arguments key. The argument must be a kind of lookupKey"
+
+    ^ key < aKey key
+!
+
+> aKey
+    "return true, if the receivers KEY is greater 
+     than the arguments key. The argument must be a kind of lookupKey"
+
+    ^ key > aKey key
+! !
+
+!LookupKey methodsFor:'printing & storing'!
+
+printOn:aStream
+    "return a string containing a printable representation
+     of the receiver"
+
+    key printOn:aStream.
+!
+
+displayString
+    "return a string containing a printable representation
+     of the receiver for displaying - redefined to use display string on
+     the components for nicer look"
+
+    ^ self class name , '(' , key displayString , ')'
+! !