CacheDictionary.st
changeset 4843 49f5a601dee9
parent 4674 519d0604d2bc
equal deleted inserted replaced
4842:6926d1490469 4843:49f5a601dee9
   127         ].
   127         ].
   128     ] loop.
   128     ] loop.
   129 
   129 
   130     "Modified: / 01-03-1997 / 00:59:55 / cg"
   130     "Modified: / 01-03-1997 / 00:59:55 / cg"
   131     "Modified (format): / 26-12-2011 / 10:42:08 / cg"
   131     "Modified (format): / 26-12-2011 / 10:42:08 / cg"
       
   132     "Modified: / 15-03-2019 / 15:27:16 / Stefan Vogel"
   132 !
   133 !
   133 
   134 
   134 findKeyOrNilOrDeletedEntry:key  
   135 findKeyOrNilOrDeletedEntry:key  
   135     "Look for the key in the receiver.  If it is found, return
   136     "Look for the key in the receiver.  If it is found, return
   136      the index of the association containing the key, otherwise
   137      the index of the association containing the key, otherwise
   164         index := index + 1.
   165         index := index + 1.
   165         index > length ifTrue:[
   166         index > length ifTrue:[
   166             index := 1.
   167             index := 1.
   167         ].
   168         ].
   168         index == startIndex ifTrue:[
   169         index == startIndex ifTrue:[
   169             "/ mhmh - actually, a kind of round-robin would be better
   170             "/ cache is full;
       
   171             "/ replace the slot at the original startIndex (the H(key))
       
   172             "/ 
       
   173             "/ mhmh - a kind of round-robin might be better - this will always
       
   174             "/ remove the first key with this H(key)
   170             delIndex == 0 ifTrue:[
   175             delIndex == 0 ifTrue:[
   171                 delIndex := startIndex.
   176                 delIndex := startIndex.
   172                 tally := tally - 1.
   177                 tally := tally - 1.
   173             ].
   178             ].
   174 
   179 
   175             valueArray basicAt:delIndex put:DeletedEntry.
   180             keyArray basicAt:delIndex put:DeletedEntry.
   176             valueArray basicAt:delIndex put:nil.
   181             valueArray basicAt:delIndex put:nil.
   177             ^ delIndex
   182             ^ delIndex
   178         ].
   183         ].
   179     ] loop.
   184     ] loop.
   180 
   185 
   181     "Modified: / 01-03-1997 / 00:59:55 / cg"
   186     "Modified: / 01-03-1997 / 00:59:55 / cg"
   182     "Modified (format): / 26-12-2011 / 10:42:08 / cg"
   187     "Modified (format): / 26-12-2011 / 10:42:08 / cg"
       
   188     "Modified (format): / 15-03-2019 / 15:05:44 / Stefan Vogel"
   183 !
   189 !
   184 
   190 
   185 possiblyGrow
   191 possiblyGrow
   186     "redefined - never grow"
   192     "redefined - never grow"
   187 
   193