199 Set rehashAllSubInstances |
197 Set rehashAllSubInstances |
200 " |
198 " |
201 |
199 |
202 "Created: / 24.10.1997 / 23:13:44 / cg" |
200 "Created: / 24.10.1997 / 23:13:44 / cg" |
203 ! ! |
201 ! ! |
204 |
|
205 |
202 |
206 !Set methodsFor:'Compatibility-ST80'! |
203 !Set methodsFor:'Compatibility-ST80'! |
207 |
204 |
208 initialIndexFor:hashKey boundedBy:length |
205 initialIndexFor:hashKey boundedBy:length |
209 "for ST-80 compatibility only; it is (currently) not used in this |
206 "for ST-80 compatibility only; it is (currently) not used in this |
922 index := index + 1 |
920 index := index + 1 |
923 ]. |
921 ]. |
924 index == startIndex ifTrue:[ |
922 index == startIndex ifTrue:[ |
925 delIndex ~~ 0 ifTrue:[ |
923 delIndex ~~ 0 ifTrue:[ |
926 keyArray basicAt:delIndex put:nil. |
924 keyArray basicAt:delIndex put:nil. |
|
925 ^ delIndex |
|
926 ]. |
|
927 self grow. |
|
928 length := keyArray basicSize. |
|
929 startIndex := index := self initialIndexForKey:key. |
|
930 ]. |
|
931 ] loop. |
|
932 |
|
933 "Modified: / 27-02-2011 / 15:30:42 / cg" |
|
934 ! |
|
935 |
|
936 findKeyOrNilOrDeletedEntry:key |
|
937 "Look for the key in the receiver. |
|
938 If it is found, return the index of the first unused slot. |
|
939 Grow the receiver, if key was not found, and no unused slots were present. |
|
940 The answer is the index into the keyArray where the (keyArray at:index) |
|
941 may contain: |
|
942 nil - an empty slot |
|
943 DeletedEntry - an empty slot, but preceeded and followed by non-empty |
|
944 slots with keys hashing to the same value (hash collisions) |
|
945 key - key is laready present in the slot." |
|
946 |
|
947 |index "{ Class:SmallInteger }" |
|
948 length "{ Class:SmallInteger }" |
|
949 startIndex probe |
|
950 delIndex "{ Class:SmallInteger }"| |
|
951 |
|
952 delIndex := 0. |
|
953 |
|
954 length := keyArray basicSize. |
|
955 startIndex := index := self initialIndexForKey:key. |
|
956 |
|
957 [ |
|
958 probe := keyArray basicAt:index. |
|
959 probe isNil ifTrue:[ |
|
960 delIndex == 0 ifTrue:[^ index]. |
|
961 ^ delIndex |
|
962 ]. |
|
963 probe == DeletedEntry ifTrue:[ |
|
964 delIndex == 0 ifTrue:[ |
|
965 delIndex := index |
|
966 ] |
|
967 ] ifFalse:[ |
|
968 key = probe ifTrue:[^ index] |
|
969 ]. |
|
970 |
|
971 index == length ifTrue:[ |
|
972 index := 1 |
|
973 ] ifFalse:[ |
|
974 index := index + 1 |
|
975 ]. |
|
976 index == startIndex ifTrue:[ |
|
977 delIndex ~~ 0 ifTrue:[ |
927 ^ delIndex |
978 ^ delIndex |
928 ]. |
979 ]. |
929 self grow. |
980 self grow. |
930 length := keyArray basicSize. |
981 length := keyArray basicSize. |
931 startIndex := index := self initialIndexForKey:key. |
982 startIndex := index := self initialIndexForKey:key. |