IdDict.st
author Claus Gittinger <cg@exept.de>
Fri, 19 Apr 1996 12:47:25 +0200
changeset 1221 46d72af387e9
parent 1126 497de696dff0
child 1256 249fd57abee5
permissions -rw-r--r--
commentary
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Dictionary subclass:#IdentityDictionary
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    14
	 instanceVariableNames:''
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    15
	 classVariableNames:''
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    16
	 poolDictionaries:''
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    17
	 category:'Collections-Unordered'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    20
!IdentityDictionary class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    21
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1992 by Claus Gittinger
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
    25
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    26
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    35
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
documentation
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    37
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    38
    same as a Dictionary but key must be identical - not just equal.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    39
    Since compare is on identical keys (using ==), hashing is also done via
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    40
    #identityHash instead of #hash.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    41
    IdentityDictionaries are especially useful, when symbols are used as keys.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    42
"
345
claus
parents: 175
diff changeset
    43
! !
claus
parents: 175
diff changeset
    44
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    45
!IdentityDictionary methodsFor:'private'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
345
claus
parents: 175
diff changeset
    47
compareSame:element1 with:element2
claus
parents: 175
diff changeset
    48
    ^ element1 == element2
claus
parents: 175
diff changeset
    49
!
claus
parents: 175
diff changeset
    50
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    51
emptyCollectionForKeys
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    52
    "return an empty collection used for keys.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    53
     Made a separate method to allow redefinition for different kind of
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    54
     containers in subclasses"
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    55
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    56
    ^ IdentitySet new:(self size)
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    57
!
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    58
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    59
find:key ifAbsent:aBlock
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    60
    "Look for the key in the receiver.  If it is found, return
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    61
     the index of the association containing the key, otherwise
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    62
     return the value of evaluating aBlock."
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    63
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    64
    |index  "{ Class:SmallInteger }"
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    65
     length "{ Class:SmallInteger }"
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    66
     startIndex
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    67
     probe|
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    68
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    69
    length := keyArray basicSize.
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    70
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    71
"/
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    72
"/    length < 10 ifTrue:[
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    73
"/	"assuming, that for small dictionaries the overhead of hashing
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    74
"/	 is large ... maybe that proves wrong (if overhead of comparing
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    75
"/	 is high)"
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    76
"/	^ keyArray identityIndexOf:key ifAbsent:aBlock.
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    77
"/    ].
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    78
"/
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    79
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    80
    index := key identityHash.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    81
    index := index \\ length + 1.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    82
    startIndex := index.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    83
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    84
    [true] whileTrue:[
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    85
	probe := keyArray basicAt:index.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    86
	probe == key ifTrue:[^ index].
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    87
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    88
	index == length ifTrue:[
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    89
	    index := 1
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    90
	] ifFalse:[
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    91
	    index := index + 1
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    92
	].
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    93
	(probe isNil or:[index == startIndex]) ifTrue:[^ aBlock value]
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    94
    ]
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    95
!
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
    96
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    97
findKeyOrNil:key
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    98
    "Look for the key in the receiver.  
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
    99
     If it is found, return return the index of the first unused slot. 
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   100
     Grow the receiver, if key was not found, and no unused slots were present"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   101
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
    |index  "{ Class:SmallInteger }"
375
claus
parents: 362
diff changeset
   103
     length "{ Class:SmallInteger }"
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   104
     startIndex probe 
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   105
     delIndex "{ Class:SmallInteger }" |
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   106
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   107
    delIndex := 0.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   108
a27a279701f8 Initial revision
claus
parents:
diff changeset
   109
    length := keyArray basicSize.
362
claus
parents: 345
diff changeset
   110
    index := key identityHash.
claus
parents: 345
diff changeset
   111
    index := index \\ length + 1.
claus
parents: 345
diff changeset
   112
    startIndex := index.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   113
a27a279701f8 Initial revision
claus
parents:
diff changeset
   114
    [true] whileTrue:[
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   115
	probe := keyArray basicAt:index.
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   116
	key == probe ifTrue:[^ index].
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   117
	probe isNil ifTrue:[
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   118
	    delIndex == 0 ifTrue:[^ index].
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   119
	    keyArray basicAt:delIndex put:nil.
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   120
	    ^ delIndex
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   121
	].
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   122
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   123
	probe == DeletedEntry ifTrue:[
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   124
	    delIndex == 0 ifTrue:[
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   125
		delIndex := index
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   126
	    ]
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   127
	].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   129
	index == length ifTrue:[
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   130
	    index := 1
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   131
	] ifFalse:[
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   132
	    index := index + 1
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   133
	].
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   134
	index == startIndex ifTrue:[
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   135
	    delIndex ~~ 0 ifTrue:[
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   136
		keyArray basicAt:delIndex put:nil.
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   137
		^ delIndex
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   138
	    ].
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   139
	    ^ self grow findKeyOrNil:key
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   140
	].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
    ]
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   142
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   143
    "Modified: 26.3.1996 / 20:00:44 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   146
findNil:key
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   147
    "Look for the next slot usable for key.  This method assumes that
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   148
     key is not already in the receiver - used only while growing/rehashing"
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   149
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   150
    |index  "{ Class:SmallInteger }"
375
claus
parents: 362
diff changeset
   151
     length "{ Class:SmallInteger }"|
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   152
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   153
    length := keyArray basicSize.
362
claus
parents: 345
diff changeset
   154
    index := key identityHash.
claus
parents: 345
diff changeset
   155
    index := index \\ length + 1.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   156
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   157
    [(keyArray basicAt:index) notNil] whileTrue:[
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   158
	index == length ifTrue:[
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   159
	    index := 1
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   160
	] ifFalse:[
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   161
	    index := index + 1
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   162
	].
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   163
	"notice: no check for no nil found - we must find one since
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   164
	 this is only called after growing"
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   165
    ].
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   166
    ^ index
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   167
! !
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   168
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   169
!IdentityDictionary methodsFor:'testing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   170
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   171
includesValue:aValue
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   172
    "return true, if the argument, aValue is stored in the dictionary,
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   173
     Redefined to use identity compare, NOT equality compare"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   174
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   175
    ^ (valueArray identityIndexOf:aValue) ~~ 0
77
6c38ca59927f *** empty log message ***
claus
parents: 39
diff changeset
   176
!
6c38ca59927f *** empty log message ***
claus
parents: 39
diff changeset
   177
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   178
occurrencesOf:anObject
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
    "count & return how often anObject is stored in the dictionary.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   180
     This counts values - not keys.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   181
     Redefined to use identity compare, NOT equality compare."
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   182
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   183
    |cnt|
175
82ba8d2e3569 *** empty log message ***
claus
parents: 92
diff changeset
   184
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   185
    cnt := 0.
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   186
    valueArray do:[:element |
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   187
       element == anObject ifTrue:[cnt := cnt + 1]
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   188
    ].
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   189
    ^ cnt
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   190
! !
609
12be97f6d5a7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   191
634
e15218d09420 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   192
!IdentityDictionary class methodsFor:'documentation'!
e15218d09420 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   193
e15218d09420 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   194
version
1126
497de696dff0 OOPS - could add elements twice after a remove (shame on me: how could that go unnoticed for so long ...)
Claus Gittinger <cg@exept.de>
parents: 634
diff changeset
   195
    ^ '$Header: /cvs/stx/stx/libbasic/Attic/IdDict.st,v 1.19 1996-03-26 20:45:04 cg Exp $'
634
e15218d09420 version at the end
Claus Gittinger <cg@exept.de>
parents: 609
diff changeset
   196
! !