IdentityDictionary.st
branchjv
changeset 20244 20922299fd44
parent 20131 4118d61ddba0
parent 20233 2c51422816be
equal deleted inserted replaced
20229:b5cdb27022c8 20244:20922299fd44
   108         ].
   108         ].
   109         index == startIndex ifTrue:[^ aBlock value]
   109         index == startIndex ifTrue:[^ aBlock value]
   110     ] loop.
   110     ] loop.
   111 !
   111 !
   112 
   112 
       
   113 findIdentical:key ifAbsent:aBlock
       
   114     "IdentityDictionary does identity compare anyway..."
       
   115 
       
   116     ^ self find:key ifAbsent:aBlock
       
   117 !
       
   118 
   113 findKeyOrNil:key
   119 findKeyOrNil:key
   114     "Look for the key in the receiver.  
   120     "Look for the key in the receiver.  
   115      If it is found, return the index of the first unused slot. 
   121      If it is found, return the index of the first unused slot. 
   116      Grow the receiver, if key was not found, and no unused slots were present
   122      Grow the receiver, if key was not found, and no unused slots were present
   117 
   123 
   158     ] loop.
   164     ] loop.
   159 
   165 
   160     "Modified: 26.3.1996 / 20:00:44 / cg"
   166     "Modified: 26.3.1996 / 20:00:44 / cg"
   161 !
   167 !
   162 
   168 
       
   169 findKeyOrNilOrDeletedEntry:key
       
   170     "Look for the key in the receiver.  
       
   171      If it is found, return the index of the first unused slot. 
       
   172      Grow the receiver, if key was not found, and no unused slots were present."
       
   173 
       
   174     |index  "{ Class:SmallInteger }"
       
   175      length "{ Class:SmallInteger }"
       
   176      startIndex probe 
       
   177      delIndex "{ Class:SmallInteger }"|
       
   178 
       
   179     delIndex := 0.
       
   180 
       
   181     length := keyArray basicSize.
       
   182     startIndex := index := self initialIndexForKey:key.
       
   183 
       
   184     [
       
   185         probe := keyArray basicAt:index.
       
   186         key == probe ifTrue:[^ index].              "<--- == is different from inherited"   
       
   187         probe isNil ifTrue:[
       
   188             delIndex == 0 ifTrue:[^ index].
       
   189             ^ delIndex
       
   190         ].
       
   191 
       
   192         (delIndex == 0 and:[probe == DeletedEntry]) ifTrue:[
       
   193             delIndex := index
       
   194         ].
       
   195 
       
   196         index == length ifTrue:[
       
   197             index := 1
       
   198         ] ifFalse:[
       
   199             index := index + 1
       
   200         ].
       
   201         index == startIndex ifTrue:[
       
   202             delIndex ~~ 0 ifTrue:[
       
   203                 ^ delIndex
       
   204             ].
       
   205             self grow.
       
   206             length := keyArray basicSize.
       
   207             startIndex := index := self initialIndexForKey:key.
       
   208         ].
       
   209     ] loop.
       
   210 
       
   211     "Modified: 26.3.1996 / 20:00:44 / cg"
       
   212 !
       
   213 
   163 hashFor:aKey
   214 hashFor:aKey
   164     "return an initial index given a key."
   215     "return an initial index given a key."
   165 
   216 
   166     ^ aKey identityHash
   217     ^ aKey identityHash
   167 
   218 
   196 
   247 
   197 !IdentityDictionary class methodsFor:'documentation'!
   248 !IdentityDictionary class methodsFor:'documentation'!
   198 
   249 
   199 version
   250 version
   200     ^ '$Header$'
   251     ^ '$Header$'
   201 ! !
   252 !
   202 
   253 
       
   254 version_CVS
       
   255     ^ '$Header$'
       
   256 ! !
       
   257