LookupKey.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 19 Jan 2012 11:46:00 +0000
branchjv
changeset 17911 a99f15c5efa5
parent 17910 8d796ca8bd1d
child 17940 985e22966acb
permissions -rw-r--r--
Updated with /trunk
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
"
17865
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
    12
"{ Package: 'stx:libbasic' }"
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    13
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    14
Magnitude subclass:#LookupKey
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    15
	instanceVariableNames:'key'
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    16
	classVariableNames:''
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    17
	poolDictionaries:''
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    18
	category:'Collections-Support'
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    19
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    20
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    21
!LookupKey class methodsFor:'documentation'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    22
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    23
copyright
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    24
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    25
 COPYRIGHT (c) 1994 by Claus Gittinger
379
5b5a130ccd09 revision added
claus
parents: 157
diff changeset
    26
	      All Rights Reserved
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    27
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    28
 This software is furnished under a license and may be used
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    33
 hereby transferred.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    34
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    35
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    36
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    37
documentation
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    38
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    39
    LookupKey has been extracted from Association for ST-80 compatibility.
1761
8a42b8a58547 commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    40
    This class is currently not used directly.
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    41
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    42
    [Instance variables:]
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    43
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    44
        key             <Object>        the key
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    45
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    46
    [author:]
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 629
diff changeset
    47
        Claus Gittinger
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    48
"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    49
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    50
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    51
!LookupKey class methodsFor:'instance creation'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    52
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    53
key:aKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    54
    "return a new instance."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    55
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    56
    ^ self basicNew key:aKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    57
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    58
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    59
!LookupKey methodsFor:'accessing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    60
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    61
key
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    62
    "return the key of the receiver"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    63
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    64
    ^ key
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    65
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    66
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    67
key:anObject
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    68
    "set the key of the receiver to be anObject.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    69
     Return the receiver"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    70
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    71
    key := anObject
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    72
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    73
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    74
!LookupKey methodsFor:'comparing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    75
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    76
< aKey
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    77
    "return true, if the receivers KEY is less 
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    78
     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
    79
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    80
    ^ key < aKey key
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    81
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    82
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    83
= aLookupKey
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    84
    "return true if the receiver equals the argument.
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    85
     Notice, that in contrast to the less/greater compares,
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    86
     this compares both key AND value."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    87
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    88
    ^ (self species == aLookupKey species) and:[key = aLookupKey key]
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    89
!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    90
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    91
> aKey
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    92
    "return true, if the receivers KEY is greater 
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    93
     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
    94
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    95
    ^ key > aKey key
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    96
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    97
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    98
hash
1e3f01c45262 Initial revision
claus
parents:
diff changeset
    99
    "return an integer useful for hashing on the receiver;
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   100
     redefined since = is redefined here."
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   101
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   102
    ^ key hash
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   103
! !
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   104
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   105
!LookupKey methodsFor:'printing & storing'!
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   106
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   107
displayString
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   108
    "return a string containing a printable representation
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   109
     of the receiver for displaying - redefined to use display string on
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   110
     the components for nicer look"
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   111
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   112
    ^ self class name , '(' , key displayString , ')'
607
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
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   115
printOn:aStream
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   116
    "append a user printed representation of the receiver to aStream.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   117
     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
   118
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   119
    key printOn:aStream.
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   120
! !
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   121
17865
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   122
629
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   123
!LookupKey class methodsFor:'documentation'!
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   124
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   125
version
17892
d86c8bd5ece3 Merged with CVS
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17869
diff changeset
   126
    ^ '$Header: /cvs/stx/stx/libbasic/LookupKey.st,v 1.9 1999/07/15 19:44:33 cg Exp $'
17865
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   127
!
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   128
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   129
version_SVN
17911
a99f15c5efa5 Updated with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17910
diff changeset
   130
    ^ '$Id: LookupKey.st 10761 2012-01-19 11:46:00Z vranyj1 $'
17846
24edc476ac18 Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17845
diff changeset
   131
! !
17892
d86c8bd5ece3 Merged with CVS
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17869
diff changeset
   132
17910
8d796ca8bd1d Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17892
diff changeset
   133
17911
a99f15c5efa5 Updated with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17910
diff changeset
   134