LookupKey.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 May 2012 22:58:24 +0100
branchjv
changeset 17940 985e22966acb
parent 17911 a99f15c5efa5
child 18011 deb0c3355881
permissions -rw-r--r--
Merged 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
17940
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   107
displayOn:aGCOrStream
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   108
    "Compatibility
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   109
     append a printed desription on some stream (Dolphin,  Squeak)
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   110
     OR:
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   111
     display the receiver in a graphicsContext at 0@0 (ST80).
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   112
     This method allows for any object to be displayed in some view
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   113
     (although the fallBack is to display its printString ...)"
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   114
17940
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   115
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   116
    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   117
    (aGCOrStream isStream and:[aGCOrStream ~~ Transcript]) ifFalse:[
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   118
        ^ super displayOn:aGCOrStream
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   119
    ].
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   120
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   121
    aGCOrStream 
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   122
        nextPutAll:self className; 
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   123
        nextPut:$(.
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   124
    key displayOn:aGCOrStream.
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   125
    aGCOrStream nextPut:$)
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   126
!
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   127
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   128
printOn:aStream
4392
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   129
    "append a user printed representation of the receiver to aStream.
26fb48f04e1b comment
Claus Gittinger <cg@exept.de>
parents: 1761
diff changeset
   130
     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
   131
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   132
    key printOn:aStream.
157
1e3f01c45262 Initial revision
claus
parents:
diff changeset
   133
! !
607
a9a526c51233 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   134
17865
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   135
629
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   136
!LookupKey class methodsFor:'documentation'!
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   137
2ceefe9b5a19 version at the end
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
   138
version
17940
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   139
    ^ '$Header: /cvs/stx/stx/libbasic/LookupKey.st,v 1.10 2012/04/24 12:01:05 stefan Exp $'
17865
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   140
!
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   141
598963c6ff8e Recommited from itself
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17846
diff changeset
   142
version_SVN
17940
985e22966acb Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17911
diff changeset
   143
    ^ '$Id: LookupKey.st 10807 2012-05-05 21:58:24Z vranyj1 $'
17846
24edc476ac18 Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17845
diff changeset
   144
! !
17892
d86c8bd5ece3 Merged with CVS
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17869
diff changeset
   145
17910
8d796ca8bd1d Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17892
diff changeset
   146
17911
a99f15c5efa5 Updated with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17910
diff changeset
   147