--- a/WeakIdentitySet.st Thu Jan 30 14:59:44 1997 +0100
+++ b/WeakIdentitySet.st Thu Jan 30 15:07:11 1997 +0100
@@ -212,75 +212,73 @@
findKeyOrNil:key
"Look for the key in the receiver.
- If it is found, return return the index of the first unused slot.
- Grow the receiver, if key was not found, and no unused slots were present"
+ If it is found, return return the index, otherwise
+ the index of the first unused slot.
+ Grow the receiver, if key was not found, and no unused slots were present.
+
+ Warning: an empty slot MUST be filled by the sender - it is only to be sent
+ by at:put: / add: - like methods."
|index "{ Class:SmallInteger }"
length "{ Class:SmallInteger }"
startIndex probe
- delIndex "{ Class:SmallInteger }"
- wasBlocked|
+ delIndex "{ Class:SmallInteger }"|
- wasBlocked := OperatingSystem blockInterrupts.
+ (OperatingSystem blockInterrupts) ifFalse:[
+ "/
+ "/ may never be entered with interrupts enabled
+ "/
+ OperatingSystem unblockInterrupts.
+ self error:'oops - unblocked call of findKeyOrNil'.
+ ^ nil "/ leads to other errors if proceeded
+ ].
- wasBlocked ifFalse:[
- "/ may never be entered with interrupts enabled
- self error:'oops - unblocked call of findKeyOrNil'
+ delIndex := 0.
+
+ length := keyArray basicSize.
+ index := key identityHash.
+ index < 16r1FFFFFFF ifTrue:[
+ index := index * 2
].
- [
- delIndex := 0.
+ index := index \\ length + 1.
+ startIndex := index.
- length := keyArray basicSize.
- index := key identityHash.
- index < 16r1FFFFFFF ifTrue:[
- index := index * 2
+ [true] whileTrue:[
+ probe := keyArray basicAt:index.
+ key == probe ifTrue:[^ index].
+ probe isNil ifTrue:[
+ delIndex == 0 ifTrue:[^ index].
+ keyArray basicAt:delIndex put:nil.
+ ^ delIndex
].
- index := index \\ length + 1.
- startIndex := index.
+ probe == 0 ifTrue:[
+ probe := DeletedEntry.
+ keyArray basicAt:index put:probe.
+ tally := tally - 1.
+ ].
+ delIndex == 0 ifTrue:[
+ probe == DeletedEntry ifTrue:[
+ delIndex := index
+ ]
+ ].
- [true] whileTrue:[
- probe := keyArray basicAt:index.
- key == probe ifTrue:[^ index].
- probe isNil ifTrue:[
- delIndex == 0 ifTrue:[^ index].
+ index == length ifTrue:[
+ index := 1
+ ] ifFalse:[
+ index := index + 1
+ ].
+ index == startIndex ifTrue:[
+ delIndex ~~ 0 ifTrue:[
keyArray basicAt:delIndex put:nil.
^ delIndex
].
-
- probe == 0 ifTrue:[
- probe := DeletedEntry.
- keyArray basicAt:index put:probe.
- tally := tally - 1.
- ].
- delIndex == 0 ifTrue:[
- probe == DeletedEntry ifTrue:[
- delIndex := index
- ]
- ].
-
- index == length ifTrue:[
- index := 1
- ] ifFalse:[
- index := index + 1
- ].
- index == startIndex ifTrue:[
- delIndex ~~ 0 ifTrue:[
- keyArray basicAt:delIndex put:nil.
- ^ delIndex
- ].
- ^ self grow findKeyOrNil:key
- ].
- ]
- ] valueNowOrOnUnwindDo:[
- wasBlocked ifFalse:[
- OperatingSystem unblockInterrupts
- ]
+ ^ self grow findKeyOrNil:key
+ ].
]
- "Created: 29.1.1997 / 21:43:57 / cg"
- "Modified: 29.1.1997 / 22:09:55 / cg"
+ "Modified: 30.1.1997 / 15:04:38 / cg"
!
keyContainerOfSize:n
@@ -299,5 +297,5 @@
!WeakIdentitySet class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.27 1997-01-29 21:10:33 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/WeakIdentitySet.st,v 1.28 1997-01-30 14:07:04 cg Exp $'
! !