LookupKey.st
author Claus Gittinger <cg@exept.de>
Fri, 06 Oct 2006 15:51:04 +0200
changeset 10050 ac9d34eeeaaa
parent 4392 26fb48f04e1b
child 14119 26e51066f338
child 17711 39faaaf888b4
permissions -rw-r--r--
classFilename handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     1
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 157
diff changeset
     3
	      All Rights Reserved
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     4
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1e3f01c45262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    11
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    12
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    13
Magnitude subclass:#LookupKey
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    14
	instanceVariableNames:'key'
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    15
	classVariableNames:''
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    16
	poolDictionaries:''
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    17
	category:'Collections-Support'
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    18
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    19
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    20
!LookupKey class methodsFor:'documentation'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    21
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    22
copyright
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    23
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 157
diff changeset
    25
	      All Rights Reserved
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    26
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    33
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    34
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    35
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    36
documentation
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    37
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    38
    LookupKey has been extracted from Association for ST-80 compatibility.
1761
8a42b8a58547 commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    39
    This class is currently not used directly.
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    40
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    41
    [Instance variables:]
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    42
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    43
        key             <Object>        the key
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    44
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    45
    [author:]
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    46
        Claus Gittinger
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    47
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    48
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    49
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    50
!LookupKey class methodsFor:'instance creation'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    51
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    52
key:aKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    53
    "return a new instance."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    54
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    55
    ^ self basicNew key:aKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    56
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    57
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    58
!LookupKey methodsFor:'accessing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    59
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    60
key
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    61
    "return the key of the receiver"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    62
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    63
    ^ key
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    64
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    65
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    66
key:anObject
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    67
    "set the key of the receiver to be anObject.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    68
     Return the receiver"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    69
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    70
    key := anObject
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    71
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    72
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    73
!LookupKey methodsFor:'comparing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    74
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    75
< aKey
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    76
    "return true, if the receivers KEY is less 
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    77
     than the arguments key. The argument must be a kind of lookupKey"
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    78
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    79
    ^ key < aKey key
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    80
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    81
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    82
= aLookupKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    83
    "return true if the receiver equals the argument.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    84
     Notice, that in contrast to the less/greater compares,
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    85
     this compares both key AND value."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    86
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    87
    ^ (self species == aLookupKey species) and:[key = aLookupKey key]
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    88
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    89
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    90
> aKey
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    91
    "return true, if the receivers KEY is greater 
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    92
     than the arguments key. The argument must be a kind of lookupKey"
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    93
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    94
    ^ key > aKey key
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    95
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    96
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    97
hash
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    98
    "return an integer useful for hashing on the receiver;
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    99
     redefined since = is redefined here."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   100
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   101
    ^ key hash
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   102
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   103
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   104
!LookupKey methodsFor:'printing & storing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   105
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   106
displayString
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   107
    "return a string containing a printable representation
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   108
     of the receiver for displaying - redefined to use display string on
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   109
     the components for nicer look"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   110
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   111
    ^ self class name , '(' , key displayString , ')'
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   112
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   113
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   114
printOn:aStream
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   115
    "append a user printed representation of the receiver to aStream.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   116
     The format is suitable for a human - not meant to be read back."
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   117
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   118
    key printOn:aStream.
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   119
! !
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   120
629
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   121
!LookupKey class methodsFor:'documentation'!
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   122
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   123
version
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   124
    ^ '$Header: /cvs/stx/stx/libbasic/LookupKey.st,v 1.9 1999-07-15 19:44:33 cg Exp $'
629
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   125
! !